🐹

Go (Golang)

Lipuo tsa Mananeo

Puo ea lenaneo e potlakileng, e ngotsoeng ka mokhoa o sa fetoheng ho tsoa ho Google bakeng sa ho haha li-application tse sebetsang hantle le tse ka atolosoang

Lintlha tsa ho kenya

Ho romelloa ha basebetsi: 2-5 min
sehlopha: Lipuo tsa Mananeo
RAM e tlase: 256MB
Tšehetso: Litekete le imeile

Tseba lengolo lena

Tlhaloso

Go (Golang) ke puo ea lenaneo e tsitsitseng ka mokhoa o hlophisitsoeng, e hahiloeng ke Google bakeng sa ho haha software e bonolo, e tšepahalang le e sebetsang hantle. E hlahisitsoe ke Rob Pike, Ken Thompson le Robert Griesemer, Go e kopanya ts'ebetso le polokeho ea lipuo tse hlophisitsoeng joalo ka C++ le bonolo ba ho sebelisa le tlhahiso ea lipuo tse hlalosoang joalo ka Python. Likarolo tse matla tsa Go li kenyelletsa ho hlophisa ka lebelo le phahameng haholo, concurrency ea semmuso ka goroutines le channels, garbage collection ea kahare, le laeborari e felletseng ea mantlha. Puo e phethahatsa bonolo: tsela e le 'ngoe ea ho etsa lintho, ho sebetsana le liphoso ka ho hlakileng, le syntax e nyane, e etsang hore khoutu ea Go e be bonolo ho e bala, ho e hlokomela le ho e atolosa lihlopheng tse kholo.

Likarolo tsa bohlokoa

Ho Hlophisa ka Lebelo

Hlophisa mela e limilione ka metsotsoana ka taolo ea li-dependency

Goroutines le Channels

Concurrency e bobebe ka phetisetso ea melaetsa ea mofuta oa CSP

Li-binary tse Tsitsitseng

Binary e le 'ngoe ntle le li-dependency bakeng sa romello e bonolo

Laeborari e Felletseng ea Mantlha

Li-HTTP server, JSON, crypto, liteko le tse ling tse kahare

Ho Sebetsa Lipalangoang Tse Fapaneng

Hlophisa bakeng sa Linux, macOS, Windows, ARM ho tsoa sistimi efe kapa efe

Lisebelisoa tsa Kahare

go fmt, go test, go mod, race detector le profiler li kenyelelitsoe

Mehlala ea ho sebelisa

• Li-API tsa backend le microservices
• Lits'ebetso tsa cloud-native (Docker, Kubernetes)
• Lisebelisoa tsa DevOps le lits'ebetso tsa CLI
• Lisistimi tse aroloang le litšebeletso tsa marang-rang
• Li-web server tse phahameng ka ts'ebetso
• Li-pipeline tsa ts'ebetso ea data
• Ho ngola lits'ebetso tsa sistimi le lisebelisoa tsa infrastructure

Litaelo tsa ho kenya

Kenyo ho Ubuntu:
# Download latest (check golang.org/dl)
wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz

# Extract to /usr/local
sudo rm -rf /usr/local/go
sudo tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz

# Add to PATH
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
echo 'export GOPATH=$HOME/go' >> ~/.bashrc
source ~/.bashrc

# Verify
go version
Lumela Lefatše:
package main
import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
go run main.go
go build -o myapp main.go
./myapp

Litlhahiso tsa ho kenya

Sebopeho sa Projeke:
myapp/
├── go.mod          # Module definition
├── go.sum          # Dependency checksums
├── main.go         # Entry point
├── internal/       # Private packages
└── cmd/            # CLI commands
go.mod:
module github.com/user/myapp

go 1.21

require (
    github.com/gin-gonic/gin v1.9.1
    github.com/lib/pq v1.10.9
)
Mohlala oa HTTP Server:
package main

import (
    "net/http"
    "github.com/gin-gonic/gin"
)

func main() {
    r := gin.Default()
    
    r.GET("/", func(c *gin.Context) {
        c.JSON(200, gin.H{"message": "Hello"})
    })
    
    r.Run(":8080")
}
Mohlala oa Concurrency:
package main

import (
    "fmt"
    "time"
)

func worker(id int, jobs <-chan int, results chan<- int) {
    for j := range jobs {
        fmt.Printf("Worker %d processing job %d\n", id, j)
        time.Sleep(time.Second)
        results <- j * 2
    }
}

func main() {
    jobs := make(chan int, 100)
    results := make(chan int, 100)

    // Start 3 workers
    for w := 1; w <= 3; w++ {
        go worker(w, jobs, results)
    }

    // Send 5 jobs
    for j := 1; j <= 5; j++ {
        jobs <- j
    }
    close(jobs)

    // Collect results
    for a := 1; a <= 5; a++ {
        <-results
    }
}

Likopo tsa theknoloji

Litaelo tsa sistimi

  • Khopolo: 256MB RAM

Lekanya Sengoloa sena

★★★★★
-
Ho kenya...

Na o se o loketse ho kenya kopo ya hao? Go (Golang)?

Qala ka metsotsoana ka ts'ebetso ea rona e bonolo ea ho kenya VPS

Ho kenya ka ho ka bang 2 metsotso • Full root ho kena • Thuto ka terene le lengolo tsoibila