I have installed the go language in my ubuntu using sudo apt install golang-go
.
It was successfully installed. When i run go version
I am getting go version go1.10.4 linux/amd64
but when i tried running go mod init projectName
I am getting the following error go: unknown subcommand "mod"
Do I need to install mod package or am i missing something? I have implemented the solution given by christophe in this forum but it didn't work for me.
The go mod init command creates a go. mod file to track your code's dependencies. So far, the file includes only the name of your module and the Go version your code supports. But as you add dependencies, the go. mod file will list the versions your code depends on.
mod file within the mymodule directory to define the Go module itself. To do this, you'll use the go tool's mod init command and provide it with the module's name, which in this case is mymodule .
go mod tidy ensures that the go. mod file matches the source code in the module. It adds any missing module requirements necessary to build the current module's packages and dependencies, if there are some not used dependencies go mod tidy will remove those from go.
Preliminary module support was added in Go 1.11, so Go 1.10 knows no mod
subcommand.
You need to install a newer, preferably the newest 1.14 version of Go. Get it from the official downloads page. Go 1.10 is not even supported anymore (doesn't receive security patches).
The prepared packages of OSes usually lag behind new releases. I'd advise to always get Go from the official page.
Because preliminary support for go-modules came in version 1.11 and 1.12.
More here
I suggest that you install using the linux build directly from golang
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With