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
+21.5k Golang : How to read float value from standard input ?
+14.3k Golang : Simple word wrap or line breaking example
+7.9k Javascript : Put image into Chrome browser's console
+8.3k Golang : Emulate NumPy way of creating matrix example
+22.7k Golang : Set and Get HTTP request headers example
+5.4k Gogland : Datasource explorer
+5.7k Get website traffic ranking with Similar Web or Alexa
+29.9k Golang : Get and Set User-Agent examples
+39.6k Golang : Remove dashes(or any character) from string
+7.7k Golang : How to execute code at certain day, hour and minute?
+5.7k Linux/Unix/PHP : Restart PHP-FPM
+5.1k Golang : Display packages names during compilation