Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: You are neither in a module nor in your GOPATH. #39030

Closed
chrsbot opened this issue May 12, 2020 · 7 comments
Closed

cmd/go: You are neither in a module nor in your GOPATH. #39030

chrsbot opened this issue May 12, 2020 · 7 comments

Comments

@chrsbot
Copy link

@chrsbot chrsbot commented May 12, 2020

What version of Go are you using (go version)?

$ go version

go version go1.14.2 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env

go env GOOS GOARCH
windows
amd64

What did you do?

I'm pretty sure I did nothing. The error just constantly pops up and I've read the other issues with this logged here but they don't help. Please provide a clear walk through (I'm new to this).

Just a side note, I am in my GOPATH folder. So, I'm really confused as to why this is happening.

What did you expect to see?

I expected to not see this message.

What did you see instead?

I saw this message.

@dmitshur dmitshur changed the title You are neither in a module nor in your GOPATH. cmd/go: You are neither in a module nor in your GOPATH. May 12, 2020
@dmitshur
Copy link
Member

@dmitshur dmitshur commented May 12, 2020

@chrsbot Can you please provide the complete output of go env in the issue? Also please include what command you ran before you got the error, and what directory you ran that command in. Thanks.

@chrsbot
Copy link
Author

@chrsbot chrsbot commented May 13, 2020

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented May 13, 2020

@chrsbot We'd still like to understand whether this error was shown inappropriately and whether it's clear enough.

Could you please tell us:

  • Complete output of go env
  • What command you ran before you saw the error
  • What directory you ran the command in (was it specifically $GOPATH or a subdirectory)?
  • What files were there
  • What would have made the error more clear, or if the command should have succeeded, what should it have done?
@chrsbot
Copy link
Author

@chrsbot chrsbot commented May 13, 2020

Sure thing. Hopefully the below answers suffice.

go env command

go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\chris\AppData\Local\go-build
set GOENV=C:\Users\chris\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\chris\Documents\Swanbot
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=c:\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=c:\go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\chris\AppData\Local\Temp\go-build720043642=/tmp/go-build -gno-record-gcc-switches
PS C:\Users\chris\Documents\Swanbot>

** what command yo ean before you saw the error**

Don't think I ran commands. The cause of the issue was I tried to create a package for testing, then import it into my main fail. Then the issue began to pop up.

** what directory you ran the command in **

I believe it was in $GOPATH (which I have set to C:\Users\chris\Documents\Swanbot)

** what files were there**
my bin, src, pkg files were there. Along with my hello.go file. There's also a folder called .vscode in the main folder.

** what would have made the error more clear **

A walk-through of how to solve the problem would have made it more clear. As the error merely just states what the problem and gives you suggestions of what to do. A little tutorial of how to perform those steps would've been great.

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented May 13, 2020

Don't think I ran commands. The cause of the issue was I tried to create a package for testing, then import it into my main fail. Then the issue began to pop up.

Where exactly did you see the error? Most issues here are seen after a go build command or something like that. Was this in an editor? Please help us understand what happened.

A walk-through of how to solve the problem would have made it more clear. As the error merely just states what the problem and gives you suggestions of what to do. A little tutorial of how to perform those steps would've been great.

What resources have you looked at so far? Usually we recommend people go through Getting Started for installing Go, and then How to Write Go Code for directory layout and packaging. Both are linked from https://golang.org/doc.

Developing code directly in GOPATH may confuse some tools. Generally, code would be in either a directory that matches its import path like $GOPATH/src/github.com/user/project or a directory outside $GOPATH like $HOME/Code/project. It shouldn't be necessary to explicitly set GOPATH in most cases, and we're planning to phase it out at some point in the future.

@chrsbot
Copy link
Author

@chrsbot chrsbot commented May 13, 2020

Where exactly did you see the error? Most issues here are seen after a go build command or something like that. Was this in an editor? Please help us understand what happened

Thank you for reminding me actually. I used go build actually. At first, I ran it in git bash terminal then in VSCode's terminal I believe.

What resources have you looked at so far? Usually we recommend people go through Getting Started for installing Go, and then How to Write Go Code for directory layout and packaging. Both are linked from https://golang.org/doc.

I will have a closer look at these resources thank you.

@jayconrod
Copy link
Contributor

@jayconrod jayconrod commented May 27, 2020

Closing this issue. Please let us know if something is missing from those introductory pages though.

@jayconrod jayconrod closed this May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.