Skip to content

proposal: cmd/go: clean should honor the -o flag as a build parameter so it can remove the final built artifacts #77221

Description

@norman-abramovitz

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

$ go version
go version go1.25.6 darwin/arm64

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
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/norm/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/norm/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/jx/038678ld7hx14_ys0r2nh_tm0000gn/T/go-build3841041466=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/Users/norm/Projects/CloudFoundry/ocf-scheduler/ocf-scheduler/go.mod'
GOMODCACHE='/Users/norm/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/norm/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.25.6/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/norm/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.25.6/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.25.6'
GOWORK=''
PKG_CONFIG='pkg-config'
uname -v: Darwin Kernel Version 25.2.0: Tue Nov 18 21:07:05 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T6020
ProductName:		macOS
ProductVersion:		26.2
BuildVersion:		25C56
lldb --version: lldb-1703.0.236.21
Apple Swift version 6.2.3 (swiftlang-6.2.3.3.21 clang-1700.6.3.2)

What did you do?

The following command builds multiple main packages and places their final executables in the directory specified by the -o parameter.
go build -o . ./...

I would have expected the following command to remove the final executables from the directory specified by -o.
go clean -o . ./...

Multiple main packages were located in subdirectories structured as follows:
cmd/app1/main.go
cmd/app2/main.go
cmd/appn/main.go

What did you expect to see?

It was expected the final executables would be removed from where the -o parameter was set to.

What did you see instead?

go clean -o . ./...
flag provided but not defined: -o

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestIssues asking for a new feature that does not need a proposal.GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ProposalToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions