[Go] golang读取打包html文件到二进制

当在编译打包文件时,有时候html文件需要编译进二进制 , 可以使用这个包

github.com/gobuffalo/packr

当使用了go.mod的话 , 直接在代码中引入使用就行 , 运行或者编译时会自动把依赖下载下来

box := packr.NewBox("../static")

content,err:=box.FindString("html/login.html")

这样读取到的字符串 , 再使用template包就可以了 , 编译后html也会被编译进去