I am trying to build my golang cli project with TravisCI. One of the problem found is when running test which create files, I got permission error.
But when trying to run the test with sudo, it changed to sudo: go: command not found
Here is the error snippet from travis:
Anyone can help with a solution?
Notes:
Answering my own question
Compiling from the comments, I tried 2 options
The first is to update the current working directory permission, with chmod 777 .
(yes I set all, dont want to really bother with travis specific behavior), but turns out it doesn't work. Don't know for sure the cause this time, probably the dynamically generated binary also have permission issue
The solution that works for me is reading the go
binary path, then re-run it as sudo, as shown below
script:
- GO_EXECUTABLE_PATH=$(which go)
- echo $GO_EXECUTABLE_PATH
- sudo $GO_EXECUTABLE_PATH test ./...