packr
packr copied to clipboard
Issues migrating to go mod
We are currently building find with packr2 using go dep. I'm working to migrate to go mods and our packed files are not being looked for relative to the where the built binary is called.
$ packr2 version
v2.2.0
Directory structure:
|── main.go
└── cmd
├── root.go
└── version
Within root.go we have:
rootBox := packr.New("RootBox", "./")
version, err := rootBox.FindString("version")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
From our repo in $GOPATH/src/...
We do:
GO111MODULE=off packr2 clean . && GOOS=linux GOARCH=amd64 GO111MODULE=off packr2 build .
Then test run in a container to ensure no local deps:
$ mv ./my_cli ~/test
$ docker run -v $HOME/test:/test busybox /bin/sh -c "/test/my_cli --version"
my_cli version 0.2.3
Now when migrating to go mods:
$ mkdir -p ~/projects && cd ~/projects
$ git clone my_cli && cd my_cli
$ go mod init my_cli
$ rm Gopkg.*
$ GO111MODULE=on packr2 clean . && GOOS=linux GOARCH=amd64 GO111MODULE=on packr2 build .
Then run in container to test:
$ mv ./my_cli ~/test
$ docker run -v $HOME/test:/test busybox /bin/sh -c "/test/my_cli --version"
stat /version: no such file or directory
$ docker run -v $HOME/test:/test busybox /bin/sh -c "cd test; ./my_cli --version"
stat /test/version: no such file or directory
Am I missing something?