I cann't update my file go.mod since I use the command go test cmd/... -v inner of a task. The packages are changed to older versions, even the line go 1.14 is changed to go 1.13.
I had no idea what's hapenning until I run directly from command line go test cmd/... -v and I checked that the file mod.go was not modified.
So, why does task is changing such file and how to fix it?
Hi @tredoe,
I don't think that is a bug. Task won't modify the go.mod file for you, the go command does that.
My bet is that you likely have two different Go versions installed, and Task is calling one of them and your shell is seeing the other one.
I've tried several things:
I removed my Go installation which was not into a directory used by default (/opt/go). Now, it is installed on /usr/local/go and GOPATH is in $HOME/go. I changed the environment variables, and Go is working well with the last version one.
But the issue follows.
I deleted both go.mod and go.sum, and I started the module again with go mod init [name]
The issue follows.
I deleted the directory .git, but nothing...
Any idea more?
And to be sure that there is only Go installation:
$ sudo find / -type f -name 'go'
/usr/local/go/bin/go
Thinking... Could be due to the editor Visual Studio Code?
I closed the editor, I deleted again go.mod and go.sum, I started the module, run go test ... (it goes well), but go.mod changes when I use task.
I also deleted all temporary files related to Go: rm /tmp/go*
@tredoe Unfortunately, I have no further ideas of what's happening. To me, it still seems that you're somehow using two different Go versions.
You could perhaps try running which go both inside Task and in your shell.
If you discover what's happening, let us know (since it can help someone else in the future).
@andreynering It returns /usr/local/go/bin/go, the same result than one got using find directly from the shell.
After of doing some tests, I checked that the issue is not due to task. When I compile whatever program inner of my main project, the file 'go.mod' is changed.
The issue is by the go tools.
Reinstall everything, clean the cache used to build packages (go clean -cache), and it is working well now.