How to precompile Golang standard library?

WBOY
Release: 2024-02-05 21:57:03
forward
1172 people have browsed it

How to precompile Golang standard library?

Question content

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.


Correct answer


By default, the standard library is not precompiled to save distribution size.

Set environment variables GODEBUG=installgoroot=all to change the default behavior.

Checkhttps://www.php.cn/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!

Related labels:
source:stackoverflow.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template