Go - Overview


Advertisements


Go is a general-purpose language designed with systems programming in mind. It was initially developed at Google in the year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is strongly and statically typed, provides inbuilt support for garbage collection, and supports concurrent programming.

Programs are constructed using packages, for efficient management of dependencies. Go programming implementations use a traditional compile and link model to generate executable binaries. The Go programming language was announced in November 2009 and is used in some of the Google's production systems.

Features of Go Programming

The most important features of Go programming are listed below −

  • Support for environment adopting patterns similar to dynamic languages. For example, type inference (x := 0 is valid declaration of a variable x of type int)

  • Compilation time is fast.

  • Inbuilt concurrency support: lightweight processes (via go routines), channels, select statement.

  • Go programs are simple, concise, and safe.

  • Support for Interfaces and Type embedding.

  • Production of statically linked native binaries without external dependencies.

Features Excluded Intentionally

To keep the language simple and concise, the following features commonly available in other similar languages are omitted in Go −

  • Support for type inheritance

  • Support for method or operator overloading

  • Support for circular dependencies among packages

  • Support for pointer arithmetic

  • Support for assertions

  • Support for generic programming

Go Programs

A Go program can vary in length from 3 lines to millions of lines and it should be written into one or more text files with the extension ".go". For example, hello.go.

You can use "vi", "vim" or any other text editor to write your Go program into a file.

Compiling and Executing Go Programs

For most of the examples given in this tutorial, you will find a Try it option, so just make use of it and enjoy your learning.

Try the following example using the Try it option available at the top right corner of the following sample code −

package main

import "fmt"

func main() {
   fmt.Println("Hello, World!")
}


Advertisements