Skip to content

cmd/go: clarify documentation for -replace flag #26417

@komuw

Description

@komuw

Please answer these questions before submitting your issue. Thanks!

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

go version devel +b59b42cee8 Tue Jul 17 10:07:18 2018 +0000 darwin/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/go"
GOMOD="
/mystuff/meli/go.mod"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/p5/56z0g6pj6dq0njc1n6wccz4r0000gn/T/go-build722725015=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

try to use a go module replacement to point to a local repository

git clone https://github.com/pkg/errors to a place outside GOPATH
in your application's go.mod file add a replace directive to point to the cloned github.com/pkg/errors
cat go.mod

replace github.com/pkg/errors => ../errors

try to build your application

What did you expect to see?

  • my application to build succefully without problem(using the cloned errors package)

What did you see instead?

go: parsing ../errors/go.mod: open ~/mystuff/errors/go.mod: no such file or directory
go: error loading module requirements

However, if I manually add a go.mod file to the cloned errors package

echo 'module "github.com/pkg/errors"' >> ~/mystuff/errors/go.mod

I'm able to build my application using that local errors package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.modules

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions