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
+19.1k Golang : Display list of time zones with GMT
+15.4k Golang : invalid character ',' looking for beginning of value
+20.7k Golang : Read directory content with os.Open
+10.6k Fix ERROR 1045 (28000): Access denied for user 'root'@'ip-address' (using password: YES)
+14k Golang : Human readable time elapsed format such as 5 days ago
+8.5k Golang : How to check variable or object type during runtime?
+10.2k Golang : Bcrypting password
+6.3k Unix/Linux : Use netstat to find out IP addresses served by your website server
+6.4k PHP : Proper way to get UTF-8 character or string length
+17.1k Golang : Capture stdout of a child process and act according to the result
+4.7k MariaDB/MySQL : Form select statement or search query with Chinese characters
+12.2k Golang : Split strings into command line arguments