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
+10.1k Golang : Test a slice of integers for odd and even numbers
+11.5k Golang : Change date format to yyyy-mm-dd
+13.9k Golang : How to check if a file is hidden?
+7k Golang : Levenshtein distance example
+36.4k Golang : Convert date or time stamp from string to time.Time type
+16.3k Golang :Trim white spaces from a string
+22.1k Golang : Repeat a character by multiple of x factor
+4.9k Unix/Linux : secure copying between servers with SCP command examples
+9.7k Golang : Detect number of active displays and the display's resolution
+20.2k Golang : Count number of digits from given integer value
+6.2k PHP : Get client IP address
+11.1k Golang : Roll the dice example