企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[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") } } ```