Unknown go subcommand when starting a new Device Service project

Hello,
I use this guide 4.3.1. Writing a Device Service in Go from official edgexfoundry docs (doesn’t allow me to post the exact url) to see how start a new device service.
In 4.3.1.3.Starting a new Device Service project step 4 says to enter the command GO111MODULE=on go mode init . Where should i enter that command? I run it in terminal but i get the message :
go: unknown subcommand "mode"
Run ‘go help’ for usage.

Thank you

Hi sakxam,

the correct command is:

GO111MODULE=on go mod init

So the same command without the “e”. It is just a typo in the guide.

Kind regards,
Alex

2 Likes

@chrab’s answer is right but I just want to add why.

It is because it is Go’s convention.

This line can be used as an environment variable so that it can be used in a terminal or bashrc (or so) to indicate that you want to use Go’s new module system after Go v1.11

GO111MODULE=on # (in a terminal) or
export GO111MODULE=on # (in a shell config file)

This line can be used as a command to init a new Go project

go mod init # (in a terminal)

I run go mod init in the terminal but the output message is the same :
go: unknown subcommand "mod"
Run ‘go help’ for usage.

Which version of Go are you using?

Would you share the return of go version?

Also, env | grep GO111MODULE?

I use go version go1.10.4 linux/amd64
env | grep GO111MODULE doesn’t return anything.
So there isnt GO111MODULE in the env list

I see…

The version of Go should be 1.11 or later.
Mine is go version go1.12.7 linux/amd64.

So for now, you may install a newer version of Go.
(GOMODULE is not set in my case, too).

  1. Try which go to find out where your go is
  2. Remove it and re-install Go without apt since apt command of ubuntu installs little old version of go.

In my case, go lives in /usr/local/go/bin/go.
I would do rm -rf /usr/local/go and follow the official steps or my note (https://github.com/bus710/golang-dev-env-setting).

I install the version go1.12.7 and where i run the GO111MODULE=on go mod init command had some permission problem . So i change the permissions (i gave all permissions) to folder where the project is and the problem solved.
But now i have problem with the command make build
I am in step 4.3.1.8. Rebuild your Device Service from guide 4.3.1. Writing a Device Service in Go
The output is the below :

Thank you very much

Not sure about this since I have not seen this before.

One thing I can suggest is that checking the version of the SDK by:

git branch

If you use Edinburgh for both the developer-scripts and SDK, good.
If the branch command returns master or something else, match it by:

git branch edinburgh

// if the above command changes the branch from master to edinburgh,
// try the make build again