Go Programming Language (Introduction)
Last Updated :
04 Sep, 2025
Go, often referred to as Golang, is an open-source programming language developed by Google in 2007 and officially released in 2009. It was designed with the goal of combining performance and security of a low-level language like C with the simplicity and productivity of modern languages like Python.
- Clean, minimal syntax; beginner-friendly yet powerful for large systems.
- Concurrency with Goroutines and Channels for running multiple tasks.
- Cross-platform: compile once, run on Windows, Linux, or macOS.
- Statically typed: catches errors at compile time.
- Automatic memory management (garbage collection).
- Latest release: Go 1.25 (August 2025), after Go 1.24 (February 2025).
If you're looking to learn Go programming,Boot.dev's Full Go Course is the perfect starting point. With step-by-step lessons, hands-on challenges, and expert guidance, you'll build a solid foundation in Go. Dive into real-world projects and gain the skills to become a proficient Go developer. Enroll now and master Go at your own pace!.
Hello World! Program in Golang
To run a Go program you need a Go compiler. In Go compiler, first you create a program and save your program with extension .go, for example, first.go.
Go
// First Go program
package main
import "fmt"
// Main function
func main() {
fmt.Println("Hello, geeksforgeeks")
}
Output:
Hello, geeksforgeeks
Explanation of the syntax of Go program:
- Line 1: It contains the package main of the program, which have overall content of the program.It is the initial point to run the program, So it is compulsory to write.
- Line 2: It contains an import statement "fmt". In Go (Golang), the import statement is used to include external packages that provide additional functionality beyond the built-in language features. In this case, "fmt" is a package that provides functions for formatting input and output.
- Line 3: main function, it is beginning of execution of program.
- Line 4: fmt.Println() is a standard library function to print something as a output on screen.In this, fmt package has transmitted Println method which is used to display the output.
- Comment: Comments are used for explaining code and are used in similar manner as in Java or C or C++. Compilers ignore the comment entries and does not execute them. Comments can be of single line or multiple lines.
Single Line Comment:
Syntax:
// single line comment
Multi-line Comment:
Syntax:
/* multiline comment */
Now we run this first.go file in the go compiler using the following command, i.e:
go run first.go
For more details about the different terms used in this program, you can visit Hello World in Golang
Beginning with Go programming:
There are various online IDEs such as The Go Playground, repl.it, etc. which can be used to run Go programs without installing. For installing Go in own PCs or Laptop we need of following two software: Text editor and Compiler.
Note: Extension of source code file of go language must be .go
Identifiers and Keywords
Identifiers are the user-defined name of the program components. In Go Programming language, an identifier can be a variable name, function name, constant, statement labels, package name, or types.
Example:
// Valid identifiers:
_geeks23
geeks
gek23sd
Geeks
geeKs
geeks_geeks
// Invalid identifiers:
212geeks
if
default
Keywords or Reserved words are the words in a language that are used for some internal process or represent some predefined actions. These words are therefore not allowed to use as an identifier. Doing this will result in a compile-time error. There are total 25 keywords present in the Go language as follows:
Example:
Go
// Go program to illustrate
// the use of keywords
// Here package keyword is used to
// include the main package
// in the program
package main
// import keyword is used to
// import "fmt" in your package
import "fmt"
// func is used to
// create function
func main() {
// Here, var keyword is used
// to create variables
// Pname, Lname, and Cname
// are the valid identifiers
var Pname = "GeeksforGeeks"
var Lname = "Go Language"
var Cname = "Keywords"
fmt.Printf("Portal name: %s", Pname)
fmt.Printf("\nLanguage name: %s", Lname)
fmt.Printf("\nChapter name: %s", Cname)
}
Output:
Portal name: GeeksforGeeks
Language name: Go Language
Chapter name: Keywords
Data Types
Data types specify the type of data that a valid Go variable can hold. In Go language, the type is divided into four categories which are as follows:
- Basic type: Numbers, strings, and booleans come under this category.
- Aggregate type: Array and structs come under this category.
- Reference type: Pointers, slices, maps, functions, and channels come under this category.
- Interface type: Interfaces in Go define a set of method signatures that a type must implement. They allow you to write flexible and reusable code by focusing on behavior rather than specific implementation.
Here, we will discuss Basic Data Types in the Go language. The Basic Data Types are further categorized into three subcategories which are:
- Numbers
- Booleans
- Strings
Numbers: In Go language, numbers are divided into three sub-categories that are:
- Integers: In Go language, both signed and unsigned integers are available in four different sizes as shown in the below table. The signed int is represented by int and the unsigned integer is represented by unit.
Floating-Point Numbers: In Go language, floating-point numbers are divided into two categories as shown in the below table:
Complex Numbers: The complex numbers are divided into two parts are shown in the below table. float32 and float64 are also part of these complex numbers. The in-built function creates a complex number from its imaginary and real part and in-built imaginary and real function extract those parts.
Variable names must begin with a letter or an underscore(_). And the names may contain the letters ‘a-z’ or ’A-Z’ or digits 0-9 as well as the character ‘_’.
Geeks, geeks, _geeks23 // valid variable
123Geeks, 23geeks // invalid variable
- A variable name should not start with a digit.
234geeks // illegal variable
- The name of the variable is case sensitive.
geeks and Geeks are two different variables
- Keywords is not allowed to use as a variable name.
- There is no limit on the length of the name of the variable, but it is advisable to use an optimum length of 4 – 15 letters only.
Conditional Structures
if : It is used to decide whether a certain statement or block of statements will be executed or not i.e if a certain condition is true then a block of statement is executed otherwise not.
Syntax:
if(condition) {
// Statements to execute if
// condition is true
}
Flow Chart:
if-else : if we want to do something else if the condition is false. Here comes the else statement. We can use the else statement with if statement to execute a block of code when the condition is false.
Syntax:
if (condition) {
// Executes this block if
// condition is true
} else {
// Executes this block if
// condition is false
}
Flow Chart:
Nested if : Nested if statements mean an if statement inside an if statement. Yes, Golang allows us to nest if statements within if statements. i.e, we can place an if statement inside another if statement.
Syntax:
if (condition1) {
// Executes when condition1 is true
if (condition2) {
// Executes when condition2 is true
}
}
Flow Chart:
if-else-if Ladder : Here, a user can decide among multiple options. The if statements are executed from the top down. As soon as one of the conditions controlling the if is true, the statement associated with that if is executed, and the rest of the ladder is bypassed. If none of the conditions is true, then the final else statement will be executed.
Some popular Applications developed in Go Language
- Docker: a set of tools for deploying linux containers
- Openshift: a cloud computing platform as a service by Red Hat.
- Kubernetes: The future of seamlessly automated deployment processes
- Dropbox: migrated some of their critical components from Python to Go.
- Netflix: for two part of their server architecture.
- InfluxDB: is an open-source time series database developed by InfluxData.
- Golang: The language itself was written in Go.
Go Programming Language : An Overview of Go Part
Explore
Go Tutorial
3 min read
Overview
Fundamentals
Control Statements
Functions & Methods
Structure
Arrays
Slices
Strings
Pointers