Documentation
¶
Overview ¶
Package module parses a git remote URL into a Go module path and the name variants derived from it: the repository name, a Go identifier, and an environment-variable prefix.
It is pure string logic with no I/O — a reusable leaf library for any caller that needs to reason about a project's identity from its remote.
Index ¶
Constants ¶
const ErrInvalidRemote errs.Const = "invalid remote"
ErrInvalidRemote indicates a git remote that cannot be parsed into a module path.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnvPrefix ¶
type EnvPrefix string
EnvPrefix is a Name reduced to an environment-variable prefix, e.g. "TEMPLATE_CLI".
type Identifier ¶
type Identifier string
Identifier is a Name reduced to a valid Go identifier, e.g. "templatecli".
type Name ¶
type Name string
Name is a project's short name — the last segment of the module path, e.g. "template.cli".
func (Name) EnvPrefix ¶
EnvPrefix reduces the name to an environment-variable prefix by uppercasing it and mapping every non-alphanumeric character to an underscore.
func (Name) Identifier ¶
func (n Name) Identifier() Identifier
Identifier reduces the name to a valid lowercase Go identifier by dropping every character that is not a lowercase letter or digit.
type Path ¶
type Path string
Path is a Go module path, e.g. "github.com/gomatic/template.cli".
func Parse ¶
Parse turns a git remote URL into a Go module path, accepting both the scp-like SSH form (git@host:org/repo.git) and URL forms (https://host/org/repo.git, ssh://git@host/org/repo). It strips the scheme, any userinfo, and a trailing ".git", and reports ErrInvalidRemote when the result is not a host/org/repo path.