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
+5.2k Python : Create Whois client or function example
+22k Fix "Failed to start php5-fpm.service: Unit php5-fpm.service is masked."
+23.9k Golang : Use regular expression to validate domain name
+47.8k Golang : Convert int to byte array([]byte)
+24.1k Golang : Upload to S3 with official aws-sdk-go package
+7.4k Android Studio : How to detect camera, activate and capture example
+8.9k Golang : Find network service name from given port and protocol
+41.9k Golang : How do I convert int to uint8?
+9.9k Golang : Sort and reverse sort a slice of integers
+5.6k PHP : Fix Call to undefined function curl_init() error
+18.1k Golang : Convert IPv4 address to decimal number(base 10) or integer
+28.6k Get file path of temporary file in Go