The strings package

The strings standard Go package allows you to manipulate UTF-8 strings in Go and includes many powerful functions. Most of these functions will be illustrated in the useStrings.go source file, which will be presented in five parts. Note that the functions of the strings package that are related to file input and output will be demonstrated in Chapter 8, Telling a UNIX System What to Do.

The first part of useStrings.go follows:

package main 
import ( 
    s "strings" 
var f = fmt.Printf 
There is a difference in the way the strings package is imported. This kind of import statement makes Go create an alias for that package. So, instead of writing strings.FunctionName(), you can now write s.FunctionName(), which ...

Get Mastering Go - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.