“How many people are using the 2 latest releases of Go?”
“It is intended that programs written to the Go 1 specification will continue to compile and run correctly, unchanged, over the lifetime of that specification.”
Runtime and compiler improvements.
More features in the standard libraries.
Bugs and Security patches.
New language features and tooling.
func (r *Rand) Int32N(n int32) int32
func (r *Rand) Int64N(n int64) int64
func (r *Rand) IntN(n int) int
// ...repeated per integer type
type intType interface {
~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint |
~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
func (r *Rand) N[Int intType](n Int) Int
type Foo interface {
Bar[T any](v T) T // not allowed
}
type Foo interface {
Bar(v int) int
}
type FooImpl struct{}
func (FooImpl) Bar[T any](v T) T { return v }
var _ Foo = FooImpl{} // doesn't compile
type Habitat struct {
Burrow string
}
type Gopher struct {
Name string
Habitat
}
// before
g := Gopher{
Name: "Gopher",
Habitat: Habitat{Burrow: "Burrow #42"},
}
// after
g := Gopher{
Name: "Gopher",
Burrow: "Burrow #42",
}
type Identity struct { Age int }
type Gopher struct {
Name string // I want to move this
Identity
}
g := Gopher{
Name: "Gopher",
Identity: Identity{
Age: 13,
},
}
g := Gopher{Name: "Gopher", Age: 13}
type Identity struct {
Age int
Name string // Moved
}
type Gopher struct { Identity }
g := Gopher{
Identity: Identity{
Name: "Gopher", // have to move the field everywhere
Age: 13,
},
}
g := Gopher{Name: "Gopher", Age: 13}
encoding/json/v2 package which can be imported separatelyencoding/json (v1) now runs on the v2 engine internally, unchanged behaviourencoding/json/v2Deterministic optionimport "encoding/json"
m := map[string]int{"z": 1, "a": 2}
json.Marshal(m)
// {"a":2,"z":1}
import "encoding/json/v2"
m := map[string]int{"z": 1, "a": 2}
json.Marshal(m)
// {"z":1,"a":2} (unsorted)
json.Marshal(m, json.Deterministic(true))
// {"a":2,"z":1} (opt back in)
RejectUnknownMembers// duplicate key
{
"Name": "a",
"Name": "b"
}
// invalid UTF-8
{
"Name": "\xff\xfe"
}
// wrong case
{
"name": "a"
}
// opt in: json.RejectUnknownMembers(true)
nil slices/maps used to marshal to null[] / {} insteadimport "encoding/json"
type T struct {
Items []int
Meta map[string]int
}
json.Marshal(T{})
// {"Items":null,"Meta":null}
import "encoding/json/v2"
type T struct {
Items []int
Meta map[string]int
}
json.Marshal(T{})
// {"Items":[],"Meta":{}}
uuid package (RFC 9562)id := uuid.NewV4()
// 3f29a1d2-6b7e-4c1a-9f3d-8e2b7a4c5d6f
id := uuid.NewV7()
// 018f4d2a-7b3c-7e21-9f4a-1234567890ab
id := uuid.NewV4()
id = uuid.NewV7()
id, err := uuid.Parse(s)
id.String()
simd/archsimd (Go 1.26)GOEXPERIMENT=simdvar a, b archsimd.Int32x8 // AVX2, 8 lanes
a = archsimd.LoadInt32x8(s1) // load 8 int32s
b = archsimd.LoadInt32x8(s2) // load 8 int32s
a.Add(b).Store(dst) // add + store
a := simd.LoadInt32s(s1) // width inferred
b := simd.LoadInt32s(s2)
a.Add(b).Store(dst) // add + store
crypto/mldsa package implementing ML-DSAcrypto/x509, crypto/tls also implement ML-DSApriv, _ := mldsa.GenerateKey(mldsa.MLDSA65())
pub := priv.PublicKey()
opts := &mldsa.Options{}
sig, _ := priv.Sign(nil, message, opts)
err := mldsa.Verify(pub, message, sig, opts)
CutLast in bytes and stringsi := bytes.LastIndex(s, sep)
before, after := s[:i], s[i+len(sep):]
before, after, found := bytes.CutLast(s, sep)
before, after, _ := bytes.CutLast(s, []byte("."))
// "archive.tar.gz" ->
// before="archive.tar", after="gz"
dir, file, _ := bytes.CutLast(s, []byte("/"))
// "/var/log/app.log" ->
// dir="/var/log", file="app.log"
See the complete release notes
https://go.dev/doc/go1.27