• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar
  • Skip to footer

GitopsCentral

  • Home
  • Courses
  • Roadmap
  • About
  • Log In
  • Sign Up

How to install golang on ubuntu or kali linux

November 10, 2018 by shaik zillani

Introduction

Go is a modern programming language developed by Google that uses high-level syntax similar to scripting languages. Go is a statically typed, compiled language in the tradition of C. This tutorial, I will walk you through downloading and installing Go on ubuntu/Kali linux.

Step-1 Download the archive file from official website

golang-download

Visit the official golang website https://golang.org/dl and download the linux variant of go, extract it to /usr/local using the below command,

tar -C /usr/local -xzf go1.11.2.linux-amd64.tar.gz

Step-2 Update GOPATH and reload bashrc

Update bashrc with GOPATH. GOPATH is for the workspace, set this location as per your preference, in my case I have it under /root/go-workspace as you can see below. GOROOT is pointing to the Go’s installation directory.

vim ~/.bashrc

To the end of the file update the path as below,

export GOPATH=/root/go-workspace
export GOROOT=/usr/local/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Now, refresh the .bashrc using the below command,

source ~/.bashrc

Now as the Go got installed & paths are set, Let’s ensure that its working by executing a simple “Hello, World!” program in go. Create a new file and name it hello.go and copy below code into it, which uses the main Go packages, imports the formatted IO content component, &  sets a new function to print ‘hello world’

package main

import "fmt"

func main() {
  fmt.Printf("hello, world\n")
}

Lets execute this,

go run hello.go

hello, world

This file will output “hello world” if it successfully runs, which shows that Go is building files correctly. You can also see a binary file called hello generated. let’s try to execute that and see that the result will be same.

./hello

hello world

Complete golang course:

Please checkout the full golang course from scratch here . We will continuously updating the pages with all new contents.

Installing IDE

Finally, our next step will be, to install an IDE for development. Most people use eclipse with golang plugin or intelliJ with golang plugin. The best IDE if you can buy one is the goland, its built for the golang. You can check out this blog post to learn, how to install goland on linux

golang,  kalilinux,  ubuntu go,  golang,  kali,  kalilinux,  linux,  ubuntu

Primary Sidebar

en English
ar Arabiczh-CN Chinese (Simplified)nl Dutchen Englishfr Frenchde Germanhi Hindiid Indonesianit Italianja Japanesems Malaypt Portugueseru Russianes Spanishte Telugu

Course Tags

concurrency free go golang

Recent Posts

  • Roadmap to Mastery
  • Increase SSH connection timeout
  • Check Certificate expiry in Kubernetes
  • space invaders in golang
  • creating kubernetes cluster using eksctl
  • Facebook
  • GitHub
  • YouTube

Contact

Navigation

  • goacademy pro

Footer

  • Facebook
  • GitHub
  • Instagram
  • LinkedIn
  • Twitter

info@gitopscentral.com


+91 8341443220

© Copyright 2016-2024 gitopscentral · All Rights Reserved ·