Strings
suggest changeA string in Go is an immutable sequence of bytes (8-bit byte values).
This is different from languages like Python, C#, Java, or Swift, where strings are sequences of characters.
Zero value of a string type is an empty string.
Basic string usage
var s string // empty string ""
s1 := "string\nliteral\nwith\tescape characters\n"
s2 := `raw string literal
which doesn't recognize escape characters like \n
`
fmt.Printf("sum of strings\n'%s'\n", s+s1+s2)
sum of strings
'string
literal
with escape characters
raw string literal
which doesn't recognize escape characters like \n
'
Learn more about strings.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents