使用go1.6内嵌资源构建静态服务
# content.txt内容
123package main
import (
_ "embed"
"fmt"
)
//go:embed test.txt
// 三个类型
// []byte 需import (_"embed")
// string
// embed.FS 多个文件和目录(注意是多个)
// var test string
var test []byte
func main() {
fmt.Println(test)
}最后更新于