Ad space (banner)
๐ŸนGo Lessons
Lesson 2 / 68

Your First Output (fmt.Println)

In this lesson you will learn the basic way to print output in Go with fmt.Println, and get a feel for what kind of language Go is. This is for anyone searching for "Go fmt.Println how to use".

A Go program starts from package main and func main(). fmt.Println prints text. Developed by Google, Go combines a deliberately simple syntax with fast execution, and is widely used for the backends of large web services and for cloud infrastructure tooling.

The sample code declares an executable program with package main, loads the standard library with import "fmt", and prints a string with the single line fmt.Println("Hello, Go!"). The design philosophy of keeping the syntax deliberately simple shows through everywhere.

A common stumbling block for beginners is forgetting package main or the import. Unlike some languages you cannot simply start writing statements; Go requires this scaffolding first.

In real-world development, printing to the screen is the first step in checking behaviour and debugging. Package management and builds are standardised too, which is part of why Go environments are so straightforward to set up.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run Go directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)