Golang: Convert Value to String
To convert a value to string,
load the the package fmt
, then use the function
fmt.Sprintf(string, v1, v2, etc)
package main import "fmt" func main() { var x = "John" var y = 36 var s = fmt.Sprintf("name is %v, age is %v", x, y) fmt.Println(s == "name is John, age is 36") }
For the input types and output format, see Golang: Printf Verbs
Golang, String
Golang, array and slice
- Golang: Array
- Golang: Slice
- Golang: Slice of Slice
- Golang: Append to Slice
- Golang: Cut Slice (Delete Elements)
- Golang: Copy Slice
- Golang: Clear Slice
- Golang: Nested Slice
- Golang: Slice of Strings to String
- Golang: Iterate Slice
- Golang: Convert Value to String
- Golang: Convert Array to Slice
- Golang: Print Slice, Array