Go Hello World

Go Hello World: Writing Your First Program

April 3rd, 2026
3539
3:00 Minutes

Learning Golang, but don't know where to start? Golang (Go) is a programming language created at Google, known for its simplicity, efficiency and strong support for concurrent programming. It could be an excellent choice if you are a beginner looking to step into the world of coding.

I have specially designed this Golang tutorial for knowledge seekers like you. It will walk you through writing your very first Go program: the classic 'Hello, World!'. It is the most basic thing you should start your coding practice with.

Introduction to Go

Go is an open-source programming language created by Google in 2009. It is designed to be simple, fast and efficient to make it ideal for beginners and professionals. Go is widely used for building web servers, cloud applications and microservices.

Want to Master Golang Programming Language?

Explore our Golang Tutorial to boost your coding skills and gain hands-on knowledge in Go Programming.

Explore Now
Golang Learning Illustration

Why Start with Hello World in Golang?

The Hello World program is a tradition in programming. It will introduce you to the basic structure of a Go program that includes packages, imports and the main function. It also helps you verify that your Go environment is set up correctly.

Setting Up Your Go Environment

You need to set up your development environment before writing your first Go program. It involves the following steps:

  • Install Go: You need to download and install the Go compiler from the official Go website. It supports Windows, macOS and Linux.
  • Choose a Code Editor: You can use a beginner-friendly editor like Visual Studio Code or GoLand. These tools make coding in Go easy with features like syntax highlighting.
  • Verify Installation: Open your terminal and type go version. It will shop the Go version if the installation is successful.

Related Article: How to install Go programming language?

Writing Your First Go Hello World Program

Let's create a simple Go program that prints 'Hello, World!' on your screen. The steps are:

1. Create a File: Open your code editor and create a new file named hello.go. Go files always end with the .go extension.

2. Add the Package Declaration: Every Go program starts with a package. Use package main for executable programs. This tells the Go compiler that this is a standalone program.

package main

3. Import the fmt Package: The fmt package in Go handles formatted input and output. Import it using:

import "fmt"

4. Write the Main Function: The main function is the entry point of your Go program. Inside it, use fmt.Println to display text.

func main() {

fmt.Println("Hello, World!")

}

5. Save the File: Save your hello.go file in a folder like go-projects.

Your complete Go Hello World program looks like this:

package main

import "fmt"

func main() {

fmt.Println("Hello, World!")

}

Running Your Go Program

Running your Go Hello World program involves opening your terminal and navigating to the folder containing hello.go. Use this command for the same:

go run hello.go

Output:

Hello, World!

You can also use the given command if you want to compile the program into an executable file:

go build hello.go

This will create an executable file (hello on macOS/Linux or hello.exe on Windows) that you can run directly.

Also Read: Golang vs Java

Wrapping-Up

This guide has explained how to set up your Go environment, write a simple program and run it using the Go compiler. Its simplicity makes it perfect for beginners and this basic program lays the foundation for learning more advanced Go concepts. Just keep practicing, keep coding, explore Go tutorials and try building small projects to grow your skills.

FAQs- Go Hello World Program

Q1. What is the purpose of the package main in Go?

The package main declaration tells the Go compiler that the program is executable. It must include a main function that is the entry point of the program.

Q2. Why do we use the fmt package?

The fmt package provides functions for formatting and printing text like fmt.Println. It is used to display output in the terminal.

Q3. How do I run a Go program?

Save your program with a .go extension like hello.go, open your terminal, navigate to the file's directory and run go run hello.go.

Q4. Is Go easy for freshers to learn?

Yes, Go has simple syntax and is easier to understand compared to many other programming languages.

Course Schedule

Course NameBatch TypeDetails
Golang Training
Every WeekdayView Details
Golang Training
Every WeekendView Details
Drop Us a Query
Fields marked * are mandatory

Programming Certification Courses

×

Your Shopping Cart


Your shopping cart is empty.