ADVERTISEMENT
ADVERTISEMENT

Golang println() Function with Examples

Golang | println() Function: Here, we are going to learn about the built-in println() function with its usages, syntax, and examples.
Submitted by IncludeHelp, on October 20, 2021

println() Function

In the Go programming language, the println() is a built-in function that is used to format the given arguments in an implementation-specific way and writes the result to standard error. The whitespaces are always added between arguments and a newline is appended at the end of the line. The println() function is useful for bootstrapping and debugging purposes; it is not guaranteed to stay in the language.

It accepts one or more parameters (args ...Type) and returns nothing.

Syntax:

func println(args ...Type)

Parameter(s):

  • args… : One or more parameters to print.

Return Value:

The return type of the println() function is none.

Example 1:

// Golang program to demonstrate the
// example of println() function

package main

// Main Function
func main() {
	var i, j string = "Hello", "World"

	println("This is an example of 'print()'...\n")
	println(i)
	println(j)
}

Output:

This is an example of 'print()'...

Hello
World

Example 2:

// Golang program to demonstrate the
// example of println() function

package main

// Main Function
func main() {
	name := "Alex"
	age := 21
	println(name, " age is ", age)
}

Output:

Alex  age is  21

Golang builtin Package »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.