ScriptsApr 11, 2026·1 min read

Go — The Go Programming Language from Google

Go is an open-source programming language designed at Google by Rob Pike, Ken Thompson, and Robert Griesemer. Fast compilation, garbage collection, built-in concurrency via goroutines and channels, and a massive standard library. Powers Docker, Kubernetes, and most cloud infrastructure.

SC
Script Depot · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

# Install
brew install go                            # macOS
sudo snap install go --classic             # Linux
# Or download from https://go.dev/dl

go version

Hello world:

// main.go
package main

import (
    "fmt"
    "net/http"
)

func main() {
    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        fmt.Fprintf(w, "Hello from Go")
    })
    fmt.Println("Listening on :8080")
    http.ListenAndServe(":8080", nil)
}

Run and build:

go mod init myapp
go run main.go
go build -o myapp main.go
GOOS=linux GOARCH=amd64 go build -o myapp-linux main.go
go test ./...
go vet ./...
go install tool
Intro

Go (often called Golang) is an open-source programming language designed at Google in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. Designed for simplicity, fast compilation, and effective concurrency. Now the lingua franca of cloud infrastructure: Docker, Kubernetes, Terraform, Prometheus, CockroachDB, etcd, and many more are written in Go.

What Go Does

  • Compiled — fast native binaries, cross-compile
  • Garbage collected — low-pause GC optimized for latency
  • Static typing — with type inference via :=
  • Goroutines — cheap concurrent functions (thousands per MB)
  • Channels — CSP-style communication between goroutines
  • Interfaces — structural typing, no inheritance
  • Standard library — HTTP, crypto, JSON, SQL all in stdlib
  • Tooling — go fmt, vet, test, doc, mod built in
  • Modules — dependency management since Go 1.11
  • Generics — since Go 1.18

Architecture

Compiler (gc) written in Go itself, plus gccgo alternative. Runtime manages goroutine scheduler (M:N mapping to OS threads), memory allocator, and garbage collector. Single static binary output — no DLL hell.

Self-Hosting

Language toolchain. Installs via official installer or package manager.

Key Features

  • Single static binary output
  • Lightning-fast compilation
  • Cross-compilation (GOOS/GOARCH)
  • Goroutines + channels
  • Rich standard library
  • go fmt canonical formatting
  • Comprehensive tooling (test, vet, doc)
  • Generics (since 1.18)
  • Fuzzing (since 1.18)
  • Workspaces for multi-module dev

Comparison

Language Concurrency Compilation GC Typical Use
Go Goroutines/CSP Fast Yes Cloud infra
Rust Async + threads Slow No (ownership) Systems
Java Threads + Project Loom Medium Yes Enterprise
Python asyncio Interpreted Yes Scripts, ML
C++ Threads + coroutines Slow No Performance
Node.js Event loop JIT Yes Web APIs

常见问题 FAQ

Q: Go 适合 web 开发吗? A: 非常适合。标准库有完整 HTTP server,加上 Gin、Echo、Fiber、Chi 等 framework。Go 也是微服务和 gRPC 后端的首选。

Q: 泛型什么时候加的? A: Go 1.18 (2022年3月)。之前要靠 interface{} 或代码生成,现在可以写真正的类型参数化函数和类型。

Q: Goroutines 和 OS 线程区别? A: Goroutine 是 Go 运行时管理的用户态协程,初始栈 2KB(vs OS 线程 1-8MB)。调度器在 OS 线程上 M:N 调度 goroutine,可轻松开百万个。

来源与致谢 Sources

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets