-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Description
Currently, go embed only allows for local files to be embedded in the final binary. While I understand that this beneficial for security, reproducibility and running go build in airgapped environments, it also has a major drawback:
Every file embedded into the go binary has to either be checked in with your VCS or be downloaded dynamically before using go build (and other go commands).
Checking every file into your VCS is not feasible for binary blobs of certain sizes as file sizes are often limited and binary blobs are prone to creating huge diffs.
Adding extra required steps before running go build is problematic as well. I like the fact that I don't need special Makefiles and build tools to use go.
My proposal is as follows:
- Allow go embed with a url and a hash
- Can either point to a single file or tar
- Embedded files can be cached and downloaded in advance (very similar to the handling of go modules)
This has the following advantages:
- Fully deterministic by specifying expected hash
- Lightweight (only url and hash are part of the embed directive)
- Cachable using hash
- Optional early download step allows compilation in air-gapped systems