Hello World to Golang
package main
import "fmt"
func main() {
fmt.Println("Hello, δΈη")
}
Installasi golang (Mac OS)
Via installer
Unduh installer di di https://golang.org/dl/ untuk versi terbaru 1.14.2
go1.14.2.darwin-amd64.pkg (120MB)
lalu buka file dan ikuti instruksi. Installer akan menginstall paket Go di /usr/local/go.
which go
Via Brew
Paling mudah menggunakan brew.
brew install go
which go
# /usr/local/bin/go
Membuat Aplikasi Go pertama kamu kuy
Buat direktori projek kamu di manapaun terserah ( anywhere/<your_app_location> )
`:
mkdir -p anywhere/first
cd anywhere/first
go mod init my.app
lalu buka app.go dan ketik
package main
import "fmt"
func main() {
fmt.Println("my app!\n")
}
lalu jalankan
go run app.go
#my app
Selanjutnya? https://tour.golang.org/welcome/1
Referensi
- https://medium.com/easyread/pengalaman-saya-belajar-golang-94478b98331d
- https://medium.com/golang-learn/quick-go-setup-guide-on-mac-os-x-956b327222b8
- https://golang.org/pkg/