Go 1.27 reference · 7 entries

Go Formatting, Strings and Text

Print and format with fmt, split, search and build strings, convert numbers with strconv, and match regular expressions.

NameDescriptionSince
fmt.Printf Print formatted output using verbs like %v, %+v, %d, %s, %q, %.2f and %T, with width and alignment options.
fmt.Errorf Create an error with a formatted message; the %w verb wraps another error so errors.Is and errors.As can find it.
strings.Split and strings.Join Split a string into a slice around a separator, and join a slice of strings with a separator.
strings.Contains, HasPrefix and Index Check whether a string contains, starts or ends with a substring, and find its position.
strings.Builder Build a string efficiently piece by piece without creating a new string for every concatenation.
strconv.Atoi, Itoa and ParseFloat Convert between strings and numbers or booleans, with errors for invalid input.
regexp.MustCompile Compile a regular expression (RE2 syntax, linear time) and use it to match, find and replace text.

Was this page helpful?