Last active
August 29, 2015 14:06
-
-
Save tomohiro/80ee263b44e32161a5d0 to your computer and use it in GitHub Desktop.
Check mimetype of images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: | |
// $ go run mime.go | |
// foo.png -> image/png | |
// bar.jpg -> image/jpeg | |
// baz.gif -> image/gif | |
// foo.bmp -> image/bmp | |
// | |
// Description: | |
// Check mimetype of images | |
// | |
package main | |
import ( | |
"fmt" | |
"mime" | |
"path/filepath" | |
) | |
func main() { | |
images := []string{"foo.png", "bar.jpg", "baz.gif", "foo.bmp"} | |
for _, f := range images { | |
mt := mime.TypeByExtension(filepath.Ext(f)) | |
fmt.Printf("%s -> %s\n", f, mt) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment