MCPcopy Create free account
hub / github.com/h2non/filetype / MatchFile

Function MatchFile

match.go:44–52  ·  view source on GitHub ↗

MatchFile infers a file type for a file

(filepath string)

Source from the content-addressed store, hash-verified

42
43// MatchFile infers a file type for a file
44func MatchFile(filepath string) (types.Type, error) {
45 file, err := os.Open(filepath)
46 if err != nil {
47 return types.Unknown, err
48 }
49 defer file.Close()
50
51 return MatchReader(file)
52}
53
54// MatchReader is convenient wrapper to Match() any Reader
55func MatchReader(reader io.Reader) (types.Type, error) {

Callers 1

TestMatchFileFunction · 0.85

Calls 1

MatchReaderFunction · 0.85

Tested by 1

TestMatchFileFunction · 0.68