module

package module
v0.3.27 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 3 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

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

View Source
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

func (n Name) EnvPrefix() 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

func Parse(remote Remote) (Path, error)

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.

func (Path) Repo

func (p Path) Repo() Name

Repo returns the last segment of the module path — the repository name.

type Remote

type Remote string

Remote is a git remote URL, e.g. "git@github.com:gomatic/template.cli.git".

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址