Skip to content

proposal: embed: Allow remote resources to be embedded #56401

@malt3

Description

@malt3

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions