Fast, low-alloc Go slug generator with an elegant Fluent API.
go get -u github.com/ivanbyone/slugigopackage 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:
}Package slugigo provides functionality for generating URL-friendly slugs due to standard RFC-3986. So, default output complies with the following rules:
- Acceptable
ASCIIcharacters:- only lowercase letters:
a-z - numbers:
0-9 - dash:
- - underscore:
_ - dot:
.
- only lowercase letters:
- Default separator:
- - Unacceptable leading and trailing dashes.
You can set custom configuration for use due to your needs. See more in docs.
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
- support
This project is licensed under the terms of the MIT license. See LICENSE file for details.