feat: initial commit

This commit is contained in:
Tomas Aparicio
2015-09-24 10:40:41 +01:00
commit 4af2d19f91
18 changed files with 767 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
# filetype [![Build Status](https://travis-ci.org/h2non/filetype.png)](https://travis-ci.org/h2non/filetype) [![GoDoc](https://godoc.org/github.com/h2non/filetype?status.svg)](https://godoc.org/github.com/h2non/filetype)
Small [Go](https://golang.org) package to infer the file type checking the [magic number](https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_numbers_in_files) of a given binary buffer.
Supports a wide range of file types, including images formats, fonts, videos, audio and other common application files, and provides the proper file extension and convenient MIME code.
## Installation
```bash
go get gopkg.in/h2non/filetype.v0
```
## Usage
```go
import (
"fmt"
"io/ioutil"
"gopkg.in/h2non/filetype.v0"
)
func main() {
buf, _ := ioutil.ReadFile("sample.jpg")
kind, unkwown := filetype.Type(buf)
if unkwown != nil {
fmt.Printf("Unkwown file type")
return
}
fmt.Printf("File type found: %s. MIME: %s", kind.Extension, kind.MIME.Value)
}
```
## API
## License
MIT - Tomas Aparicio