I'm new to go and I have a problem when I write packages. when importing the package I get the error:
package mypackages/numbers is not in GOROOT (/usr/local/Cellar/go/1.16.5/libexec/src/mypackages/numbers)
this is the code structure from my $GOPATH/src:
.
├── github.com
├── gitlab.com
├── golang.org
├── learning
│ └── test
│ └── main.go
└── mypackages
└── numbers
└── numbers.go
learning/test/main.go content:
package main
import (
"fmt"
"mypackages/numbers"
)
func main() {
fmt.Println(numbers.Even(6))
}
mypackages/numbers/numbers.go content:
package numbers
func Even(n uint) bool {
if n%2 == 0 {
return true
}
return false
}
The environment variables running go env:
GOCACHE="/Users/AminBSHR/Library/Caches/go-build"
GOENV="/Users/AminBSHR/Library/Application Support/go/env"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOMODCACHE="/Users/AminBSHR/go/pkg/mod"
GOPATH="/Users/AminBSHR/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.5/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.16.5/libexec/pkg/tool/darwin_amd64"