DEV Community

Cover image for My attempt to make you love Go ๐Ÿ˜Š - A quick introduction to Go
Oghenevwede Emeni
Oghenevwede Emeni

Posted on

My attempt to make you love Go ๐Ÿ˜Š - A quick introduction to Go

Go is a lovely language; it's quick and simple to learn, and it can make you cry now and then, but it's still a lovely language. I've been playing with Go for a few weeks and I'm completely smitten! But enough chit-chat for now; let's get this party started.

What is Go?

Go is an open-source programming language that was officially released by Google in 2012. It focuses on ease of use, reliability, accuracy, and concurrency. Go's biggest flex is its concurrent nature. Concurrency refers to the ability to perform multiple tasks at the same time. Server-side programming, game development, and cloud programming are all possible with Go.

Why do i love Go so much?

  • It's simple to learnย 
  • There's a lively communityย 
  • There's a lot of documentation
  • And you should if you enjoy your bank apps making cha-ching noises!

How do i get started with Go?

Go's website is a good place to start if you want to learn more about the language. It's really simple to use! Instructions for installing Go on your PC can be found at

Go Program structure

This article is aimed at complete beginners who are either getting started with Go or have recently started. We'll talk about the bare minimum structure of Go programs so that we can use it as a starting point for future tutorials.

Consider the following code, which prints the words "I am a beast!" โˆ’

package main
import "fmt"
func main() {
/* This is my first sample program. */
//I am trying to understand the basics of Go
   fmt.Println("I am a beast!")
Enter fullscreen mode Exit fullscreen mode

Let's analyze the code above -

  1. The first line, which contains "package main," is required and serves as the starting point for running programs.
  2. The "fmt" preprocessor command is imported next.ย This package allows you to format simple strings and print them, as well as collect user input from the console, write to a file using a writer, and even print error messages.
  3. The main() function is where the program execution starts. It's essentially a point where a program's first instructions are executed and where the program has access to command-line arguments. When you run a Go file, it looks for the main function and executes the code inside it first.
  4. The compiler ignores /.../ and //, which are used to add comments to the program. The purpose of comments is to explain what each part of a program is doing.
  5. Go has a function called println(...) that displays the message "I am a beast!" on the screen. The Println method is exported by the fmt package and is used to display the message on the screen.

Let's actually test the code above -

  • Make a file in your text editor. beast.go is what I'm going to call mine.
  • Copy and paste the code above, making sure to save it!
  • Go to your terminal and make sure you're in the same directory as your file, then type go run beast.go. (This is the command that will allow you to run your program!)
  • As long as there are no errors, this will print out "I am a beast!"
$ go run beast.go
I am a beast!
Enter fullscreen mode Exit fullscreen mode

Yup! You've completed your first Go program with flying colours. Remember that reading Go's documentation is a great way to learn the language. Until next time, take care!

Top comments (0)