Skip to content

cmd/go: misleading error message for replacement module with capital letters #38220

@retgits

Description

@retgits

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

$ go version
go version go1.14.1 darwin/amd64

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/lstigter/Library/Caches/go-build"
GOENV="/Users/lstigter/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/lstigter/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4b/hq3khbrx30b_wk3fz63z9vww0000gq/T/go-build752664778=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I forked a project from https://github.com/wavefrontHQ/wavefront-lambda-go which doesn't use Go modules yet to help them adopt Go modules. I created a go.mod file, using

$ go mod init github.com/wavefrontHQ/wavefront-lambda-go
$ go mod tidy

That results in the go.mod file

module github.com/wavefronthq/wavefront-lambda-go

go 1.14

require (
	github.com/aws/aws-lambda-go v1.12.1
	github.com/rcrowley/go-metrics v0.0.0-20190706150252-9beb055b7962
	github.com/wavefronthq/go-metrics-wavefront v0.9.0
)

The resulting code was committed to the forked repo https://github.com/retgits/wavefront-lambda-go

In a project where I want to use this new module, I added a replace directive into my go.mod file to point to the new location

module github.com/retgits/acme-serverless-payment

replace github.com/wavefronthq/wavefront-lambda-go => github.com/retgits/wavefront-lambda-go v0.0.0-20200402174306-c89629d5856a

go 1.13

require (
	github.com/aws/aws-lambda-go v1.15.0
	github.com/aws/aws-sdk-go v1.29.27
	github.com/getsentry/sentry-go v0.5.1
	github.com/gofrs/uuid v3.2.0+incompatible
	github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
	github.com/pulumi/pulumi v1.12.1
	github.com/pulumi/pulumi-aws v1.26.0
	github.com/retgits/creditcard v0.6.0
	github.com/retgits/pulumi-helpers v0.1.3
	github.com/wavefronthq/wavefront-lambda-go v0.0.0-20190812171804-d9475d6695cc
	gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
	gopkg.in/yaml.v2 v2.2.8 // indirect
)

Running any of the go commands throws an error

What did you expect to see?

$go mod tidy
<no errors>

What did you see instead?

$ go mod tidy                                              
go: github.com/retgits/[email protected]: parsing go.mod:
        module declares its path as: github.com/wavefrontHQ/wavefront-lambda-go
                but was required as: github.com/retgits/wavefront-lambda-go

The error message is a little misleading, and as @jayconrod discovered is about the capitalization of wavefrontHQ. After changing it all to lowercase in the module, it was solved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions