I tried to use the Go compiler in a sandbox environment, but without a shared build cache directory, the compilation speed is very slow because every The referenced standard library will be compiled every time. I want to avoid sharing the build cache because I want to keep compilation isolated. I raised this issue with the Golang team at https://github.com/golang/go/issues/64721 and they suggested precompiling and distributing the standard library, but I don't know how to do it.
I tried GOBIN=/tmp/go-std-lib go build std
but it doesn't work.
By default, the standard library is not precompiled to save distribution size.
Set environment variables GODEBUG=installgoroot=all
to change the default behavior.
Check//m.sbmmt.com/link/3d8c34ed1d91e42e80ccda0c6dd0b027 for more details.
The above is the detailed content of How to precompile Golang standard library?. For more information, please follow other related articles on the PHP Chinese website!