Data Types
Strings and Runes
Go strings store text, and runes represent individual Unicode characters.
Strings and Runes
strings_runes.go
package main
import "fmt"
func main() {
var word =
firstRune := []rune(word)[0]
message := word + " types"
fmt.Println("word=", word)
fmt.Println("first=", string(firstRune))
fmt.Println("message=", message)
}
package main
import "fmt"
func main() {
var word =
firstRune := []rune(word)[0]
message := word + " types"
fmt.Println("word=", word)
fmt.Println("first=", string(firstRune))
fmt.Println("message=", message)
}
package main
import "fmt"
func main() {
var word =
firstRune := []rune(word)[0]
message := word + " types"
fmt.Println("word=", word)
fmt.Println("first=", string(firstRune))
fmt.Println("message=", message)
}
rune
A `rune` is an alias for `int32` and commonly represents one Unicode character.