Go 课程

Introduction to Go (Golang)

Python 3初学者教程。

What is Go?

Go (also known as Golang) is an open-source programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. It was first released in 2009 and has since become one of the most popular languages for backend development, cloud infrastructure, and DevOps tooling.

Where is Go used?

  • Cloud & Infrastructure — Docker, Kubernetes, Terraform are all written in Go
  • Backend APIs — High-performance web servers and microservices
  • DevOps tooling — CLI tools, deployment pipelines
  • Networking — Proxies, load balancers, network utilities

Why Go?

  • ⚡ Compiles to a single fast binary — no runtime required
  • 🔒 Statically typed — catch errors at compile time
  • 🔄 Built-in concurrency with goroutines and channels
  • 📦 Simple, minimal syntax — easy to read and maintain

Your first Go program

package main

import "fmt"

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

Every Go program starts with a package main declaration and a main() function. The fmt package provides formatted I/O functions.

Running Go code

// Save as main.go, then run:
// go run main.go
// Or build a binary:
// go build -o hello main.go
// ./hello

You can also use the Go Playground at play.golang.org to run code directly in your browser without any installation.