fmt.Fprintln() 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.Fprintln() function in Go language formats using the default formats for its operands and writes to w. Here Spaces are always added between the specified 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 Fprintln(w io.Writer, a ...interface{}) (n int, err error) Parameters: This function accepts two parameters which are illustrated below: w io.Writer: This is the specified standard input or output. a ...interface{}: This is containing some strings and constant variables used in the code. 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.Fprintln() function // Including the main package package main // Importing fmt and os import ( "fmt" "os" ) // Calling main func main() { // Declaring some const variables const name, dept = "GeeksforGeeks", "CS" // Calling Fprintln() function which returns // "n" as the number of bytes written and // "err" as any error ancountered n, err := fmt.Fprintln(os.Stdout, name, "is a", dept, "portal.") // Printing the number of bytes written fmt.Print(n, " bytes written.\n") // Printing if any error encountered fmt.Print(err) } Output: GeeksforGeeks is a CS portal. 30 bytes written. <nil> In the above code, it can be seen that in Fprintln() function, no newline (\n) was added still it prints a new line which can be seen from the above-shown output. Example 2: C // Golang program to illustrate the usage of // fmt.Fprintln() function // Including the main package package main // Importing fmt and os import ( "fmt" "os" ) // Calling main func main() { // Declaring some const variables const str1, str2, str3 = "a", "b", "c" // Calling Fprintln() function which returns // "n" as the number of bytes written and // "err" as any error ancountered n, err := fmt.Fprintln(os.Stdout, str1, str2, str3) // Printing the number of bytes written fmt.Print(n, " bytes written.\n") // Printing if any error encountered fmt.Print(err) } Output: a b c 6 bytes written. <nil> In the above code, it can be seen that in Fprintln() function, no space was added still it prints including space which can be seen from the above-shown output. Comment More infoAdvertise with us Next Article fmt.Fprintln() Function in Golang With Examples K Kanchan_Ray Follow Improve Article Tags : Go Language Golang-fmt Similar Reads fmt.Fprint() 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.Fprint() function in Go language formats using the default formats for its operands and writes to w. Here Spaces are added between operands when any string is not used as a par 3 min read fmt.Fprintf() 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.Fprintf() function in Go language formats according to a format specifier and writes to w. Moreover, this function is defined under the fmt package. Here, you need to import th 2 min read fmt.Fscanln() 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.Fscanln() function in Go language scans the specified text, read from r and then stores successive space-separated values into successive arguments. This function stops scannin 3 min read fmt.Fscan() 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.Fscan() function in Go language scans the specified text, read from r, and then stores the successive space-separated values into successive arguments. Here newlines get counte 3 min read fmt.Fscanf() 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.Fscanf() function in Go language scans the specified text, read from r and then stores the successive space-separated values into successive arguments as determined by the form 3 min read fmt.Scan() 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.Scan() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive arg 2 min read filepath.Ext() Function in Golang With Examples In Go language, path package used for paths separated by forwarding slashes, such as the paths in URLs. The filepath.Ext() function in Go language used to return the file name extension used by the specified path. The extension is the suffix beginning at the final dot in the final element of path; i 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.Scanf() 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.Scanf() function in Go language scans the input texts which is given in the standard input, reads from there and stores the successive space-separated values into successive ar 2 min read fmt.Sscan() 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.Sscan() function in Go language scans the specified texts and store the successive space-separated texts into successive arguments. Moreover, this function is defined under the 2 min read Like