Go Language Tutorial
In Go programming, string data type and also predefined string manipulation operations are available.
var str string
var str string str = "codingpointer.com!"
Another way
str := "codingpointer.com!"
any one of the way can be used to define string variables.
fmt.Sprintf("%s", &str)
Sprintf function in fmt package is used to get the user input and need to use %s with Sprintf funtion to get string user input in Go programming.
Simple Go program declares string data type variable, assigning value and prints the string variable data.
package main import "fmt" func main() { var str string str = "codingpointer.com!" fmt.Println(str) }Output:
$ go build print-string.go $ ./print-string codingpointer.com!
In Go programming, built in functions and operators are available to manipulate strings. strings and strconv packages are used for string manipulations.
strconv.ParseInt, strconv.ParseFloat, strings.Split, strings.ToUpper, strings.ToLower are some of the functions used for string manipulations in Go.
« Previous Next »