Initials is a Go package that generates initials from names.
go get github.com/go-mods/initials
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
}
Defines the length of the initials
initials.GetInitials("John Doe", WithLength(3)) // Output: JDO
Defines the length of the initials to the number of words
initials.GetInitials("John David Dugga", WithWordLength()) // Output: JDD
Set the separator between the initials.
initials.GetInitials("John Doe", WithSeparator(".")) // Output: J.D
If set to true, the initials will be generated with the case of the words.
initials.GetInitials("John doe", WithSensitive()) // Output: Jd
If set to true, the initials will be generated in lowercase.
initials.GetInitials("John Doe", WithLowercase()) // Output: jd
If set to true, the initials will be generated in uppercase.
initials.GetInitials("John Doe", WithUpperCase()) // Output: JD
If set to true, the initials will be generated in camel case.
initials.GetInitials("John Doe", WithLength(3), WithCamelCase()) // Output: JDo