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
+20.2k Golang : Reset or rewind io.Reader or io.Writer
+6.8k Golang : Join lines with certain suffix symbol example
+18.8k Golang : How to make function callback or pass value from function as parameter?
+5.9k Golang : Use NLP to get sentences for each paragraph example
+17.9k Golang : Qt image viewer example
+8.5k Golang : How to check if input string is a word?
+7.5k Golang : Gorrila set route name and get the current route name
+19.1k Golang : Display list of time zones with GMT
+6.3k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+11.8k Golang : GTK Input dialog box examples
+12.7k Golang : Add ASCII art to command line application launching process
+6.3k Golang : Calculate US Dollar Index (DXY)