Skip to content

cmd/go: go clean -testcache fails if GOCACHE directory does not exist #29100

@mxk

Description

@mxk

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

$ go version
go version go1.11.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes. It may be affected by #26794 for 1.12, but looking at the code, I think the bug is still there.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN="/Users/mxk/bin"
GOCACHE="/Users/mxk/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/mxk/.go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11.2/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/xg/rnkm_hgs5298dsx212f1_y2c0000gp/T/go-build752263492=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

cachedir=$(go env GOCACHE)
mv $cachedir $cachedir.old
go clean -testcache
mv $cachedir.old $cachedir

What did you expect to see?

No errors and an exit code of 0.

What did you see instead?

go clean -testcache: open /Users/mxk/Library/Caches/go-build/testexpire.txt: no such file or directory
exit code 1

The -testcache flag assumes that the cache directory exists. When that's not the case, there is nothing to clear, so the command should exit normally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeGoCommandcmd/goNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions