多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] > https://github.com/h2non/filetype ## 概述 - 通过文件的魔术数字判断 ## 示例 ``` package main import ( "fmt" "io/ioutil" "github.com/h2non/filetype" ) func main() { // Open a file descriptor file, _ := os.Open("movie.mp4") // We only have to pass the file header = first 261 bytes head := make([]byte, 261) file.Read(head) if filetype.IsImage(head) { fmt.Println("File is an image") } else { fmt.Println("Not an image") } } ```