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.

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.