Post
Available in: PortuguΓͺs

Go 1.26: Everything That Changed in the New Version

Hey everyone!

Go 1.26 arrived in February 2026, six months after Go 1.25. And it came with changes that will directly impact performance and the way you write Go code.

The main highlight is the new Green Tea garbage collector, now enabled by default. But there’s a lot more interesting stuff in this version.

Let’s see what really changed.

What you’ll find here

This version brings changes in four main areas:

  1. Language changes: more powerful new, more flexible generics
  2. New garbage collector: Green Tea GC by default
  3. Modernized tools: go fix completely rewritten
  4. Library improvements: various stdlib improvements

Each section covers what changed and the practical impact for your day-to-day work.

1. Language changes

new accepts expressions as operand

The built-in new function now allows its operand to be an expression, specifying the initial value of the variable.

This is especially useful when working with serialization packages like encoding/json or protocol buffers that use pointers to represent optional values:

1
2
3
4
5
6
7
8
9
10
11
type Person struct {
    Name string `json:"name"`
    Age  *int   `json:"age"` // age if known; nil otherwise
}

func personJSON(name string, born time.Time) ([]byte, error) {
    return json.Marshal(Person{
        Name: name,
        Age:  new(yearsSince(born)), // before, needed an auxiliary variable
    })
}

Before, you needed to create an auxiliary variable:

1
2
3
// Before Go 1.26
age := yearsSince(born)
person := Person{Name: name, Age: &age}

Now it’s much cleaner and more direct.

Generics: types can self-reference in parameter list

The restriction that a generic type may not refer to itself in its type parameter list has been lifted.

It’s now possible to specify type constraints that refer to the generic type being constrained:

1
2
3
4
5
6
7
type Adder[A Adder[A]] interface {
    Add(A) A
}

func algo[A Adder[A]](x, y A) A {
    return x.Add(y)
}

Previously, the self-reference to Adder on the first line was not allowed. This makes type constraints more powerful and simplifies the spec rules for type parameters.

2. New garbage collector: Green Tea GC

What is the Green Tea GC

The Green Tea garbage collector, previously available as an experiment in Go 1.25, is now enabled by default in Go 1.26.

This new GC improves the performance of marking and scanning small objects through better memory locality and CPU scalability.

Performance impact

Benchmark results vary, but the expectation is:

1
2
3
4
5
6
7
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Reduction in GC overhead               β”‚
β”‚                                         β”‚
β”‚  General:        10–40% less overhead   β”‚
β”‚  Modern CPUs:    +10% additional        β”‚
β”‚  (Intel Ice Lake / AMD Zen 4 or newer)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

On modern CPUs (Intel Ice Lake or AMD Zen 4 and newer), the GC leverages vector instructions for scanning small objects, adding ~10% more improvement.

How to disable (if needed)

If you encounter any performance or behavior issues, you can disable it:

1
GOEXPERIMENT=nogreenteagc go build .

Note: This opt-out setting will be removed in Go 1.27. If you need to disable it for any reason, please report the issue at github.com/golang/go.

Other runtime improvements

Faster cgo calls: The baseline runtime overhead of cgo calls has been reduced by ~30%.

Heap base address randomization: On 64-bit platforms, the runtime now randomizes the heap base address at startup. This is a security enhancement that makes it harder for attackers to predict memory addresses when using cgo.

Goroutine leak profile (experimental): A new profile type that reports leaked goroutines is now available as an experiment:

1
GOEXPERIMENT=goroutineleakprofile go build .

A β€œleaked” goroutine is one blocked on a concurrency primitive (channels, sync.Mutex, sync.Cond, etc.) that cannot be unblocked. The runtime detects this using the garbage collector.

3. Tools: go fix completely rewritten

The new go fix

go fix has been completely revamped and is now the home of Go’s modernizers. It provides a reliable, push-button way to update Go code bases to the latest idioms and core library APIs.

The initial suite of modernizers includes:

  • Dozens of fixers to use modern language and library features
  • A source-level inliner that allows automating API migrations using //go:fix inline directives
1
2
# Automatically modernizes your code
go fix ./...

Important: These fixers should not change the behavior of your program.

The new go fix is built on the same analysis framework as go vet. This means the same analyzers that provide diagnostics in go vet can be used to suggest and apply fixes in go fix.

Other tool changes

go mod init with lower version by default: Now creates go.mod with a previous version to encourage compatibility with supported versions:

1
2
Go 1.26 β†’ creates go.mod with go 1.25.0
Go 1.26 RC β†’ creates go.mod with go 1.24.0

cmd/doc removed: The go tool doc command has been removed. Use go doc as a direct replacement (same flags and behavior).

pprof with flame graph by default: The pprof web UI now shows the flame graph by default when using -http. The previous view is still available at β€œView β†’ Graph”.

4. Library improvements

log/slog: MultiHandler

New NewMultiHandler function that creates a handler invoking multiple handlers:

1
2
3
4
5
handler := slog.NewMultiHandler(
    slog.NewJSONHandler(os.Stdout, nil),
    slog.NewTextHandler(logFile, nil),
)
logger := slog.New(handler)

io: More efficient ReadAll

io.ReadAll now allocates less intermediate memory and returns a minimally sized slice:

  • ~2x faster
  • ~50% less memory allocated
  • More benefit for larger inputs

reflect: iterators for types and values

New methods that return iterators:

1
2
3
4
// Iterate over struct fields
for field, value := range reflect.ValueOf(myStruct).Fields() {
    fmt.Println(field.Name, value)
}

New methods: Type.Fields, Type.Methods, Type.Ins, Type.Outs, Value.Fields, Value.Methods.

net/http: HTTP/2 improvements

  • New HTTP2Config.StrictMaxConcurrentRequests field to control opening new connections when the HTTP/2 stream limit is reached
  • Client now uses cookies with correct scope for URLs with Request.Host

testing: artifact directory

New methods T.ArtifactDir, B.ArtifactDir and F.ArtifactDir for writing test output files:

1
go test -artifacts ./...

image/jpeg: faster encoder and decoder

The JPEG encoder and decoder have been replaced with new, faster, more accurate implementations.

Attention: Code that expects specific bit-for-bit outputs may need to be updated.

5. Platform changes

macOS

Go 1.26 is the last release that will run on macOS 12 Monterey. Go 1.27 will require macOS 13 Ventura or later.

Summary:

AreaChangeImpact
GCGreen Tea GC by default10–40% less overhead
Languagenew with expressionsCleaner code
LanguageGenerics self-referenceMore powerful constraints
Toolsgo fix rewrittenAutomatic code modernization
Runtimecgo ~30% fasterBetter C integration
ioReadAll 2x fasterLess allocations
macOSLast version with macOS 12Update to macOS 13+

How to update

1
2
3
4
5
6
# Download Go 1.26
go install golang.org/dl/go1.26@latest
go1.26 download

# Or via official site
# https://go.dev/dl/

After updating, run the new go fix to modernize your code:

1
go fix ./...

Conclusion

Go 1.26 is a solid release. The Green Tea GC by default is the most impactful change β€” you’ll notice the difference in applications that make heavy use of memory.

The language changes are small but useful. The rewritten go fix is a long-term bet to keep Go code bases modern.

Worth updating. And as always, Go 1’s compatibility promise guarantees your existing code will continue to work.

References and sources