Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go clean fails in case of no Go source and enabling Go Modules #31002

Open
lufia opened this issue Mar 22, 2019 · 3 comments
Open

cmd/go: go clean fails in case of no Go source and enabling Go Modules #31002

lufia opened this issue Mar 22, 2019 · 3 comments
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@lufia
Copy link
Contributor

lufia commented Mar 22, 2019

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

$ go version
go version devel +4906a00cdd Fri Mar 22 09:07:09 2019 +0000 darwin/amd64

Does this issue reproduce with the latest release?

yes.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/lufia/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/lufia"
GOPROXY=""
GORACE=""
GOROOT="/Users/lufia/go"
GOTMPDIR=""
GOTOOLDIR="/Users/lufia/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/lufia/go/src/go.mod"
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/0b/8y9l7z3x1pv4p2c5l9f0y6600000gn/T/go-build395440320=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

If GO111MODULE=on and there is no Go source file in current directory, go clean fails.

$ git clone https://github.com/lufia/go-mod-clean
$ cd go-mod-clean

$ export GO111MODULE=off
$ go clean && echo ok
ok

$ export GO111MODULE=on
$ go clean && echo ok
can't load package: package github.com/lufia/go-mod-clean: unknown import path "github.com/lufia/go-mod-clean": cannot find module providing package github.com/lufia/go-mod-clean

$ go clean ./... && echo ok
ok

What did you expect to see?

I want that go clean is success.

What did you see instead?

I have seen an error message above.

lufia added a commit to mackerelio/go-osstat that referenced this issue Mar 22, 2019
@andybons andybons changed the title go clean fails in case of no Go source and enabling Go Modules cmd/go: go clean fails in case of no Go source and enabling Go Modules Mar 22, 2019
@andybons andybons added this to the Unplanned milestone Mar 22, 2019
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 22, 2019
@andybons
Copy link
Member

@bcmills @jayconrod

@bcmills
Copy link
Contributor

bcmills commented Apr 1, 2019

What did you expect go clean to do in that case? It normally deletes a bunch of legacy files from the current package, but if you're using modules it is unlikely that you have any of those legacy files around.

(Note that both go clean -modcache and go clean -cache now avoid resolving imports, so this issue should only apply to go clean without additional flags.)

@lufia
Copy link
Contributor Author

lufia commented Apr 8, 2019

I hope go clean become same status either GO111MODULE is set to on or not.

I have a Makefile that like described below:

.PHONY: clean
clean:
    go clean

A user that use GOPATH mode above recipe works fine. But now, above Makefile will fail with "cannot find module providing package..." by switching to module-aware mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants