# Go 1.26: new(expr), go fix Modernizers and Goroutine Leak Profiles

> What Go 1.26 changes for backend teams: new(expr) for optional fields, the rewritten go fix, the Green Tea GC default, and the experimental goroutine leak

Go 1.26 came out in February 2026, and it is a release that rewards a careful read of the notes. There is one small language change that removes a lot of boilerplate, a rebuilt `go fix` that can modernise a codebase mechanically, a garbage collector that is now on by default, and an experimental profile that finds leaked goroutines.

This article covers the four changes that matter most for backend services, shows how to try each one, and lists what to check before upgrading production. The details come from the [official Go 1.26 release notes](https://go.dev/doc/go1.26) and secondary write-ups. I could not run the examples on a Go 1.26 toolchain (the sandbox I wrote them in has Go 1.24), so treat the code as illustrative and confirm it on your own machine.

## Background: why this release is worth attention

Go releases are deliberately modest, so a version that touches the language, the GC and the tooling in one go stands out. None of the four changes below forces a rewrite. They are easy to adopt one at a time, and each one removes a specific source of friction in service code: awkward pointers to values, stale idioms, GC cost, and goroutines that never exit.

## new(expr): pointers to values without a helper

Before 1.26, `new` took only a type. If you wanted a pointer to a value, which is common for optional fields in JSON or protobuf-style structs, you either declared a temporary variable or wrote a generic helper that every project copied:

```go
func ptr[T any](v T) *T { return &v }

type Settings struct {
	Timeout *time.Duration `json:"timeout,omitempty"`
	Retries *int           `json:"retries,omitempty"`
}

s := Settings{
	Timeout: ptr(30 * time.Second),
	Retries: ptr(3),
}
```

In Go 1.26, the operand of `new` can be an expression, and that expression sets the initial value of the new variable:

```go
s := Settings{
	Timeout: new(30 * time.Second),
	Retries: new(3),
}
```

The helper disappears. The same form works for computed values, such as `new(time.Now())`, because the expression is evaluated once and the result is stored in the new variable.

Two practical notes. First, an untyped constant takes its default type, so `new(3)` is a `*int`; write `new(int64(3))` when you need a different type. Second, the result is a pointer to a fresh copy, exactly as with the old helper, so there is no aliasing surprise.

## go fix: modernizers you can run in CI

`go fix` has existed for a long time, but its old fixers were mostly relics of early Go. In 1.26 it was rewritten on the same analysis framework as `go vet` and now hosts a suite of *modernizers*. Their goal is to update code to newer idioms and library APIs without changing behaviour.

```sh
go fix ./...
```

Typical modernizations replace hand-written loops with newer standard-library helpers, or swap old patterns for features added in recent releases. Sources disagree on how many modernizers ship, so check `go help fix` and the release notes on your toolchain for the real list.

A safe way to adopt it:

1. Commit a clean tree on a branch.
2. Run `go fix ./...` and read the whole diff. The modernizers are meant to be behaviour-preserving, but review is cheap.
3. Run your tests and the race detector.
4. Merge the mechanical change as its own PR so it does not hide real changes.

Library authors also get something here. A `//go:fix inline` directive on a deprecated function lets `go fix` inline calls to it for your users, which turns an API migration into a one-command change.

## Green Tea GC is now the default

The Green Tea garbage collector was an experiment in Go 1.25. In 1.26 it is on by default. It can still be switched off with a build-time `GOEXPERIMENT` setting, and the release notes say that setting is expected to be removed in Go 1.27, so you have one release to compare behaviour if you hit a regression.

What this means for you:

- You do not need code changes. The collector is a runtime change.
- Measure before and after on your own workload. GC behaviour depends on heap shape and allocation rate, and I would not quote a general speed-up number for your service.
- Keep the opt-out in mind for the upgrade window only. Do not build a long-term plan on it.

Two smaller runtime changes are worth knowing. Baseline cgo call overhead dropped by about 30%, which helps services that call C libraries in hot paths. And on 64-bit platforms the runtime now randomises the heap base address at startup, which is a hardening change that should be invisible unless you depend on fixed addresses.

## Finding leaked goroutines

Goroutine leaks are the classic slow failure in Go services: memory and goroutine counts climb for days until something falls over. The usual cause is a goroutine blocked forever on a channel nobody will use again.

```go
func fetchFirst(ctx context.Context, urls []string) (string, error) {
	results := make(chan string) // unbuffered

	for _, u := range urls {
		go func() {
			body, err := fetch(ctx, u)
			if err == nil {
				results <- body // blocks forever if the caller already returned
			}
		}()
	}

	select {
	case r := <-results:
		return r, nil // early return: the other goroutines are now stuck
	case <-ctx.Done():
		return "", ctx.Err()
	}
}
```

Go 1.26 adds an experimental `goroutineleak` profile to `runtime/pprof`. It uses the garbage collector's reachability information: a goroutine that is blocked on a channel or mutex that no other live goroutine can reach is reported as leaked. You enable it at build time:

```sh
GOEXPERIMENT=goroutineleakprofile go build -o server ./cmd/server
```

With `net/http/pprof` imported, the profile is served at `/debug/pprof/goroutineleak`. The Go team has said it aims to enable it by default in 1.27.

Limitations to keep in mind:

- It only finds goroutines blocked on objects that are *unreachable*. A goroutine stuck on a global or otherwise reachable channel will not be flagged.
- It is experimental, so test it in staging before turning it on for production binaries.
- It complements, and does not replace, fixing the pattern. For the example above, the fix is a buffered channel sized to the number of senders, or a `select` on `ctx.Done()` in each sender.

```go
results := make(chan string, len(urls)) // senders can always finish
```

## Smaller changes to check

- **`go mod init`** now writes a `go` directive one minor version behind your toolchain. If your template or scripts assume the current version, adjust them.
- **`go tool doc` and `cmd/doc`** were removed. Use `go doc`, which takes the same flags.
- **pprof's web UI** now opens on the flame graph by default.
- **New experimental `secret` package** and new crypto KEM interfaces were added to the standard library. Treat the experimental package as unstable.

## Upgrade plan

1. Read the [release notes](https://go.dev/doc/go1.26) end to end, including the section on removed and changed behaviour.
2. Upgrade the toolchain in CI first and run the full test suite with `-race`.
3. Run `go fix ./...` as a separate, reviewable change.
4. Deploy to a canary and compare p99 latency, memory and GC time against the previous build.
5. Build one staging binary with `goroutineleakprofile` and exercise your slowest endpoints.
6. Roll out, and record any change in your dashboards for the next upgrade.

## Advantages and limitations

**Advantages**

- `new(expr)` removes a helper that nearly every codebase had.
- `go fix` makes idiom upgrades a tool task instead of a manual chore.
- The GC change and cgo improvement need no code changes.
- Leak detection moves from guesswork to a profile.

**Limitations**

- The leak profile is experimental and cannot see reachable-but-stuck goroutines.
- `new(expr)` needs 1.26 in `go.mod`, so libraries that support older Go versions cannot use it yet.
- The GC opt-out is temporary.

## Common mistakes

- Setting the `go` directive to 1.26 in a library, which forces every consumer to upgrade.
- Merging `go fix` output together with feature work.
- Treating a clean leak profile as proof there are no leaks.
- Comparing GC behaviour on a laptop instead of a production-like load.

## Conclusion

Go 1.26 is a low-risk upgrade with a few real wins. Adopt `new(expr)` where your minimum Go version allows it, run `go fix` as its own change, measure the new GC on your own traffic, and try the leak profile in staging. Verify each claim against the release notes for your exact patch version before you roll out.

## Frequently asked questions

### What is new in Go 1.26?

The main changes are `new` accepting an expression, a rewritten `go fix` with modernizers, the Green Tea garbage collector enabled by default, lower cgo call overhead, and an experimental goroutine leak profile.

### Does Go 1.26 need code changes?

No. Existing code should keep working. You choose whether to adopt `new(expr)` and run `go fix`.

### How do I enable the goroutine leak profile?

Build with `GOEXPERIMENT=goroutineleakprofile`, import `net/http/pprof`, and request `/debug/pprof/goroutineleak`. It is experimental in 1.26.

### Can I turn off the Green Tea GC?

Yes, with a build-time `GOEXPERIMENT` setting, but the release notes say it is expected to be removed in Go 1.27.

### Is `go fix` safe to run on a whole repository?

It is designed to preserve behaviour, but you should review the diff and run your tests, as with any automated change.

## References and further reading

- [Go 1.26 release notes](https://go.dev/doc/go1.26), the primary source for every change above.
- [The Go blog](https://go.dev/blog/), for design write-ups on the GC and the modernizers.
- [runtime/pprof package documentation](https://pkg.go.dev/runtime/pprof), for profile types.

If you are planning a Go upgrade or chasing a memory problem in a production service, see my [backend and API development](/services/backend-api-development/) and [cloud and DevOps](/services/cloud-devops/) services, or [tell me about your project](/contact/).

---

HTML version: https://fullstackweb.dev/blog/go-1-26-new-expr-go-fix-goroutine-leaks/
Maintained by Hendra Nicholas, Senior Full-Stack Software Engineer & AI Engineer, hello@fullstackweb.dev.
