Skip to content

Commit

Permalink
Add support to ConvertFormats for reading from standard input
Browse files Browse the repository at this point in the history
This can be invoked by setting `inFilename` to `"-"`. This a pretty standard
shortcut for specifying standard input.
  • Loading branch information
Tenzer committed Dec 2, 2016
1 parent 8a1ad56 commit d8447d5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion codec.go
Expand Up @@ -30,7 +30,14 @@ type Decoder interface {
type ConversionFunc func(r io.Reader, w io.Writer, options Options) error

func ConvertFormats(inFilename, outFilename string, conversionFunc ConversionFunc, options Options) error {
inFile, err := os.Open(inFilename)
var inFile *os.File
var err error

if inFilename == "-" {
inFile = os.Stdin
} else {
inFile, err = os.Open(inFilename)
}
if err != nil {
return err
}
Expand Down

0 comments on commit d8447d5

Please sign in to comment.