Skip to content

cmd/go: get fails to get a package when mod file has replace in a repo that imports packages from another go module in the same repository #35693

Closed
@dayadev

Description

@dayadev

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

go version go1.13.4 darwin/amd64

Does this issue reproduce with the latest release?

yes it does

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

go env Output
GO111MODULE=""
GOARCH="amd64"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.13.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.4/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
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"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_4/g37z5y0j0t7dppmsyxymdsx00000gn/T/go-build977671086=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?


api
├── apiA
│   ├── apiA.go
│   └── go.mod
└── lib
    ├── go.mod
    └── lib.go

Here is my mod file contents

apiA mod contents


module api/apiA

replace api/lib => ../lib

require (
    github.com/fatih/structs v1.1.0 // indirect
    github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect
    github.com/sirupsen/logrus v1.4.2
    api/lib v0.0.0-00010101000000-000000000000 // indirect
)

In the above mod file last line the the require api v0.0.0-00010101000000-000000000000 is actually generated for the module in lib directory

Everything works fine as the code builds and runs fine but when I try to get a package from github with

go get github.com/spf13/[email protected]

What did you expect to see?

expected to get the package and add it to go.mod file

What did you see instead?

It throws below error

go: malformed module path "api/lib": missing dot in first path element

api/lib is referring to my module in lib directory and not sure why its making an http call to get api/lib though I used replace

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions