Skip to content

go-mods/initials

Repository files navigation

Generate initials from names

GoDoc Go Report Card License

Initials is a Go package that generates initials from names.

Installation

go get github.com/go-mods/initials

Usage

package main

import (
    "fmt"
    "github.com/go-mods/initials"
)

func main() {
    fmt.Println(initials.GetInitials("John Doe"))                                   // Output: JD
    fmt.Println(initials.GetInitials("John Doe", WithLength(3), WithCamelCase()))   // Output: JDo
    fmt.Println(initials.GetInitials("John"))                                       // Output: JO  
    fmt.Println(initials.GetInitials("John"), WithCamelCase())                      // Output: Jo
}

Options

WithLength (Default: 2)

Defines the length of the initials

initials.GetInitials("John Doe", WithLength(3)) // Output: JDO

WithWordLength

Defines the length of the initials to the number of words

initials.GetInitials("John David Dugga", WithWordLength()) // Output: JDD

WithSeparator (default: "")

Set the separator between the initials.

initials.GetInitials("John Doe", WithSeparator(".")) // Output: J.D

WithSensitive (default: false)

If set to true, the initials will be generated with the case of the words.

initials.GetInitials("John doe", WithSensitive()) // Output: Jd

WithLowercase (default: false)

If set to true, the initials will be generated in lowercase.

initials.GetInitials("John Doe", WithLowercase()) // Output: jd

WithUpperCase (default: true)

If set to true, the initials will be generated in uppercase.

initials.GetInitials("John Doe", WithUpperCase()) // Output: JD

WithCamelCase (default: false)

If set to true, the initials will be generated in camel case.

initials.GetInitials("John Doe", WithLength(3), WithCamelCase()) // Output: JDo

About

generates initials from names

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages