Apa itu GO?
APakah ini bagian dari Gojek? Oh ternyata bukan lol… Go adalah bahasa pemrograman yang dibuat oleh Google pada tahun 2007. Sejak saat itulah mereka memutuskan untuk mengimplementasikan Go untuk membuat produk dan servis dalam skala besar.
Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines, while its novel type system enables flexible and modular program construction. Go compiles quickly to machine code yet has the convenience of garbage collection and the power of run-time reflection. It’s a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.
- Go is an open source programming language supported by Google
- Easy to learn and get started with
- Built-in concurrency and a robust standard library
- Growing ecosystem of partners, communities, and tools
Check Latest Go Version
- https://go.dev/dl/
- Copy link base on your architecture PC
Atau bisa juga install dari repository ubuntu dengan cara
sudo apt install golang-g
.
Install Go
- open powershell, type wsl
1
cd ~
- Download package
1
wget https://go.dev/dl/go1.18.3.linux-amd64.tar.gz
- Extract
1
sudo tar -xvf go1.18.3.linux-amd64.tar.gz
- Move to /usr/local
1
sudo mv go /usr/local
Edit .bashrc
masih dengan wsl guys…
- copas path environment:
code ~/.bashrc
1 2 3 export GOROOT=/usr/local/go export GOPATH=$HOME/go export PATH=$GOPATH/bin:$GOROOT/bin:$PATH- reload terminal:
source ~/.bashrc
- next cek dulu
1 2 which go go version
Saatnya mencoba
cd /source/labs
ini bebas mo bikin dimana sihmkdir go
cd go
mkdir hello
cd hello
go mod init example/hello
touch hello.go
nano hello.go
1 2 3 4 5 6 7
package main import "fmt" func main() { fmt.Println("Hello, World!") }
go run .
orgo run hello.go
nano hello.go
Test Running Code