Help us shape the future of Go! Take the 2026 Go Developer Survey

slugigo

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 1 Imported by: 0

README

slugigo

Fast, low-alloc Go slug generator with an elegant Fluent API.

GH Release Slugigo CI Status Slugigo License Go documentation

Quick Start

Installation

go get -u github.com/ivanbyone/slugigo

Usage example

package main

import (
    "fmt"
    "github.com/ivanbyone/slugigo"
)

func main() {
    // Basic usage (ASCII, default compliance RFC-3986)
    slug := slugigo.Slug("Hello, Slugigo!").Build()
    fmt.Println(slug)
    // Output: hello-slugigo

    // Advanced custom configuration
    custom := slugigo.Slug("Hello, Fluent Slugigo").
        NoLowercase().
        MaxLength(12).
        Separator("_").
        SaveLeadingAndTrailingDash().
        Build()
    fmt.Println(custom)
    // Output: 
}

Concept

Package slugigo provides functionality for generating URL-friendly slugs due to standard RFC-3986. So, default output complies with the following rules:

  • Acceptable ASCII characters:
    • only lowercase letters: a-z
    • numbers: 0-9
    • dash: -
    • underscore: _
    • dot: .
  • Default separator: -
  • Unacceptable leading and trailing dashes.

You can set custom configuration for use due to your needs. See more in docs.

Roadmap

v0.2.0

  • Improve library code style
  • Add Go benchmarks
  • Compile comprehensive documentation
  • Key feature: custom replacements with Fluent style

Stable release

  • Major: Multiple languages transliteration support
  • Minor:
    • support Prefix() & Suffix()
    • generating dates for slug (UNIX, Datetime)
    • emoji replacements

License

This project is licensed under the terms of the MIT license. See LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slugigo

type Slugigo struct {
	// contains filtered or unexported fields
}

Slugigo

func Slug

func Slug(text string) Slugigo

Slug returns a new Slugigo instance initialized with the provided string.

It provides a Fluent API for configuring the slug generator through method chaining. Use Build() to generate the final slug after setting desired options.

func (Slugigo) Build

func (s Slugigo) Build() string

Build

func (Slugigo) MaxLength

func (s Slugigo) MaxLength(length int) Slugigo

MaxLength

func (Slugigo) NoLowercase

func (s Slugigo) NoLowercase() Slugigo

NoLowercase

func (Slugigo) SaveLeadingAndTrailingDash

func (s Slugigo) SaveLeadingAndTrailingDash() Slugigo

func (Slugigo) Separator

func (s Slugigo) Separator(sep string) Slugigo

Separator

Jump to

Keyboard shortcuts

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