slug

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package slug derives URL-safe identifiers from human-readable names.

This is the deterministic half of a larger slug package, vendored so the id::slug builtin keeps working without the language depending on a host. The collision-resolving variants need a datastore to ask "does this candidate already exist?", which a language runtime must not require — id::slug always called Generate with a nil existence check, so only the normalization below was ever reachable from DTL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(name string) string

Generate produces a URL-safe slug from name.

Rules:

  • Lowercase
  • Letters and digits pass through
  • Whitespace, dashes, underscores, slashes and dots collapse to a single "-"
  • Anything else is dropped
  • Leading/trailing dashes trimmed
  • Empty result becomes "untitled"

Types

This section is empty.

Jump to

Keyboard shortcuts

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