fmt.Println() Function in Golang With Examples Last Updated : 05 May, 2020 Comments Improve Suggest changes Like Article Like Report In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Println() function in Go language formats using the default formats for its operands and writes to standard output. Here spaces are always added between operands and a newline is appended at the end. Moreover, this function is defined under the fmt package. Here, you need to import the "fmt" package in order to use these functions. Syntax: func Println(a ...interface{}) (n int, err error) Here, "a ...interface{}" contains some strings including specified constant variables. Return Value: It returns the number of bytes written and any write error encountered. Example 1: C // Golang program to illustrate the usage of // fmt.Println() function // Including the main package package main // Importing fmt import ( "fmt" ) // Calling main func main() { // Declaring some const variables const name, dept = "GeeksforGeeks", "CS" // Calling Println() function fmt.Println(name, "is", "a", dept, "Portal.") // It is conventional not to worry about any // error returned by Println. } Output: GeeksforGeeks is a CS Portal. In the above code, it can be seen that the function Println() is not containing any space within the specified strings still in output is print space that can be seen from the above output. Example 2: C // Golang program to illustrate the usage of // fmt.Println() function // Including the main package package main // Importing fmt import ( "fmt" ) // Calling main func main() { // Declaring some const variables const num1, num2, num3, num4 = 5, 10, 15, 50 // Calling Println() function fmt.Println(num1, "+", num2, "=", num3) fmt.Println(num1, "*", num2, "=", num4) // It is conventional not to worry about any // error returned by Println. } Output: 5 + 10 = 15 5 * 10 = 50 In the above code, it can be seen that the function Println() is not using any newline (\n) still in the output it prints new line that can be seen from above shown output. Comment More infoAdvertise with us Next Article fmt.Println() Function in Golang With Examples K Kanchan_Ray Follow Improve Article Tags : Go Language Golang-fmt Similar Reads fmt.Sprintln() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Sprintln() function in Go language formats using the default formats for its operands and returns the resulting string. Here spaces are always added between operands and a newl 2 min read fmt.print() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.print() function in Go language formats using the default formats for its operands and writes to standard output. Here Spaces are added between operands when any string is not 2 min read fmt.Printf() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Printf() function in Go language formats according to a format specifier and writes to standard output. Moreover, this function is defined under the fmt package. Here, you need 3 min read fmt.Sprint() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Sprint() function in Go language formats using the default formats for its operands and returns the resulting string. Here spaces are added between operands when any string is 3 min read fmt.Sprintf() Function in Golang With Examples In Go language, fmt package implements formatted I/O with functions analogous to C's printf() and scanf() function. The fmt.Sprintf() function in Go language formats according to a format specifier and returns the resulting string. Moreover, this function is defined under the fmt package. Here, you 2 min read Like