Open ismith opened 7 years ago
(This is after installing via go get
.)
It searches for the templates relative to the binary. When you run go run main.go the binary ends up in /tmp somewhere, and the templates are not copied there. I want to embed the templates in the future, but I'm also lazy and it works for us 😛
On Fri, May 19, 2017, at 11:42 PM, Ian Smith wrote:
(This is after installing via go get.)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub[1], or mute the thread[2].>
Links:
You can use something like this to find the directory corresponding to an import path inside GOPATH, and os.Chdir
into it during command initialization:
Not the go run
case - slackinviter
is in my PATH
, so it can be run from any cwd
; but parseFiles
loads relative to the cwd
. I'll open a PR if I can figure out a way to do this that doesn't break the build. (go-bindata
uses go generate
, which is nice, but isn't integrated with go build
AFAIK.)
I suspect the same issue affects the contents of static/
.
If I cd to
$GOPATH/src/github.com/flexd/slackinviter/main.go
,slackinviter -h
runs fine; if not,main.go
can't findtemplates/index.tmpl
.