On Thu, 5 Oct 2017, at 08:58 AM, Johan terryn wrote:
> In following code:


> 


> type JPGFile struct {


>     Exif_SOI [2]byte Exif } type Exif struct { APP1Marker   [2]byte
>     APP1DataSize uint16 ExifHeader   [6]byte TIFFHeader[6]byte }> func 
> ReadFile(filename string) (JPGFile, error) {


>     jpgFile := JPGFile{} in, err := os.Open(filename) defer in.Close()
>     if err != nil {    return jpgFile, err } binary.Read(in,
>     binary.LittleEndian, &jpgFile)>         return jpgFile, nil
> }
> **


> **


> **


> *binary.Read* accepts "in" (os.File) as a reader, but if I pass the
> file as a parameter to the function I get the (correct ) error message
> that "in" is not a reader, as defined in the documentation: func
> Read(r *io.Reader*, order ByteOrder, data interface{}) error> 


> Or is this working as intended?



Can you provide a fuller example showing imports? Your code looks
correct and "in" is an io.Reader so it's surprising that you are getting
that message. This non-runnable version of your code compiles fine:
https://play.golang.org/p/aruCeIHFEZ
Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to