Go Overview
Go overview
Go is an open-source programming language announced by Google in 2009. It combines the benefits of statically typed languages with a concise development experience.
Before Go, Google commonly used languages such as C++ and Java for server software. Developers who prioritized convenience often chose dynamically typed interpreted languages such as Python and JavaScript. Go was created to provide efficient compilation and execution while keeping programs simple to write.
Go actively reduces unnecessary complexity. It does not need header files, and declarations are written once. It has no class hierarchy, exceptions, assertion statements, or overloading. Generics have been supported since Go 1.18.
Go is now widely used. Docker and Kubernetes are notable examples of software implemented in Go.
Major features
- Formatting: Run
gofmtorgo fmtto format code automatically. - Comments: Use
/* */for block comments and//for line comments. - Naming: Package names are usually single lowercase words. Identifiers that start with an uppercase letter are exported outside the package.
- Semicolons: Semicolons at the end of statements are usually omitted.
- Control flow:
:=declares variables without an explicit type. Conditions forifandfordo not need parentheses. Go usesforinstead of separatewhileanddo-whilestatements. Aswitchcase does not needbreakby default. - Functions: Functions can return multiple values. A
deferstatement schedules cleanup work such as unlocking a mutex or closing a file. - Data: Use
newfor zero-valued storage andmakefor slices, maps, and channels. Constructor-style functions conventionally start withNew. - Initialization: An
initfunction can validate or prepare package state before the program starts. - Methods: Go has no classes, but methods can be defined on types by using receiver parameters.
- Interfaces: Types satisfy interfaces implicitly. An interface parameter makes code less dependent on a concrete type.
- Blank identifier: Use
_when a value intentionally does not need to be used. - Embedding: A struct can embed another struct or interfaces instead of using class inheritance.
- Concurrency: Start asynchronous work with goroutines and communicate through channels. Use
selectto handle channel operations. - Errors: Functions commonly return an
errorvalue.panicandrecoverare available for exceptional situations.
Supported environments
The official download page provides installers and archives for operating system and architecture combinations. Support changes between Go releases, so check the Go downloads page and minimum requirements before installing.
| OS | Architectures | Notes |
|---|---|---|
| Linux | Various | Go 1.24 and later require Linux kernel 3.2 or later. |
| macOS | x86_64, ARM64 | Go 1.26 requires macOS 12 Monterey or later. |
| Windows | x86, x86_64, ARM64 | Go 1.21 and later require Windows 10 or Windows Server 2016 or later. |
| Other operating systems | Varies | Check the official documentation for FreeBSD, OpenBSD, and other ports. |
Related open-source languages
Go draws ideas from several language families:
- C family for basic syntax
- Pascal, Modula, and Oberon families for declarations and packages
- Newsqueak and Limbo for concurrency
License
Go is distributed under a BSD-style license. Modification and distribution are allowed when the copyright and license notices are preserved and the lack of warranty is stated.