Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Hello World | Getting Started
Introduction to GoLang

Hello WorldHello World

As a first step, we will start with the conventional "Hello World" program so that you can get acquainted with the syntax and basic structure of a Go program. Following is the code to output "Hello World" using Go:

go

index.go

Here main() represents a function, indicated by the keyword func before it.

Note

Keywords, also known as reserved words, are special words with predefined meanings that serve specific purposes in the language. Most of the keywords, like func itself, will be explained in detail where relevant. The keywords we will learn in this section are var and const.

func main()

Everything enclosed within the following curly braces {} is executed when the program runs. In this case, the fmt.Println statement is the first thing to execute.

go

index.go

fmt.Println prints whatever is inside the double quotes (") to the console, which in this case is "Hello World". Textual data is always enclosed in double quotation marks (").

Note

Commas , can be used in the fmt.Println statement to output multiple pieces of numerical or textual data. Spaces are automatically added between the values.

go

index.go

Detailed explanations of the remaining code components will be provided in later chapters as they become relevant.

Everything was clear?

Section 1. Chapter 2
course content

Course Content

Introduction to GoLang

Hello WorldHello World

As a first step, we will start with the conventional "Hello World" program so that you can get acquainted with the syntax and basic structure of a Go program. Following is the code to output "Hello World" using Go:

go

index.go

Here main() represents a function, indicated by the keyword func before it.

Note

Keywords, also known as reserved words, are special words with predefined meanings that serve specific purposes in the language. Most of the keywords, like func itself, will be explained in detail where relevant. The keywords we will learn in this section are var and const.

func main()

Everything enclosed within the following curly braces {} is executed when the program runs. In this case, the fmt.Println statement is the first thing to execute.

go

index.go

fmt.Println prints whatever is inside the double quotes (") to the console, which in this case is "Hello World". Textual data is always enclosed in double quotation marks (").

Note

Commas , can be used in the fmt.Println statement to output multiple pieces of numerical or textual data. Spaces are automatically added between the values.

go

index.go

Detailed explanations of the remaining code components will be provided in later chapters as they become relevant.

Everything was clear?

Section 1. Chapter 2
some-alt