Golang fmt.Sprintf() function example
package fmt
Sprintf formats according to a format specifier and returns the resulting string.
Golang fmt.Sprintf() function usage example
package main
import "fmt"
func main() {
concatenated := fmt.Sprintf("a ", "string")
fmt.Println(concatenated) // will produce a %!(EXTRA string=string)
concatenated = fmt.Sprintf("a %s", "string")
fmt.Println(concatenated)
}
Output :
a %!(EXTRA string=string)
a string
Reference :
Advertisement
Something interesting
Tutorials
+8.3k Golang: Prevent over writing file with md5 hash
+18.5k Golang : Write file with io.WriteString
+9.9k Golang : Turn string or text file into slice example
+12.9k Python : Convert IPv6 address to decimal and back to IPv6
+34.1k Golang : Create x509 certificate, private and public keys
+16k Golang : Generate universally unique identifier(UUID) example
+16.4k Golang : Convert slice to array
+7.8k Golang : Load DSA public key from file example
+4.7k Chrome : How to block socketloop.com links in Google SERP?
+17.6k Golang : Upload/Receive file progress indicator
+11.6k Golang : Surveillance with web camera and OpenCV
+23.1k Golang : Randomly pick an item from a slice/array example