The Go programming language, also known as golang, is an open source project created by Robert Griesemer, Rob Pike, and Ken Thompson in 2007 and sponsored by Google as an intended to resolve common criticisms of other languages while maintaining their positive characteristics.
It’s heavily based on C, but designed to be more concise and secure. Go has become increasingly popular for seasoned developers and new programmers alike,
used in many open source and commercial software applications.
Some notable companies using Go within their applications include Google, Dropbox, CloudOS, MongoDB, Docker and Uber.
Go is a statically typed, compiled, garbage-collected, concurrent general purpose programming language. Go is considered as an object oriented programming language and it uses object composition instead of class inheritance.
Go was based on several languages besides C: Pascal, Modula, Oberon, Newsqueak, and Limbo.
It is a traditionally compiled, object oriented, functional language that features static typing, garbage collection, concurrency, memory safety, and high readability.
Some of the major advantages of Go include:
Since a standard definition does not exist, let’s use this one, “An object is an abstract data type that has state (data) and behaviour (code)”.
Go doesn’t have something like `object`, even though it does have a type that matches the same definition of a data structure that integrates both code and behaviour.
In Go this is called a ‘struct’.
With struct we define a new data type containing the name of fields (attributes) that will keep the “state” of the object. To implement the behaviour of this object in Go,
we use functions bound to a pointer of this struct. Here’s an example to illustrate it:
Instead of inheritance Go strictly follows the composition over inheritance principle. Go accomplishes this through both subtyping (is-a) and object composition (has-a) relationships between structs and interfaces.
The mechanism Go uses to implement the principle of object composition is called embedded types. This way we have a field that is a subtype of other object, but this filed remains in a different entity.
Because of that Go provides two alternatives, “Pseudo sub typing” and “True sub typing”.
We accomplish this pseudo is-a relationship in go using what is called an Anonymous field.
Over the next posts I will bring you a more detailed explanation about this concepts while introduce you data types and language characteristics with some examples on each topic.