-3

While executing a very simple project in Goland IDE, I see following errors. Tried setting GO111MODULE=on/off/auto.. Didn't make any difference!! Any idea?

Logs:

GOROOT=/usr/local/go #gosetup

GOPATH=/Users/<uid>/Documents/workspace/<ws_name> #gosetup
/usr/local/go/bin/go build -o /private/var/folders/jn/kjwpzfrx5f98w9nrkzkw48040000gn/T/___go_build_main_go /Users/<uid>/Documents/workspace/<project>/src/github.com/<github_id>/users-api/main.go #gosetup

main.go:4:2: no required module provides package github.com/<github_id>/users-api/app: working directory is not part of a module

Compilation finished with exit code 1

NOTE: uid, github_id, ws_name etc are masks for actual ids

Brits
  • 14,829
  • 2
  • 18
  • 31
ios_mxe
  • 115
  • 2
  • 12
  • Do you have a go.mod file in your work directory? Make sure you run: go mod init before trying to go build – lnogueir Mar 02 '21 at 00:47
  • Please read and stick to the first few documents in https://golang.org/doc/#getting-started where it is explained how to set up a module and build Go code. Note that setting GOROOT was never needed and is not needed and just looks fhishy. – Volker Mar 02 '21 at 05:12
  • What Go version are you using? – artspb Mar 02 '21 at 07:24
  • All this mess was created because of IDE. Sorry for the confusion! – ios_mxe Mar 02 '21 at 16:07

1 Answers1

1

Try executing go mod init <your project name>

Then execute go mod tidy

Levan
  • 616
  • 6
  • 10