What should be the values of GOPATH and GOROOT in Go?
Hello everyone! I started learning Go a couple of weeks ago and I can't figure out the environment variable setup. I installed Go through the official installer on Windows, and it seems to have been installed in C:\Go. But when I try to build my first project, I keep getting errors like "cannot find package" or "GOPATH not set."
Here's my simple code that I'm trying to run:
```go
// main.go
package main
import "fmt"
import "example.com/mypackage/mypkg"
func main() {
fmt.Println(mypkg.Hello())
}
```
And the package I want to use:
```go
// mypkg.go in the mypkg folder
package mypkg
func Hello() string {
return "Hello from my package!"
}
```
I've tried setting GOPATH to different locations: C:\Users\MyName\go, C:\Projects\go, and even left it empty. But nothing w
No answers yet.
Log in to leave an answer