Download go eBook


A string is in effect a read-only slice of bytes. In Go a string literal will always contain a valid UTF-8 representation of its content.


  • variableName := "Hello World" // declare a string
  • variableName := `Hello World` // declare a raw literal string
  • variableName := "Hello " + "World" // concatenates strings
  • substring := "Hello World"[0:4] // get a part of the string
  • letter := "Hello World"[6] // get a character of the string
  • fmt.Sprintf("%s", "Hello World") // formats a string

Related Examples


23 Contributors: 3
Monday, July 24, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial:

Download eBook