slackinviter
slackinviter copied to clipboard
Templates don't seem to be found
If I cd to $GOPATH/src/github.com/flexd/slackinviter/main.go
, slackinviter -h
runs fine; if not, main.go
can't find templates/index.tmpl
.
(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:
- https://github.com/flexd/slackinviter/issues/18#issuecomment-302818212
- https://github.com/notifications/unsubscribe-auth/AAAJDRdblBg5qp2HL_ZfxK4r8PDwfsovks5r7gzWgaJpZM4NhDBq
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:
https://github.com/go-gl/example/blob/ee0644b7c5650555db3c0f4d04f9ef5716e6c6ac/gl21-cube/cube.go#L207-L228
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/
.