Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 1.51 KB

README.md

File metadata and controls

42 lines (28 loc) · 1.51 KB

go-capitalize

GoDoc Test Status codecov Go Report Card

go-capitalize is a Go library for capitalizing proper names.

Usage

import "github.com/fonini/go-capitalize/capitalize"

The capitalize package exports a single Capitalize() function. A simple example:

name, _ := capitalize.Capitalize("jonnas fonini")
fmt.Println(name) // will output: "Jonnas Fonini"

name, _ = capitalize.Capitalize("ruA DA praça xv")
fmt.Println(name) // will output: "Rua da Praça XV"

// With additional exceptions
options := capitalize.Options{
    Exceptions: []string{"of"},
    Surnames: []string{"McElroy"},
}

name, _ = capitalize.Capitalize("gørvel fadersdotter of giske", options)
fmt.Println(name) // will output: "Gørvel Fadersdotter of Giske"

name, _ = capitalize.Capitalize("john mcelroy", options)
fmt.Println(name) // will output: "John McElroy"

Thanks

Thanks to Fausto Gonçalves Cintra for the original PHP code.