Skip to content

Go Overview

Go, often referred to as Golang, is an open-source, statically typed, compiled programming language designed at Google by Robert Griesemer, Rob Pike, and Ken Thompson. It was first announced in 2009 and reached version 1.0 in 2012.

Go is designed to be simple, efficient, reliable, and productive. It aims to combine the development speed of dynamic languages like Python with the performance and safety of compiled languages like C++ or Java. It’s particularly well-suited for systems programming, cloud computing, web development, command-line tools, and concurrency-heavy applications.

  • Simplicity and Readability: Go has a concise syntax with a small number of keywords, making it relatively easy to learn and read.
  • Concurrency: Built-in support for concurrent programming using lightweight goroutines and channels makes it easy to write programs that handle many tasks simultaneously.
  • Fast Compilation: The compiler is designed for speed, leading to quick build times.
  • Static Typing with Type Inference: Provides type safety at compile time, but often allows omitting explicit types thanks to type inference (e.g., x := 10).
  • Garbage Collection: Automatic memory management simplifies development by handling memory allocation and deallocation.
  • Rich Standard Library: Offers a comprehensive set of packages for common tasks like networking, I/O, string manipulation, and cryptography.
  • Excellent Tooling: Comes with powerful tools like go fmt (code formatting), go test (testing), go build (compiling), go doc (documentation), and module management.
  • Static Binaries: Produces statically linked executables by default, simplifying deployment as they contain all necessary dependencies.
  • Interfaces: Provides a flexible way to achieve polymorphism through implicit satisfaction of interfaces (structural typing).

Features Intentionally Excluded (Historically)

Section titled “Features Intentionally Excluded (Historically)”

To maintain simplicity, Go initially omitted several features found in other languages. Some of these have evolved over time:

  • No Traditional Inheritance: Go favors composition over inheritance, using struct embedding and interfaces.
  • No Method or Operator Overloading: Each function/method must have a unique name within its scope; operators cannot be redefined.
  • No Pointer Arithmetic (Direct): While pointers exist, direct manipulation of memory addresses like in C is discouraged and restricted (primarily available via the unsafe package).
  • No Implicit Type Conversions: Conversions between types must be explicit.
  • No Assertions: Error handling is primarily done through explicit error values.
  • No Circular Dependencies: Package dependencies must form a directed acyclic graph (DAG).
  • No Generic Programming: Update: Generics were added to Go in version 1.18 (released in 2022), allowing for type-parameterized functions and types. This was a significant addition based on community feedback.

Go source code is written in plain text files with the .go extension (e.g., myapp.go). Programs are organized into packages, which help manage code structure and dependencies. A typical project might consist of multiple .go files across several directories (packages).

This tutorial assumes you have a basic understanding of how to use a text editor to create and modify source code files.