Using
'fmt.Sprintf', you can format a string without printing.
Signature
func
Sprintf(format string, a ...interface{}) string
Example
str := fmt.Sprintf("Good
Morning, I am %s, I am %d years old ", "Krishna", 30)
App.go
package main import ( "fmt" ) func main() { str := fmt.Sprintf("Good Morning, I am %s, I am %d years old ", "Krishna", 30) fmt.Println(str) }
Output
Good Morning,
I am Krishna, I am 30 years old
No comments:
Post a Comment