Error cannot use path@version syntax in GOPATH mode

Posted on Wed 15 December 2021 in go • Tagged with go

I was trying to install xk6 using this command:

go install go.k6.io/xk6/cmd/xk6@latest

And I got this error:

package go.k6.io/xk6/cmd/xk6@latest: cannot use path@version syntax in GOPATH mode

Although I found a question in Stack Overflow with that error, the given solutions didn't work for me. In the end, I learned that the message was caused because I was using an old version of Go: the path@version was added in Go 1.16 and I was using 1.15. Thus, the solution for my problem was updating Go.