Go 1 (2012-03-28)
Go 1 is the first formal stable release of the Go language, released on March 28, 2012. It marks the maturity of the Go language and brings an extremely important compatibility promise as well as a unified toolchain experience.
Major Changes
Language
runeType: Introducedruneas an alias forint32, used to represent Unicode code points.errorInterface: Introduced the built-inerrorinterface type, replacing the previousos.Error, forming a unified error handling contract.appendSupports Strings:appendcan now directly append strings to[]byteslices, simplifying byte sequence operations.deleteBuilt-in Function: Provideddelete(m, k)for deleting elements from a map.- Structs and Arrays Comparable: They now support
==/!=and can be used as map keys, improving data structure composition capabilities. - Composite Literal Simplification: Pointer type elements in composite literals can omit type declarations.
- Map Iteration Order: Explicitly defined as random order, encouraging robust traversal logic.
closeCheck: Prohibited closing receive-only channels to avoid runtime panics.
Toolchain
goCommand: A unified command-line tool integrating functions likeget/build/install/test/doc, automatically handling dependencies based on source code imports, relying on theGOPATHstructure (src/pkg/bin).cgo: Strengthened C language interoperability support, improving system call usability.go fix: Includes a migration tool to automatically convert old version code to the Go 1 specification.gofmt: Further standardized code style, becoming an indispensable formatting solution in the Go ecosystem.
Runtime
- Compatibility Promise: Besides introducing language and tool changes, the core of Go 1 is the compatibility guarantee for the Go 1.x lifecycle: as long as the code complies with the Go 1 specification, it will continue to compile and run, with very few exceptions not affecting mainstream application stability.
Standard Library
- Package Path Reorganization: Multiple packages migrated to form a more reasonable hierarchy:
http→net/http,template→text/template,exec→os/exec,utf8→unicode/utf8. os.ErrorRemoval: Replaced by theerrorinterface and theerrorspackage.syscallErrors: Unified to return theerrorinterface.timePackage Rewrite: Introducedtime.Timeandtime.Duration, providing nanosecond precision.os.FileInfoBecomes Interface: Abstracted file information access methods, increasing extensibility.regexpPackage Rewrite: Adopted RE2 syntax, ensuring linear time execution.
References
For more details, please refer to the official release notes: Go 1 Release Notes