douhuai4155
2016-12-28 02:36
浏览 82
已采纳

来自第三方库的Golang解析模板

I am writing a library which is parsing templates from its template package. When I am using it within a sample application its reading the template from its own directory but the code in libary is failing.

Here is the libary - https://github.com/bangarharshit/bigpipe-golang and I am facing issues with this line - https://github.com/bangarharshit/bigpipe-golang/blob/master/Application.go#L66

Copying code from lib -

templates, err := template.ParseFiles("templates/bigpipe.html")
if err != nil {
    return
}

图片转代码服务由CSDN问答提供 功能建议

我正在编写一个库,该库正在从其模板包中解析模板。 当我在示例应用程序中使用它时,它会从自己的目录中读取模板,但是libary中的代码失败。

此处是libary- https://github.com/bangarharshit/bigpipe-golang ,我在这行遇到问题- https://github.com/bangarharshit/bigpipe-golang/blob/master/Application.go #L66

从lib复制代码-

  templates,err:= template.ParseFiles(“ templates / bigpipe。  html“)
if err!= nil {
 return 
} 
   
 
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dqoqnmb163241 2016-12-31 08:16
    已采纳

    One alternative soultion is to copy content from file into a variable and use template.parse instead of template.parsefiles

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题