Expected behavior:
kind, err := filetype.MatchReader(badReader)
We would expect err != nil, but this is not so.
The documentation appears to contradict itself. In one example, we have:
kind, unknown := filetype.Match(buf)
if unknown != nil {
fmt.Printf("Unknown: %s", unknown)
return
}
Yet, in another example, we have:
// Try to match the file
fooFile := []byte{0x01, 0x02}
kind, _ := filetype.Match(fooFile)
if kind == filetype.Unknown {
fmt.Println("Unknown file type")
} else {
fmt.Printf("File type matched: %s\n", kind.Extension)
}
I would expect the documentation to be consistent and the error to be populated if we have an unknown filetype.
Expected behavior:
We would expect
err != nil, but this is not so.The documentation appears to contradict itself. In one example, we have:
Yet, in another example, we have:
I would expect the documentation to be consistent and the error to be populated if we have an unknown filetype.