Go 第三方库

发布时间: 更新时间: 总字数:798 阅读时间:2m 作者: IP上海 分享 网址

汇总Golang经常使用的第三方库,比如 cobra 等

介绍

http.DetectContentType ...
package main

import (
	"fmt"
	"net/http"
	"os"
)

func main() {
	// Open File
	f, err := os.Open("/usr/local/Cellar/graphviz/10.0.1/share/doc/graphviz/libguide.pdf")
	if err != nil {
		panic(err)
	}
	defer f.Close()

	buffer := make([]byte, 512)
	if _, err := f.Read(buffer); err != nil {
		panic(err)
	}
	contentType := http.DetectContentType(buffer)
	fmt.Println("Content Type: " + contentType)
}
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数