Skip to content

embed, cmd/go: add a way to exclude a file from embedding #42325

@earthboundkid

Description

@earthboundkid

Problem: if you embed a directory, it may embed unwanted files from the directory.

Proposal: Comments with //go:embed-exclude apply a filter of files to exclude from the embed.

Example:

Given a directory with static/a.txt and static/.dot:

//go:embed static
//go:embed-exclude .*
var staticFiles embed.FS

will just embed static/a.txt.

Refs. #42321.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions