Golang fmt.Sprintln() function example
package fmt
Sprintln formats using the default formats for its operands and returns the resulting string. Spaces are always added between operands and a newline is appended.
Golang fmt.Sprintln() function usage example
package main
import "fmt"
func main() {
chinese := "你好"
english := "Hello"
malay := "apa khabar"
fmt.Println("Sprint has NO new line :")
fmt.Print(fmt.Sprint(chinese + " " + english + " " + malay)) // no newline
fmt.Println("SprintLN has NEW line :")
fmt.Print(fmt.Sprintln(chinese + " " + english + " " + malay)) // add a newline
fmt.Print(fmt.Sprintln(chinese + " " + english + " " + malay)) // add a newline
}
Output :
Sprint has NO new line :
你好 Hello apa khabarSprintLN has NEW line :
你好 Hello apa khabar
你好 Hello apa khabar
Reference :
http://golang.org/pkg/fmt/#Sprintln
Advertisement
Something interesting
Tutorials
+13.8k Golang : Convert spaces to tabs and back to spaces example
+30.5k Get client IP Address in Go
+17k Golang : Fix cannot convert buffer (type *bytes.Buffer) to type string error
+13.6k Golang : Query string with space symbol %20 in between
+6.8k Unix/Linux : How to fix CentOS yum duplicate glibc or device-mapper-libs dependency error?
+5k Python : Convert(cast) bytes to string example
+5.7k Unix/Linux/MacOSx : Get local IP address
+12.9k Golang : Convert IPv4 address to packed 32-bit binary format
+5.4k Golang : Qt update UI elements with core.QCoreApplication_ProcessEvents
+8.9k Golang : GMail API create and send draft with simple upload attachment example
+20.2k Golang : How to get struct tag and use field name to retrieve data?
+12k Golang : Convert a rune to unicode style string \u