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"
	fmt.Printf(s)
}

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 👍

Premium Content

You can get all the below premium content directly in your mail when you subscribe us

Books

Portfolio Template

View | Get Source Code

Cheat Sheets

Cheat Sheets Books are basically Important useful notes which we use in our day-to-day life.

I'm working on some more Cheat Sheets book on Jquery, TypeScript, React js and for other languages. I will send it once it's completed.

Related Posts