Go Gopher How to Go


Go Version GitHub stars License whalelogic on GitHub

Go is an open source programming language designed for building scalable, secure, and reliable software. Go combines the performance of C with features like garbage collection, concurrency, and a strong type system.

How to Go is a modern, hands-on language reference. Master everything from syntax to advanced patterns through annotated examples.




Hello World Icon Hello, World!

This is the traditional first program for learning a new programming language.

In Go, you can create a simple "Hello, World!" program like this:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

To run this program, save it to a file named hello.go and use the command:

go run hello.go
Output:
Hello, World!

Program Structure

ComponentPurposeRequired
package mainDeclares this is an executable programYes (for executables)
import "fmt"Imports the fmt package for formatted I/OOnly if using fmt functions
func main()Entry point of the programYes (for executables)
fmt.Println()Prints text followed by a newlineNo

Common Go Commands

CommandDescription
go run hello.goCompile and run the program directly
go build hello.goCompile to an executable binary
go fmt hello.goFormat the code according to Go standards
go mod init myappInitialize a new Go module