Go: Hello world

I am following this youtube course link to learn Go programming and will document all the learning in this series of blog posts.

Go is a compiled language. We don't need JVM like in Java. It is similar to C/C++ in this aspect. You can generate compiled binary for all the platform (Linux, Windows, etc...).

We don't have Classes in Go. We don't have things like method overloading etc. It has structs that act similar to Classes, hence it is not a pure OOPs language like Java.

No try catch.

No switch case

etc...

There are a lot of things that are missing from the language but it does not mean that Go lags behind other languages. The entire mindset with Go is different.

Go has the file extension .go.

Command to initialize a module : go mod init <module-name>

It is similar to doing npm init -y in NodeJs.

It creates a go.mod file in the current directory which contains metadata information about the go module.

Hello World program in Go

package main
import "fmt"
func main(){
  fmt.Println("Hello World")  
}

To directly run the file without creating a binary: go run <filename>