go version)?go version go1.9 darwin/amd64
yes.
go env)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/csj/git/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/h8/glg18vq91h3b5x5nfpqnbcmw0000gn/T/go-build804657928=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
I just do these:
$GOPATH/src/cmd/hello$GOPATH/src/cmd/hello/main.go the content in the file:package main
import (
"fmt"
)
func main() {
fmt.Println("hello world")
}
cd $GOPATHgo build cmd/hello to be build successfully.
can't load package: package cmd/hello: cannot find package "." in:
/usr/local/Cellar/go/1.9/libexec/src/cmd/hello
https://github.com/golang/go/blob/release-branch.go1.9/src/cmd/go/internal/load/pkg.go#L1735
why treat packages start with cmd/ && !contains '/' followed as "." ?
For better or for worse, this is documented at https://golang.org/cmd/go/#hdr-Description_of_package_lists: "Import paths beginning with "cmd/" only match source code in the Go repository."
Since this is a question which has been answered, I'll assume it's safe to now close this issue.
Most helpful comment
For better or for worse, this is documented at https://golang.org/cmd/go/#hdr-Description_of_package_lists: "Import paths beginning with "cmd/" only match source code in the Go repository."