/golang

experiments with go

Primary LanguageGo

Golang

A self paced learning project for teaching Golang

Installing go

You can install golang by following the official doc: https://go.dev/learn/

Official Go Documentation

The official golang documentation can be found at: https://go.dev/doc/

Running a Go program

There are 2 ways to run a go program, the first one is long way:

  1. In order to run a go program the first thing you need to do is compile it :
$ go build file_name.go

This will create a binary file that you can run as follows:

$ ./file_name
  1. The second one is the short way of doing the same thing above using the go run command which abstracts the compilation step :
$ go run file_name.go

Background of Golang

  • Go was originally created by Robert Griesemar, Rob Pike & Ken Thompson at Google.
  • Why Have GO ?
    • Python : Easy to use but slow as its interprted language
    • Jave : Quick but the type system is very complex
    • C/C++ : Quick , but type system is complex and takes a lot of time to compile code.
    • Concurrancy is later patched in the above language.
  • Go is Strongly typed language.
  • Go is also a statically typed language.
    • A language is statically typed if the type of a variable is known at compile time.
    • Statically typed programming languages do type checking (i.e. the process of verifying and enforcing the constraints of types) at compile-time as opposed to run-time. Ex: Java, C, C++
    • Dynamically typed programming languages do type checking at run-time as opposed to compile-time. Ex: Perl, Ruby, Python, PHP, JavaScript
  • GO Key Features: