在Go可执行文件中包含模板文件

huangapple go评论78阅读模式
英文:

Including template files in Go executable

问题

我想解析一个模板HTML文件夹,并在构建时将它们缓存(或缓冲),以便在以后的Web项目中使用。基本上,我试图做的是,当我构建我的项目时,我不需要将HTML文件与可执行文件一起上传。

英文:

I want to parse a folder of template HTML files and cache (or buffer) them on build for later use in a web project. Basically I am trying to make it so when I build my project I dont need to take the HTML files with me when I upload the executable file.

答案1

得分: 2

我认为你可能在谈论将HTML文件嵌入到二进制文件中?

如果是这样,到目前为止我见过的最好的方法是使用camlistore的fileembed:https://code.google.com/p/camlistore/source/browse/pkg/fileembed/fileembed.go

在这里可以找到使用说明:https://groups.google.com/d/msg/golang-nuts/LQMv7Zsmsi0/8Aax1XSekjAJ

该线程还提供了其他用于此目的的包的附加信息。

英文:

I think maybe you are talking about embedding the html files in your binary?

If so the best way to do this that I've seen so far has been camlistores fileembed: https://code.google.com/p/camlistore/source/browse/pkg/fileembed/fileembed.go

See here for directions on use: https://groups.google.com/d/msg/golang-nuts/LQMv7Zsmsi0/8Aax1XSekjAJ

That thread has addtional info on other packages for this as well.

huangapple
  • 本文由 发表于 2012年9月6日 04:53:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/12289582.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定