Skip to content

embed: document that paths must satisfy fs.ValidPath(name) #44012

@gazerro

Description

@gazerro

The embed documentation does not says that paths must also satisfy fs.ValidPath(name). It only says

The path separator is a forward slash, even on Windows systems.

and

Patterns must not contain ‘.’ or ‘..’ path elements nor begin with a leading slash.

For example in this case:

//go:embed data/

the compiler fails with the error:

pattern data/: invalid pattern syntax

but "data/" is valid as pattern, it is not valid for the fs.ValidPath function.

I think that the sentence

A //go:embed directive above a variable declaration specifies which files to embed, using one or more path.Match patterns.

should mention fs.ValidPath and consequently "The path separator is a forward slash, even on Windows systems" and "Patterns must not contain ‘.’ or ‘..’ path elements nor begin with a leading slash" can be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.release-blocker

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions