How to print string in golang?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

Today, we will learn to print or log string variables in go lang, here we will use the fmt.Printf() method to show string type print in output.

Let’s create some string type variable.

package main
import "fmt"

func main() {
  // direct print
	fmt.Printf("Go Hello, World!")
	// string variable pring
	s := "aGuideHub"

In the above code, we have used the Printf() method to print string in the console, here take examples of direct string print and string variable print

Check the output of the above code example.

print, string, golang

Try it yourself

All the best 👍

Follow me on Twitter