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 doesn’t remove the binary whose name is defined in go.mod #41656

Open
hitzhangjie opened this issue Sep 27, 2020 · 5 comments
Open
Milestone

Comments

@hitzhangjie
Copy link

@hitzhangjie hitzhangjie commented Sep 27, 2020

Hi, go clean doesn't remove the built binary, the filename of binary is the same as the module directive in go.mod.

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

$ go version
go version go1.15 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
GO111MODULE="auto"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/zhangjie/Library/Caches/go-build"
GOENV="/Users/zhangjie/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/zhangjie/go/pkg/mod"
GONOPROXY="git.code.oa.com/*"
GONOSUMDB="git.code.oa.com/*"
GOOS="darwin"
GOPATH="/Users/zhangjie/go"
GOPRIVATE="git.code.oa.com/*"
GOPROXY="mirrors.tencent.com,direct"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/zhangjie/gotest/goclean/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/0j/mvtnlhyj5j9cyqqq1b27bgg40000gn/T/go-build498757503=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.15 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.15
uname -v: Darwin Kernel Version 19.6.0: Mon Aug 31 22:12:52 PDT 2020; root:xnu-6153.141.2~1/RELEASE_X86_64
ProductName:	Mac OS X
ProductVersion:	10.15.7
BuildVersion:	19H2
lldb --version: lldb-1200.0.32.1
Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)

What did you do?

file: goclean/main.go
file: goclean/go.mod, it defines the module a.b.c

After run cd goclean; go build, we get a binary goclean/a.b.c, then I run cd goclean; go clean -x, it says only the following list will be removed main main.exe goclean goclean.exe ...test ...test.exe. No a.b.c, a.b.c.exe, a.b.c.test, a.b.c.test.exe is listed.

I want to know if it's a bug, or it is designed like that.

What did you expect to see?

I want to see a.b.c, a.b.c.exe, a.b.c.test and a.b.c.test.exe are cleaned, too.

What did you see instead?

The files, a.b.c, a.b.c.exe, a.b.c.test and a.b.c.test.exe are kept.

@andybons andybons changed the title go clean doens't remove the binary whose name is defined in go.mod cmd/go: go clean doesn’t remove the binary whose name is defined in go.mod Sep 29, 2020
@andybons andybons added this to the Unplanned milestone Sep 29, 2020
@andybons
Copy link
Member

@andybons andybons commented Sep 29, 2020

@jayconrod jayconrod modified the milestones: Unplanned, Backlog Sep 29, 2020
@bcmills
Copy link
Member

@bcmills bcmills commented Sep 29, 2020

$ go version
go version devel +9a7a981a Tue Sep 29 08:21:48 2020 +0000 linux/amd64

$ (cd goclean; go build)

$ ls goclean/
a.b.c  go.mod  main.go

$ (cd goclean; go clean -x)
cd /tmp/tmp.WYzmKl7fkG/goclean
rm -f goclean goclean.exe goclean.test goclean.test.exe main main.exe

-- goclean/go.mod --
module a.b.c

go 1.16
-- goclean/main.go --
package main

func main() {}
@bcmills bcmills added the GoCommand label Sep 29, 2020
@nasjp
Copy link

@nasjp nasjp commented Sep 30, 2020

I'll work on this. OK?

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 15, 2020

Change https://golang.org/cl/262677 mentions this issue: fix(cmd): when module enabled, go clean removes built binary

@hitzhangjie
Copy link
Author

@hitzhangjie hitzhangjie commented Oct 15, 2020

@bcmills @andybons @nasjp

Hi, I create a PR #41999, please take a look :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.