Unknown subcommand "mod" error while running go mod init
Asked Answered
W

2

10

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.

Wizardly answered 26/2, 2020 at 9:34 Comment(0)
B
19

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.

Bravo answered 26/2, 2020 at 9:36 Comment(0)
S
1

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

Stacey answered 26/2, 2020 at 9:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.