mwdowns
(Matthew Downs)
April 14, 2018, 7:33pm
1
Having trouble getting off the ground after installation. Following along in the install page:
Installed using the Windows installer
Set my GOPATH to be C:\Users\Me\OneDrive\Documents\GitHub\go
Created a src file in the go folder
Created a file called hello.go with the example code from the tutorial (so ~/src/hello/hello.go)
Run “go build” while in the src\hello folder
I get this error:
can’t load package: package hello: cannot find package “hello” in any of:
C:\Go\src\hello (from $GOROOT)
C:\Users\Me\OneDrive\Documents\GitHub\go\src\hello (from $GOPATH)
Am I still missing something?
When I type go env
I see my GOROOT as C:\Go
and my GOPATH as C:\Users\Me\OneDrive\Documents\GitHub\go
. I feel like that’s what it should be.
Thanks for your help.
NobbZ
(Norbert Melzer)
April 14, 2018, 7:39pm
2
Can you please do dir C:\Users\Me\OneDrive\Documents\GitHub\go\src
and dir C:\Users\Me\OneDrive\Documents\GitHub\go\src\hello
and show the output of it here?
mwdowns
(Matthew Downs)
April 14, 2018, 7:50pm
3
Directory: C:\Users\Me\OneDrive\Documents\GitHub\go\src
Mode LastWriteTime Length Name
---- ------------- ------ ----
da---l 4/14/2018 2:16 PM hello
…
Directory: C:\Users\Me\OneDrive\Documents\GitHub\go\src\hello
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---l 4/14/2018 2:49 PM 182 hello.go
…and contents of hello.go please
mwdowns
(Matthew Downs)
April 15, 2018, 2:17pm
5
package main
import "fmt"
func main() {
fmt.Println("hello, you")
}
I would run go run hello.go
, and go install
mwdowns
(Matthew Downs)
April 15, 2018, 4:11pm
7
For “go build” I would get this error:
can’t load package: package hello: cannot find package “hello” in any of:
C:\Go\src\hello (from $GOROOT)
C:\Users\Me\OneDrive\Documents\GitHub\go\src\hello (from $GOPATH)
For “go run hello.go” I would get this error:
package main: cannot find package “.” in:
C:\Users\Me\OneDrive\Documents\GitHub\go\src\hello
I ended up just nuking my install and going with the default location of the go folder at Users\Me\go and things seem to be working now. No idea why it couldn’t find my GOPATH when it was a different place (could be that the OneDrive syncing was a problem).
system
(system)
Closed
July 14, 2018, 4:11pm
8
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.