dql7588 2014-12-06 22:09
浏览 418
已采纳

html / template:模式即使绝对路径也不会匹配任何文件

I have a global constant like this.

const TemplateDir string = "/home/joe/go/src/proj/template/"

Then, later in my code I call this.

template.ParseGlob(filepath.Join(TemplateDir, "*.tmpl"))

I know that filepath.Join(TemplateDir, "*.tmpl") produces /home/joe/go/src/proj/template/*.tmpl.

This all compiles fine. However, when I try to run my executable from a directory outside of proj, I get this error.

html/template: pattern matches no files: `template/*.tmpl`

I'm not sure why I'm getting that error if I passed in an absolute path. Any ideas?

Update I forgot to mention that I'm calling my program through the $PATH variable. That is, I'm not executing ./proj anywhere. I'm just calling proj from my home directory.

  • 写回答

1条回答 默认 最新

  • douguai7291 2014-12-07 02:29
    关注

    So, it turns out that the version I was calling using my $PATH variable was outdated! Here's what happened.

    src/proj$ go build
    src/proj$ ./proj
    

    That would work fine, but this wouldn't work.

    ~/$ proj
    

    That's because I forgot to go install my package! After doing go install in my package directory, I could call my program from anywhere.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制