Notes & TILs
Search…
Where are my build files when I use `go run`
9 June 2020_
By default, 'go run' runs the compiled binary directly. The binaries are stored in a temp work folder, to see where they are stored use the -work flag. This directory path is stored in the GOCACHE env variable. Use go env to check its value
1
$ go env GOCACHE
2
/Users/username/Library/Caches/go-build
Copied!

Demo

1
go run --work fizzbuzz.go
Copied!
Sample Output
1
WORK=/tmp/go-build645222420
2
[1 2 Fizz]
Copied!
When you run this go will not delete the temporary build when exiting. The default directory may vary with your system & GOPATH.
Last modified 1mo ago
Copy link
Contents
Demo