top of page

First day at Go Programming School - Hello World

Updated: May 26, 2023

With the increase of adoption of Kubernetes by many companies in IT industry, there has been increase in demand of another programming language along with Python and that language is 'GO'.

Since 'Kubernetes' is entirely written in 'GO', that's why its a preferrable language when it comes to writing Kubernetes API and extending capabilities of Kubernetes.

I also came across a situation where I had to learn this language an year back and then I thought to write a series of few articles on Go to share my experience with this language.

Hence, if you're a beginner and want to get your hands dirty in GO, you can follow this series. I hope you will enjoy the journey and share your feedback that will really help me to stay motivated.

So, like any other programming language, my first day at Go Programming School spent learning how to print that boring line 'Hello World !'

You might be wondering why I didn't talk about installing basic softwares to setup development environment. Honestly speaking to learn basics you don't require to setup anything. If you have an internet connection then you can practice GO on [ Go Playground ]

So, our first program to print those magical words is as follow:

package main 

import "fmt"

func main() {
    fmt.Println("Hello World");

You can either copy-paste above program in Go playground & execute by clicking 'Run' button


Create a file with name main.go with above code and then:

Below commands compiles the code and produce a binary file which can be executed later on:
# go build main.go
# ./main

Output: Hello World


Below command directly run the go program and produce output:
# go run main.go

Output: Hello World

Let me explain the above program a bit:

  • package main : Go program run in packages and main is the starting point for go program. Hence. it's mandatory to define the package name.

  • import "fmt" : In this line, we are importing "fmt" package which includes predefined functions.

  • func main : This is the entry point of the Go program and all the statement that need to be executed must be declared inside this function. It is very similar to void main() in C language.

  • fmt.Println() : Package fmt include a function called Println() that helps us to print anything at output console, hence whatever we need to print at output console must be placed inside Println(<something>). Now you must have got an idea how 'Hello World' got printed at output.

That's all for this article. Have a good day !


Read More

Never miss an update

Thanks for submitting!

bottom of page