Go release 1.18

Introduction to Go 1.18

Significant release with changes to language, toolchain, runtime, and libraries.

Changes to the language

  • Introduction of generics with type parameters.
  • New syntax for function and type declarations.
  • Parameterized functions and types.
  • New 'any' and 'comparable' predeclared identifiers.

Mandatory to understand for writing and deploying generic code.

Bug fixes

  • Compiler now correctly reports 'declared but not used' errors.
  • Reports overflow for rune constants in certain cases.

Ports

  • New GOAMD64 environment variable.
  • Support for 64-bit RISC-V architecture on Linux.
  • Linux kernel version 2.6.32 or later required.
  • Non-cooperative preemption support for Windows ARM and ARM64.
  • iOS 12 or later required.

Tools

  • Implementation of fuzzing.
  • Changes to 'go get', 'go mod', 'go version', 'go work', 'go build', and 'go test'.
  • Removal of +build lines in favor of //go:build lines.

Runtime

  • Garbage collector changes for predictable overhead.
  • Efficient memory return to the operating system.
  • Improved formatting of stack trace arguments.

Compiler

  • Passing function arguments and results using registers on more platforms.
  • Inlining functions with range loops.
  • New -asan compiler option.
  • Possible 15% slower compile speed due to changes for generics.

Significant impact on performance and error messages.

Linker

  • Fewer relocations for faster linking and smaller binaries.
  • New -asan linker option.

Bootstrap

Go 1.17 or later preferred for bootstrapping.

Core library

  • New debug/buildinfo package.
  • New net/netip package.
  • TLS 1.2 default for client connections.
  • Rejecting SHA-1 certificates.
  • Various minor updates and performance improvements.