Techieindoor

Go ā€“ Difference between Print() and Println() function in go

We are going to learn about difference between Print() and Println() function in go. We will also see how to use and import Print() and Println().

Difference between Print() and Println() methods:

Print() and Println() methods are come under fmt package in go.

Syntax:

Print():

func Print(a ...interface{}) (n int, err error)


Println():

func Println(a ...interface{}) (n int, err error)

Print() function example:

package main

import (

  "fmt"

)

func main() {

  fmt.Print("Hello ")

  fmt.Print("Hii")

}

Output:

Hello Hii

Println() function with example:

package main

import (

  "fmt"

)

func main() {

  fmt.Println("Hello ")

  fmt.Println("Hii")

}

Output:

Hello

Hii

To learn more about golang, You can refer given below link:

https://www.techieindoor.com/go-lang-tutorial/

References:

 https://golang.org/doc/
https://golang.org/pkg/
https://golang.org/pkg/fmt/
https://golang.org/pkg/fmt/#Println
Exit mobile version