https://github.com/fonini/go-capitalize
go-capitalize is a Go library for capitalizing proper names. ðŸ”
https://github.com/fonini/go-capitalize
capitalization go-modules golang-library hacktoberfest
Last synced: about 1 year ago
JSON representation
go-capitalize is a Go library for capitalizing proper names. ðŸ”
- Host: GitHub
- URL: https://github.com/fonini/go-capitalize
- Owner: fonini
- License: mit
- Created: 2020-11-04T11:06:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2025-02-21T23:16:31.000Z (over 1 year ago)
- Last Synced: 2025-04-09T17:15:00.357Z (about 1 year ago)
- Topics: capitalization, go-modules, golang-library, hacktoberfest
- Language: Go
- Homepage:
- Size: 31.3 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# go-capitalize #
[](https://pkg.go.dev/github.com/fonini/go-capitalize/capitalize)
[](https://github.com/fonini/go-capitalize/actions?query=workflow%3Atests)
[](https://codecov.io/gh/fonini/go-capitalize)
[](https://goreportcard.com/report/github.com/fonini/go-capitalize)
go-capitalize is a Go library for capitalizing proper names.
## Usage ##
```go
import "github.com/fonini/go-capitalize/capitalize"
```
The capitalize package exports a single `Capitalize()` function. A simple example:
```go
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](https://twitter.com/g0nc1n) for the original PHP code.