Golang print() Function with Examples

Golang | print() Function: Here, we are going to learn about the built-in print() function with its usages, syntax, and examples.
Submitted by IncludeHelp, on October 20, 2021 [Last updated : March 15, 2023]

print() Function

In the Go programming language, the print() 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 print() 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 print(args ...Type)

Parameter(s)

  • args… : One or more parameters to print.

Return Value

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

Example 1

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

package main

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

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

Output

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

Example 2

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

package main

// Main Function
func main() {
	name := "Alex"
	age := 21
	print(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.