Skip to content
/ slug Public

Package slug generate slug from Unicode string.

License

Notifications You must be signed in to change notification settings

goloop/slug

Repository files navigation

Go Report Card License License Stay with Ukraine

slug

Package slug generate slug from Unicode string, URL-friendly slugify with multiple languages support.

Installation

To install this module use go get as:

$ go get -u github.com/goloop/slug

Quick Start

To use this module import it as: github.com/goloop/slug

Conversion functions

Fast conversion.

Use the Make method to convert a string to slug.

package main

import (
	"fmt"

	"github.com/goloop/slug"
)

func main() {
	// Simple generate slug from the string.
	s := slug.Make("Hello 世界")
	h := "https://example.com/"

	fmt.Printf("%s%s\n", h, s)
	// Output: https://example.com/Hello-Shi-Jie
}

Functions

  • Lower(t string) string

    Lower returns slug in lowercase.

  • Make(t string) string

    Make returns slug from string.

  • Upper(t string) string

    Upper returns slug in uppercase.

  • Version() string

    Version returns the version of the module.

  • *New() *Slug

    New returns pointer to Slug.

Methods of Slug

  • Lang(l string) *Slug

    Lang sets the type of language features to use during slugify.

  • Lower(t string) string

    Lower returns slug in lowercase.

  • Make(t string) string

    Make returns slug from string.

  • Upper(t string) string

    Upper returns slug in uppercase.