Getting Started with Golang

Mon, Aug 14, 2017 2-minute read

Continuing this series on next-generation languages, this time I’m taking a look at Golang. If you want detailed information about Go along with an online Go playground to experiment in, https://golang.org/ is the place to start.

Getting Go running begins with the binary files. Since I’m on Ubuntu 16.04 for this post, the quickest route is to pull golang-go straight from the repository.

sudo apt install golang-go

With that in place, we head over to https://golang.org/dl/ and download the archive that matches our system, then extract it into the go folder under /usr/local.

sudo tar -C /usr/local -xzf go $VERSION.$OS-$ARCH.tar.gz

For the go command to be available in the terminal, Go needs to be on our path, so we add the line export PATH=$PATH:/usr/local/go/bin to the /etc/profiles file.

That’s everything we need, so let’s write and build a hello world application.

package main

import "fmt"

func main(){
  fmt.Printf("Hello World , www.webischia.com\n")
}

gopher logo gopher.{ai,svg,png} was created by Takuya Ueda (https://twitter.com/tenntenn). Licensed under the Creative Commons 3.0 Attributions license.

– Turkish Version –

Golang Başlangıç

Yeni nesil diller serisine devam ederken bu sefer Golang ile ilgileniyorum. Go hakkında detaylı bilgi ve denemeler yapabileceğiniz online bir Go ortamı için https://golang.org/ adresini ziyaret edebilirsiniz.

Go kurulumu binary dosyalarıyla başlıyor. Bu yazı için Ubuntu 16.04 kullandığımdan, en kolay yol repoda hazır bulunan golang-go paketini indirmek.

sudo apt install golang-go

Bu tamamlandıktan sonra https://golang.org/dl/ kısmından sistemimize uygun arşivi seçip indiriyor, ardından da /usr/local altındaki go klasörüne çıkarıyoruz.

sudo tar -C /usr/local -xzf go $VERSION.$OS-$ARCH.tar.gz

Terminalde go komutunu kullanabilmemiz için Go’nun path üzerinde olması gerekiyor, bu yüzden /etc/profiles dosyasına export PATH=$PATH:/usr/local/go/bin satırını ekliyoruz.

İhtiyacımız olan her şey hazır olduğuna göre, şimdi hello world uygulamamızı yazıp build edelim.

package main

import "fmt"

func main(){
  fmt.Printf("Hello World , www.webischia.com\n")
}

gopher logo gopher.{ai,svg,png} was created by Takuya Ueda (https://twitter.com/tenntenn). Licensed under the Creative Commons 3.0 Attributions license.