1. Simpel Itu Mewah
- Inheritance yang ribet
- Generics yang bikin pusing (walaupun sekarang udah ada di versi baru, tapi tetep simpel)
- Method overloading
Intinya: Go memaksa kita nulis kode yang explicit dan mudah dibaca orang lain. Kode yang gampang dibaca = gampang di-maintain.
2. Concurrency: Senjata Rahasia Go
package main
import (
"fmt"
"time"
)
func ngopi(jenis string) {
for i := 0; i < 3; i++ {
fmt.Println("Lagi nyeruput:", jenis)
time.Sleep(100 * time.Millisecond)
}
}
func main() {
// Tinggal tambah keyword "go" di depan function
go ngopi("Arabica")
go ngopi("Robusta")
// Tunggu sebentar biar ke-print semua
time.Sleep(1 * time.Second)
fmt.Println("Kopi habis, lanjut coding!")
}go di depan fungsi, dan boom! Jalan barengan. Nggak pake ribet setup thread pool.
3. Performa yang "Sat Set"
- Startup time super cepat.
- File binary tunggal. Lo bisa compile di laptop lo, terus copy satu file itu ke server, dan langsung jalan. Nggak perlu install dependency atau runtime environment di server. Goodbye, "It works on my machine"!
4. Sisi "Unik" (Yang Sering Jadi Meme)
try-catch. Kita ngecek error secara manual. Lo bakal sering banget nulis kode kayak gini:
file, err := os.Open("rahasia.txt")
if err != nil {
log.Fatal(err)
}
data, err := io.ReadAll(file)
if err != nil {
log.Fatal(err)
}Kesimpulan: Worth It Nggak?
- Install Go di laptop lo.
- Ikutin A Tour of Go.
- Coba bikin API sederhana pake library standar
net/http.