Skip to content

cmd/go: go get <current package> gives arcane error #54745

@MaerF0x0

Description

@MaerF0x0

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

go version
go version go1.18.5 darwin/amd64

Does this issue reproduce with the latest release?

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

go env Output
go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/$ME/Library/Caches/go-build"
GOENV="/Users/$ME/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/$ME/dev/pkg/mod"
GONOPROXY="github.com/$EMPLOYER*"
GONOSUMDB="github.com/$EMPLOYER*"
GOOS="darwin"
GOPATH="/Users/$ME/dev"
GOPRIVATE="github.com/$EMPLOYER*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.18.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.18.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.18.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/$ME/dev/src/github.com/$EMPLOYER/$REPO/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/lx/c2s6byr55blfmt03c9zhhmv00000gn/T/go-build3003361518=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

was trying a command in the wrong cwd and the error lead me to think my command was wrong, not the directory... An updated output could help.

cd $GOPATH/src/github.com/$EMPLOYER/$REPO
go get github.com/$EMPLOYER/$REPO

-->

go get github.com/$EMPLOYER/$REPO
go: github.com/$EMPLOYER/$REPO: invalid github.com import path "github.com/$EMPLOYER"

go get  github.com/$EMPLOYER/$REPOT@latest
go: can't request version "latest" of the main module (github.com/$EMPLOYER/$REPO)

What did you expect to see?

I presume this is because you cannot import a module into itself? If so it might be helpful to emit a message that indicates a hint that you cannot do that
eg:

go get github.com/$EMPLOYER/$REPO
go: github.com/$EMPLOYER/$REPO: cannot import module into itself

go get  github.com/$EMPLOYER/$REPO@latest
go: github.com/$EMPLOYER/$REPO: cannot import module into itself

What did you see instead?

go: github.com/segmentio/personas-utils: invalid github.com import path "github.com/$EMPLOYER"

go: can't request version "latest" of the main module (github.com/$EMPLOYER/$REPO)

Happy to help with a PR if we agree this is would be a good change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.modules

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions