Golang bytes.Title() function example

package bytes

Title returns a copy of of the given input string with all Unicode letters that begin words mapped to their title case.

Golang bytes.Title() function usage example

 package main

 import (
 "bytes"
 "fmt"
 )

 func main() {
 str := []byte("this is a title!")

 title := bytes.Title(str)


 fmt.Println(string(str))
 fmt.Println(string(title))
 }

Output :

this is a title!

This Is A Title!

Reference :

http://golang.org/pkg/bytes/#Title

Advertisement