×

Golang Tutorial

Golang Reference

Golang Programs

Golang Practice

Golang Miscellaneous

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 [Last updated : March 15, 2023]

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 »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.