Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Issues migrating to go mod #195

Open
rjbez17 opened this issue May 2, 2019 · 0 comments
Open

Issues migrating to go mod #195

rjbez17 opened this issue May 2, 2019 · 0 comments
Labels
environmental The problem is with the OP's environment (GOPATH, etc...) help wanted Extra attention is needed

Comments

@rjbez17
Copy link

rjbez17 commented May 2, 2019

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?

@markbates markbates added environmental The problem is with the OP's environment (GOPATH, etc...) help wanted Extra attention is needed labels May 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
environmental The problem is with the OP's environment (GOPATH, etc...) help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants