Go Documentation

Hello, World!

Our first program will print the classic “hello world” message. Here’s the source code.


                package main
                import "fmt"
                func main() {
                    fmt.Println("hello world")
                }
                

values


                package main
                import "fmt"
                func main() {
                    fmt.Println("go" + "lang")
                    fmt.Println("1+1 =", 1+1)
                    fmt.Println("7.0/3.0 =", 7.0/3.0)
                    fmt.Println(true && false)
                    fmt.Println(true || false)
                    fmt.Println(!true)
                }
                

variables


                package main
                import "fmt"
                func main() {
                    var a = "initial"
                    fmt.Println(a)
                    var b, c int = 1, 2
                    fmt.Println(b, c)
                    var d = true
                    fmt.Println(d)
                    var e int
                    fmt.Println(e)
                    f := "apple"
                    fmt.Println(f)
                }
                

constants


                package main
                import (
                    "fmt"
                    "math"
                )
                const s string = "constant"
                func main() {
                    fmt.Println(s)
                    const n = 500000000
                    const d = 3e20 / n
                    fmt.Println(d)
                    fmt.Println(int64(d))
                    fmt.Println(math.Sin(n))
                }
                

for loop


                package main
                import "fmt"
                func main() {
                    i := 1
                    for i <= 3 {
                        fmt.Println(i)
                        i = i + 1
                    }
                    for j := 7; j <= 9; j++ {
                        fmt.Println(j)
                    }
                    for {
                        fmt.Println("loop")
                        break
                    }
                    for n := 0; n <= 5; n++ {
                        if n%2 == 0 {
                            continue
                        }
                        fmt.Println(n)
                    }
                }
                

if/else


                package main
                import "fmt"
                func main() {
                    if 7%2 == 0 {
                        fmt.Println("7 is even")
                    } else {
                        fmt.Println("7 is odd")
                    }
                    if 8%4 == 0 {
                        fmt.Println("8 is divisible by 4")
                    }
                    if num := 9; num < 0 {
                        fmt.Println(num, "is negative")
                    } else if num < 10 {
                        fmt.Println(num, "has 1 digit")
                    } else {
                        fmt.Println(num, "has multiple digits")
                    }
                }
                

switch


                package main
                import (
                    "fmt"
                    "time"
                )
                func main() {
                    i := 2
                    fmt.Print("Write ", i, " as ")
                    switch i {
                    case 1:
                        fmt.Println("one")
                    case 2:
                        fmt.Println("two")
                    case 3:
                        fmt.Println("three")
                    }
                    switch time.Now().Weekday() {
                    case time.Saturday, time.Sunday:
                        fmt.Println("It's the weekend")
                    default:
                        fmt.Println("It's a weekday")
                    }
                    t := time.Now()
                    switch {
                    case t.Hour() < 12:
                        fmt.Println("It's before noon")
                    default:
                        fmt.Println("It's after noon")
                    }
                    whatAmI := func(i interface{}) {
                        switch t := i.(type) {
                        case bool:
                            fmt.Println("I'm a bool")
                        case int:
                            fmt.Println("I'm an int")
                        default:
                            fmt.Printf("Don't know type %T\n", t)
                        }
                    }
                    whatAmI(true)
                    whatAmI(1)
                    whatAmI("hey")
                }
                

arrays


                package main
                import "fmt"
                func main() {
                    var a [5]int
                    fmt.Println("emp:", a)
                    a[4] = 100
                    fmt.Println("set:", a)
                    fmt.Println("get:", a[4])
                    fmt.Println("len:", len(a))
                    b := [5]int{1, 2, 3, 4, 5}
                    fmt.Println("dcl:", b)
                    var twoD [2][3]int
                    for i := 0; i < 2; i++ {
                        for j := 0; j < 3; j++ {
                            twoD[i][j] = i + j
                        }
                    }
                    fmt.Println("2d: ", twoD)
                }
                

slices


                package main
                import "fmt"
                func main() {
                    s := make([]string, 3)
                    fmt.Println("emp:", s)
                    s[0] = "a"
                    s[1] = "b"
                    s[2] = "c"
                    fmt.Println("set:", s)
                    fmt.Println("get:", s[2])
                    fmt.Println("len:", len(s))
                    s = append(s, "d")
                    s = append(s, "e", "f")
                    fmt.Println("apd:", s)
                    c := make([]string, len(s))
                    copy(c, s)
                    fmt.Println("cpy:", c)
                    l := s[2:5]
                    fmt.Println("sl1:", l)
                    l = s[:5]
                    fmt.Println("sl2:", l)
                    l = s[2:]
                    fmt.Println("sl3:", l)
                    t := []string{"g", "h", "i"}
                    fmt.Println("dcl:", t)
                    twoD := make([][]int, 3)
                    for i := 0; i < 3; i++ {
                        innerLen := i + 1
                        twoD[i] = make([]int, innerLen)
                        for j := 0; j < innerLen; j++ {
                            twoD[i][j] = i + j
                        }
                    }
                    fmt.Println("2d: ", twoD)
                }
                

maps


                package main
                
                import "fmt"
                
                func main() {
                
                    m := make(map[string]int)
                
                    m["k1"] = 7
                    m["k2"] = 13
                
                    fmt.Println("map:", m)
                
                    v1 := m["k1"]
                    fmt.Println("v1: ", v1)
                
                    fmt.Println("len:", len(m))
                
                    delete(m, "k2")
                    fmt.Println("map:", m)
                
                    _, prs := m["k2"]
                    fmt.Println("prs:", prs)
                
                    n := map[string]int{"foo": 1, "bar": 2}
                    fmt.Println("map:", n)
                }
                

range


                package main
            
                import "fmt"
                
                func main() {
                
                    nums := []int{2, 3, 4}
                    sum := 0
                    for _, num := range nums {
                        sum += num
                    }
                    fmt.Println("sum:", sum)
                
                    for i, num := range nums {
                        if num == 3 {
                            fmt.Println("index:", i)
                        }
                    }
                
                    kvs := map[string]string{"a": "apple", "b": "banana"}
                    for k, v := range kvs {
                        fmt.Printf("%s -> %s\n", k, v)
                    }
                
                    for k := range kvs {
                        fmt.Println("key:", k)
                    }
                
                    for i, c := range "go" {
                        fmt.Println(i, c)
                    }
                }
                

functions


                package main

                import "fmt"
                
                func plus(a int, b int) int {
                
                    return a + b
                }
                
                func plusPlus(a, b, c int) int {
                    return a + b + c
                }
                
                func main() {
                
                    res := plus(1, 2)
                    fmt.Println("1+2 =", res)
                
                    res = plusPlus(1, 2, 3)
                    fmt.Println("1+2+3 =", res)
                }
                

Multiple Return Values


                package main

                import "fmt"
                
                func vals() (int, int) {
                    return 3, 7
                }
                
                func main() {
                
                    a, b := vals()
                    fmt.Println(a)
                    fmt.Println(b)
                
                    _, c := vals()
                    fmt.Println(c)
                }
                

Variadic Functions


                package main

                import "fmt"
                
                func sum(nums ...int) {
                    fmt.Print(nums, " ")
                    total := 0
                    for _, num := range nums {
                        total += num
                    }
                    fmt.Println(total)
                }
                
                func main() {
                
                    sum(1, 2)
                    sum(1, 2, 3)
                
                    nums := []int{1, 2, 3, 4}
                    sum(nums...)
                }
                

Closures


                package main

                import "fmt"
                
                func intSeq() func() int {
                    i := 0
                    return func() int {
                        i++
                        return i
                    }
                }
                
                func main() {
                
                    nextInt := intSeq()
                
                    fmt.Println(nextInt())
                    fmt.Println(nextInt())
                    fmt.Println(nextInt())
                
                    newInts := intSeq()
                    fmt.Println(newInts())
                }
                

Recursion


                package main

                import "fmt"
                
                func fact(n int) int {
                    if n == 0 {
                        return 1
                    }
                    return n * fact(n-1)
                }
                
                func main() {
                    fmt.Println(fact(7))
                }
                

Pointers


                package main

                import "fmt"
                
                func zeroval(ival int) {
                    ival = 0
                }
                
                func zeroptr(iptr *int) {
                    *iptr = 0
                }
                
                func main() {
                    i := 1
                    fmt.Println("initial:", i)
                
                    zeroval(i)
                    fmt.Println("zeroval:", i)
                
                    zeroptr(&i)
                    fmt.Println("zeroptr:", i)
                
                    fmt.Println("pointer:", &i)
                }
                

Structs


                package main

                import "fmt"
                
                type person struct {
                    name string
                    age  int
                }
                
                func NewPerson(name string) *person {
                
                    p := person{name: name}
                    p.age = 42
                    return &p
                }
                
                func main() {
                
                    fmt.Println(person{"Bob", 20})
                
                    fmt.Println(person{name: "Alice", age: 30})
                
                    fmt.Println(person{name: "Fred"})
                
                    fmt.Println(&person{name: "Ann", age: 40})
                
                    fmt.Println(NewPerson("Jon"))
                
                    s := person{name: "Sean", age: 50}
                    fmt.Println(s.name)
                
                    sp := &s
                    fmt.Println(sp.age)
                
                    sp.age = 51
                    fmt.Println(sp.age)
                }
                

Methods


                package main

                import "fmt"
                
                type rect struct {
                    width, height int
                }
                
                func (r *rect) area() int {
                    return r.width * r.height
                }
                
                func (r rect) perim() int {
                    return 2*r.width + 2*r.height
                }
                
                func main() {
                    r := rect{width: 10, height: 5}
                
                    fmt.Println("area: ", r.area())
                    fmt.Println("perim:", r.perim())
                
                    rp := &r
                    fmt.Println("area: ", rp.area())
                    fmt.Println("perim:", rp.perim())
                }
                

Interfaces


                package main
                
                import (
                    "fmt"
                    "math"
                )
                
                type geometry interface {
                    area() float64
                    perim() float64
                }
                
                type rect struct {
                    width, height float64
                }
                type circle struct {
                    radius float64
                }
                
                func (r rect) area() float64 {
                    return r.width * r.height
                }
                func (r rect) perim() float64 {
                    return 2*r.width + 2*r.height
                }
                
                func (c circle) area() float64 {
                    return math.Pi * c.radius * c.radius
                }
                func (c circle) perim() float64 {
                    return 2 * math.Pi * c.radius
                }
                
                func measure(g geometry) {
                    fmt.Println(g)
                    fmt.Println(g.area())
                    fmt.Println(g.perim())
                }
                
                func main() {
                    r := rect{width: 3, height: 4}
                    c := circle{radius: 5}
                
                    measure(r)
                    measure(c)
                }
                

Errors


                package main
                
                import (
                    "errors"
                    "fmt"
                )
                
                func f1(arg int) (int, error) {
                    if arg == 42 {
                
                        return -1, errors.New("can't work with 42")
                
                    }
                
                    return arg + 3, nil
                }
                
                type argError struct {
                    arg  int
                    prob string
                }
                
                func (e *argError) Error() string {
                    return fmt.Sprintf("%d - %s", e.arg, e.prob)
                }
                
                func f2(arg int) (int, error) {
                    if arg == 42 {
                
                        return -1, &argError{arg, "can't work with it"}
                    }
                    return arg + 3, nil
                }
                
                func main() {
                
                    for _, i := range []int{7, 42} {
                        if r, e := f1(i); e != nil {
                            fmt.Println("f1 failed:", e)
                        } else {
                            fmt.Println("f1 worked:", r)
                        }
                    }
                    for _, i := range []int{7, 42} {
                        if r, e := f2(i); e != nil {
                            fmt.Println("f2 failed:", e)
                        } else {
                            fmt.Println("f2 worked:", r)
                        }
                    }
                
                    _, e := f2(42)
                    if ae, ok := e.(*argError); ok {
                        fmt.Println(ae.arg)
                        fmt.Println(ae.prob)
                    }
                }
                

Goroutines


                package main
                
                import (
                    "fmt"
                    "time"
                )
                
                func f(from string) {
                    for i := 0; i < 3; i++ {
                        fmt.Println(from, ":", i)
                    }
                }
                
                func main() {
                
                    f("direct")
                
                    go f("goroutine")
                
                    go func(msg string) {
                        fmt.Println(msg)
                    }("going")
                
                    time.Sleep(time.Second)
                    fmt.Println("done")
                }
                

Channels


                package main

                import "fmt"
                
                func main() {
                
                    messages := make(chan string)
                
                    go func() { messages <- "ping" }()
                
                    msg := <-messages
                    fmt.Println(msg)
                }
                

Channel Buffering


                package main

                import "fmt"
                
                func main() {
                
                    messages := make(chan string, 2)
                
                    messages <- "buffered"
                    messages <- "channel"
                
                    fmt.Println(<-messages)
                    fmt.Println(<-messages)
                }
                

Channel Synchronization


                package main

                import (
                    "fmt"
                    "time"
                )
                
                func worker(done chan bool) {
                    fmt.Print("working...")
                    time.Sleep(time.Second)
                    fmt.Println("done")
                
                    done <- true
                }
                
                func main() {
                
                    done := make(chan bool, 1)
                    go worker(done)
                
                    <-done
                }
                

Channel Directions


                package main

                import "fmt"
                
                func ping(pings chan<- string, msg string) {
                    pings <- msg
                }
                
                func pong(pings <-chan string, pongs chan<- string) {
                    msg := <-pings
                    pongs <- msg
                }
                
                func main() {
                    pings := make(chan string, 1)
                    pongs := make(chan string, 1)
                    ping(pings, "passed message")
                    pong(pings, pongs)
                    fmt.Println(<-pongs)
                }
                

Select


                package main
                
                import (
                    "fmt"
                    "time"
                )
                
                func main() {
                
                    c1 := make(chan string)
                    c2 := make(chan string)
                
                    go func() {
                        time.Sleep(1 * time.Second)
                        c1 <- "one"
                    }()
                    go func() {
                        time.Sleep(2 * time.Second)
                        c2 <- "two"
                    }()
                
                    for i := 0; i < 2; i++ {
                        select {
                        case msg1 := <-c1:
                            fmt.Println("received", msg1)
                        case msg2 := <-c2:
                            fmt.Println("received", msg2)
                        }
                    }
                }
                

Timeouts


                package main
                
                import (
                    "fmt"
                    "time"
                )
                
                func main() {
                
                    c1 := make(chan string, 1)
                    go func() {
                        time.Sleep(2 * time.Second)
                        c1 <- "result 1"
                    }()
                
                    select {
                    case res := <-c1:
                        fmt.Println(res)
                    case <-time.After(1 * time.Second):
                        fmt.Println("timeout 1")
                    }
                
                    c2 := make(chan string, 1)
                    go func() {
                        time.Sleep(2 * time.Second)
                        c2 <- "result 2"
                    }()
                    select {
                    case res := <-c2:
                        fmt.Println(res)
                    case <-time.After(3 * time.Second):
                        fmt.Println("timeout 2")
                    }
                }
                

Non-Blocking Channel Operations


                package main

                import "fmt"
                
                func main() {
                    messages := make(chan string)
                    signals := make(chan bool)
                
                    select {
                    case msg := <-messages:
                        fmt.Println("received message", msg)
                    default:
                        fmt.Println("no message received")
                    }
                
                    msg := "hi"
                    select {
                    case messages <- msg:
                        fmt.Println("sent message", msg)
                    default:
                        fmt.Println("no message sent")
                    }
                
                    select {
                    case msg := <-messages:
                        fmt.Println("received message", msg)
                    case sig := <-signals:
                        fmt.Println("received signal", sig)
                    default:
                        fmt.Println("no activity")
                    }
                }
                

Closing Channels


                package main
                
                import "fmt"
                
                func main() {
                    jobs := make(chan int, 5)
                    done := make(chan bool)
                
                    go func() {
                        for {
                            j, more := <-jobs
                            if more {
                                fmt.Println("received job", j)
                            } else {
                                fmt.Println("received all jobs")
                                done <- true
                                return
                            }
                        }
                    }()
                
                    for j := 1; j <= 3; j++ {
                        jobs <- j
                        fmt.Println("sent job", j)
                    }
                    close(jobs)
                    fmt.Println("sent all jobs")
                
                    <-done
                }
                

Range over Channels


                package main

                import "fmt"
                
                func main() {
                
                    queue := make(chan string, 2)
                    queue <- "one"
                    queue <- "two"
                    close(queue)
                
                    for elem := range queue {
                        fmt.Println(elem)
                    }
                }
                

Timers


                package main
                
                import (
                    "fmt"
                    "time"
                )
                
                func main() {
                
                    timer1 := time.NewTimer(2 * time.Second)
                
                    <-timer1.C
                    fmt.Println("Timer 1 expired")
                
                    timer2 := time.NewTimer(time.Second)
                    go func() {
                        <-timer2.C
                        fmt.Println("Timer 2 expired")
                    }()
                    stop2 := timer2.Stop()
                    if stop2 {
                        fmt.Println("Timer 2 stopped")
                    }
                }
                

Tickers


                package main
                
                import (
                    "fmt"
                    "time"
                )
                
                func main() {
                
                    ticker := time.NewTicker(500 * time.Millisecond)
                    done := make(chan bool)
                
                    go func() {
                        for {
                            select {
                            case <-done:
                                return
                            case t := <-ticker.C:
                                fmt.Println("Tick at", t)
                            }
                        }
                    }()
                
                    time.Sleep(1600 * time.Millisecond)
                    ticker.Stop()
                    done <- true
                    fmt.Println("Ticker stopped")
                }
                

Worker Pools


                package main

                import (
                    "fmt"
                    "time"
                )
                
                func worker(id int, jobs <-chan int, results chan<- int) {
                    for j := range jobs {
                        fmt.Println("worker", id, "started  job", j)
                        time.Sleep(time.Second)
                        fmt.Println("worker", id, "finished job", j)
                        results <- j * 2
                    }
                }
                
                func main() {
                
                    jobs := make(chan int, 100)
                    results := make(chan int, 100)
                
                    for w := 1; w <= 3; w++ {
                        go worker(w, jobs, results)
                    }
                
                    for j := 1; j <= 5; j++ {
                        jobs <- j
                    }
                    close(jobs)
                
                    for a := 1; a <= 5; a++ {
                        <-results
                    }
                }
                

WaitGroups


                package main
                
                import (
                    "fmt"
                    "sync"
                    "time"
                )
                
                func worker(id int, wg *sync.WaitGroup) {
                    fmt.Printf("Worker %d starting\n", id)
                
                    time.Sleep(time.Second)
                    fmt.Printf("Worker %d done\n", id)
                
                    wg.Done()
                }
                
                func main() {
                
                    var wg sync.WaitGroup
                
                    for i := 1; i <= 5; i++ {
                        wg.Add(1)
                        go worker(i, &wg)
                    }
                
                    wg.Wait()
                }
                

Rate Limiting


                package main
                
                import (
                    "fmt"
                    "time"
                )
                
                func main() {
                
                    requests := make(chan int, 5)
                    for i := 1; i <= 5; i++ {
                        requests <- i
                    }
                    close(requests)
                
                    limiter := time.Tick(200 * time.Millisecond)
                
                    for req := range requests {
                        <-limiter
                        fmt.Println("request", req, time.Now())
                    }
                
                    burstyLimiter := make(chan time.Time, 3)
                
                    for i := 0; i < 3; i++ {
                        burstyLimiter <- time.Now()
                    }
                
                    go func() {
                        for t := range time.Tick(200 * time.Millisecond) {
                            burstyLimiter <- t
                        }
                    }()
                
                    burstyRequests := make(chan int, 5)
                    for i := 1; i <= 5; i++ {
                        burstyRequests <- i
                    }
                    close(burstyRequests)
                    for req := range burstyRequests {
                        <-burstyLimiter
                        fmt.Println("request", req, time.Now())
                    }
                }
                

Atomic Counters


                package main
                
                import (
                    "fmt"
                    "sync"
                    "sync/atomic"
                )
                
                func main() {
                
                    var ops uint64
                
                    var wg sync.WaitGroup
                
                    for i := 0; i < 50; i++ {
                        wg.Add(1)
                
                        go func() {
                            for c := 0; c < 1000; c++ {
                
                                atomic.AddUint64(&ops, 1)
                            }
                            wg.Done()
                        }()
                    }
                
                    wg.Wait()
                
                    fmt.Println("ops:", ops)
                }
                

Mutexes


                package main
                
                import (
                    "fmt"
                    "math/rand"
                    "sync"
                    "sync/atomic"
                    "time"
                )
                
                func main() {
                
                    var state = make(map[int]int)
                
                    var mutex = &sync.Mutex{}
                
                    var readOps uint64
                    var writeOps uint64
                
                    for r := 0; r < 100; r++ {
                        go func() {
                            total := 0
                            for {
                
                                key := rand.Intn(5)
                                mutex.Lock()
                                total += state[key]
                                mutex.Unlock()
                                atomic.AddUint64(&readOps, 1)
                
                                time.Sleep(time.Millisecond)
                            }
                        }()
                    }
                
                    for w := 0; w < 10; w++ {
                        go func() {
                            for {
                                key := rand.Intn(5)
                                val := rand.Intn(100)
                                mutex.Lock()
                                state[key] = val
                                mutex.Unlock()
                                atomic.AddUint64(&writeOps, 1)
                                time.Sleep(time.Millisecond)
                            }
                        }()
                    }
                
                    time.Sleep(time.Second)
                
                    readOpsFinal := atomic.LoadUint64(&readOps)
                    fmt.Println("readOps:", readOpsFinal)
                    writeOpsFinal := atomic.LoadUint64(&writeOps)
                    fmt.Println("writeOps:", writeOpsFinal)
                
                    mutex.Lock()
                    fmt.Println("state:", state)
                    mutex.Unlock()
                }
                

Stateful Goroutines


                package main
                
                import (
                    "fmt"
                    "math/rand"
                    "sync/atomic"
                    "time"
                )
                
                type readOp struct {
                    key  int
                    resp chan int
                }
                type writeOp struct {
                    key  int
                    val  int
                    resp chan bool
                }
                
                func main() {
                
                    var readOps uint64
                    var writeOps uint64
                
                    reads := make(chan readOp)
                    writes := make(chan writeOp)
                
                    go func() {
                        var state = make(map[int]int)
                        for {
                            select {
                            case read := <-reads:
                                read.resp <- state[read.key]
                            case write := <-writes:
                                state[write.key] = write.val
                                write.resp <- true
                            }
                        }
                    }()
                
                    for r := 0; r < 100; r++ {
                        go func() {
                            for {
                                read := readOp{
                                    key:  rand.Intn(5),
                                    resp: make(chan int)}
                                reads <- read
                                <-read.resp
                                atomic.AddUint64(&readOps, 1)
                                time.Sleep(time.Millisecond)
                            }
                        }()
                    }
                
                    for w := 0; w < 10; w++ {
                        go func() {
                            for {
                                write := writeOp{
                                    key:  rand.Intn(5),
                                    val:  rand.Intn(100),
                                    resp: make(chan bool)}
                                writes <- write
                                <-write.resp
                                atomic.AddUint64(&writeOps, 1)
                                time.Sleep(time.Millisecond)
                            }
                        }()
                    }
                
                    time.Sleep(time.Second)
                
                    readOpsFinal := atomic.LoadUint64(&readOps)
                    fmt.Println("readOps:", readOpsFinal)
                    writeOpsFinal := atomic.LoadUint64(&writeOps)
                    fmt.Println("writeOps:", writeOpsFinal)
                }
                

Sorting


                package main
                
                import (
                    "fmt"
                    "sort"
                )
                
                func main() {
                
                    strs := []string{"c", "a", "b"}
                    sort.Strings(strs)
                    fmt.Println("Strings:", strs)
                
                    ints := []int{7, 2, 4}
                    sort.Ints(ints)
                    fmt.Println("Ints:   ", ints)
                
                    s := sort.IntsAreSorted(ints)
                    fmt.Println("Sorted: ", s)
                }
                

Sorting by Functions


                package main
                
                import (
                    "fmt"
                    "sort"
                )
                
                type byLength []string
                
                func (s byLength) Len() int {
                    return len(s)
                }
                func (s byLength) Swap(i, j int) {
                    s[i], s[j] = s[j], s[i]
                }
                func (s byLength) Less(i, j int) bool {
                    return len(s[i]) < len(s[j])
                }
                
                func main() {
                    fruits := []string{"peach", "banana", "kiwi"}
                    sort.Sort(byLength(fruits))
                    fmt.Println(fruits)
                }
                

Panic


                package main
                
                import "os"
                
                func main() {
                
                    panic("a problem")
                
                    _, err := os.Create("/tmp/file")
                    if err != nil {
                        panic(err)
                    }
                }
                

Defer

Collection Functions

String Functions

String Formatting

Regular Expressions

JSON

XML

Time

Epoch

Time Formatting / Parsing

Random Numbers

Number Parsing

URL Parsing

SHA1 Hashes

Base64 Encoding

Reading Files

Writing Files

Line Filters

File Paths

Directories

Temporary Files and Directories

Testing

Command-Line Arguments

Command-Line Flags

Command-Line Subcommands

Environment Variables

HTTP Clients

HTTP Servers

Spawning Processes

Exec'ing Processes

Signals

Exit

More Links: