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.

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

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题