fmt.print() 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.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 used as a parameter. 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 Print(a ...interface{}) (n int, err error) Here, "a ...interface{}" containing some strings and declared 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.print() 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 print() function fmt.Print(name, " is a ", dept, " portal.\n") // It is conventional not to worry about any // error returned by Print. } Output: GeeksforGeeks is a CS portal. Example 2: C // Golang program to illustrate the usage of // fmt.print() function // Including the main package package main // Importing fmt import ( "fmt" ) // Calling main func main() { // Declaring some const variables const str1, str2, str3 = "a", "b", "c" // Calling print() function fmt.Print(str1, str2, str3, "\n") // It is conventional not to worry about any // error returned by Print. } Output: abc In the above code, the constant variables used are strings hence spaces are not added in between two strings shown above in the output. Example 3: C // Golang program to illustrate the usage of // fmt.print() function // Including the main package package main // Importing fmt import ( "fmt" ) // Calling main func main() { // Declaring some const variables const num1, num2, num3 = 5, 15, 15 // Calling print() function fmt.Print(num1, num2, num3, "\n") // It is conventional not to worry about any // error returned by Print. } Output: 5 15 15 In the above code, the constant variables used are numbers hence spaces are added in between two numbers shown above in the output. Comment More infoAdvertise with us Next Article fmt.print() Function in Golang With Examples K Kanchan_Ray Follow Improve Article Tags : Go Language Golang-fmt Similar Reads 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.Println() 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.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 2 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 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 Like