DEV Community

Piyush Goyani
Piyush Goyani

Posted on • Originally published at on

Preliminary Go Language for Beginners

Go is the programming language that was Invented and backed by Google and is now used by many companies and programmers worldwide.

There aren't any use-case limitations with Go to build something as you can build anything with it, But it's mostly used for CLI Tooling, Network Services and APIs, Web applications and DevOps.

The Go Language is known for the following features:

  • Performance
  • Built-in Concurrency Support
  • Safety
  • Garbage Collection
  • Scalability
  • Portability / Cross Platform
  • Binary Generation
  • Standard Library and Package Management
  • Built-in Testing Support

The language is not intended for replacement of any other languages like C, C++, Python, Rust or any other as these languages have their own beauty and places in the market and people who adopted them for a long time.

Let's dive into installation and Basic Go Code.


Download Go

Download the Go archive from official site as per your choice. Here, I'm using Linux so the rest steps are accordingly.

Go to the downloaded directory and run this command from the terminal.

sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.19.2.linux-amd64.tar.gz

Enter fullscreen mode Exit fullscreen mode

This will remove the old installation of Go and extract the downloaded version to the /usr/local directory.


Edit .bashrc file and sudo nano .bashrcadd PATH and save.export PATH=$PATH:/usr/local/go/bin

Check the installed version of GO with the following command.

go version
// go version go1.19.2 linux/amd64

Enter fullscreen mode Exit fullscreen mode


Create a demo project directory and go inside the directory.

mkdir demo && cd demo

Enter fullscreen mode Exit fullscreen mode

Run the below command to enable Dependency tracking in your project.

go mod init example/demo

Enter fullscreen mode Exit fullscreen mode

This will create a file named go.mod with the below content.

module example/demo

go 1.19

Enter fullscreen mode Exit fullscreen mode

This file is generally used to manage internal and external dependencies, which stay within the project.

Create init.go file with your favourite text editor,

nano init.go

Enter fullscreen mode Exit fullscreen mode

and paste the below code and save.

package main

import "fmt"

func main() {
    fmt.Println("First program of GoLang!")

Enter fullscreen mode Exit fullscreen mode


package main : It declares the main package, which may contain all sub-functionality within the same directory linked to this file.

import "fmt" : Importing fmt, one of the standard library packages of Go, which contains functionality for console output and text formatting.

func main(): Defining main() function, which by default called first when program get executed, similar like main in C/C++.

Running Go Code

To run the Go program execute the below command in the terminal and see Output.

go run .
// First program of GoLang!

Enter fullscreen mode Exit fullscreen mode


I hope you enjoyed this article. Stay tuned and subscribe for more Go Language posts and other useful tutorials.

Oldest comments (0)

🌚 Friends don't let friends browse without dark mode.

Sorry, it's true.