Essential Go Basic types  Edit on GitHub      File Issue

Strings

String in Go is an immutable sequence of bytes (8-bit byte values)

This is different than languages like Python, C#, Java or Swift where strings are Unicode.

Zero value of a string type is an empty string.

Basic string usage:

var s string // empty string ""
s1 := "string\nliteral\nwith\tescape characters"
s2 := `raw string literal
which doesnt't recgonize escape characters like \n
`
fmt.Printf("sum of strings: '%s'\n", s+s1+s2)
sum of strings: 'string
literal
with	escape charactersraw string literal
	which doesnt't recgonize escape characters like \n
	'

Learn more about strings.

  ↑ ↓ to navigate     ↵ to select     Esc to close