当在编译打包文件时,有时候html文件需要编译进二进制 , 可以使用这个包
github.com/gobuffalo/packr
当使用了go.mod的话 , 直接在代码中引入使用就行 , 运行或者编译时会自动把依赖下载下来
box := packr.NewBox("../static")
content,err:=box.FindString("html/login.html")
这样读取到的字符串 , 再使用template包就可以了 , 编译后html也会被编译进去
当在编译打包文件时,有时候html文件需要编译进二进制 , 可以使用这个包
github.com/gobuffalo/packr
当使用了go.mod的话 , 直接在代码中引入使用就行 , 运行或者编译时会自动把依赖下载下来
box := packr.NewBox("../static")
content,err:=box.FindString("html/login.html")
这样读取到的字符串 , 再使用template包就可以了 , 编译后html也会被编译进去
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。