Proposals Unofficial Go proposal tracker

Go 1.28 in development

25 proposals implemented in Go 1.28 so far.

Allow composite literals without an explicit type

#12854 · spec · high impact · Implemented in Go 1.28 ·

Go lets you omit the type of a composite literal only in a few places, such as elements nested inside a slice or map literal. Everywhere else you must spell out the type, even when the compiler already knows it. This is verbose with long type names like generated protobuf types, and it rules out anonymous struct types for things like function arguments.

The proposal makes the type in a composite literal optional. An untyped literal {...} is assignable to a type T if T{...} with the same elements would be a valid composite literal of type T. Pointer types are handled the same way. The literal has no default type, so x := {1, 2, 3} is an error. This replaces the spec's special rules for eliding element types.

var m map[string]int = {"a": 1}

type Args struct{ A, B, C int }
func Foo(args Args) { ... }
Foo({A: 1, B: 2, C: 3})

return {}, err // instead of time.Time{}, err

p.Options = append(p.Options, {...}) // type inferred from the slice

Report missing Err calls after bufio.Scanner and sql.Rows loops

#17747 · cmd/vet · medium impact · Implemented in Go 1.28 ·

Code that loops over a bufio.Scanner or sql.Rows often forgets to call Err() afterward. The loop then ends silently on an I/O or database error, and the program treats partial results as complete.

A new vet check reports uses of bufio.Scanner where Err() is never called. It skips scanners whose underlying reader cannot fail, such as bytes.Buffer or strings.Reader. A similar analyzer reports missing Err() calls on sql.Rows. Both analyzers run in gopls and are part of the default go vet suite.

s := bufio.NewScanner(f)
for s.Scan() {
    process(s.Text())
}
// vet: s.Err() is never checked
if err := s.Err(); err != nil { // add this
    return err
}

Add flag iterators

#65675 · flag · medium impact · Implemented in Go 1.28 ·

The flag package lets you walk flags only with Visit (set flags) and VisitAll (all flags). Both take callbacks that can't stop early, so they don't fit Go's range-over-func iterators.

The proposal adds a package-level All function and a FlagSet.All method. Both return an iter.Seq[*Flag] that yields flags in lexicographical order. Instead of a separate iterator for set flags, the Flag struct gets a new IsSet field that reports whether the flag was set on the command line.

for f := range flag.All() {
    if f.IsSet {
        fmt.Printf("%s = %s\n", f.Name, f.Value)
    }
}

Add Grow to presize an existing map

#81698 · maps · medium impact · Implemented in Go 1.28 ·

Go code can presize a new map with make(M, hint), but a map that already exists grows one rehash at a time. Code that merges many entries into a map it doesn't own pays for every intermediate grow. Examples include copying headers into ResponseWriter.Header(). Presizing before a copy measured 53–65% faster.

The new maps.Grow function grows an existing map in place so that at least n more entries fit without further growth, as if the map had been created with make(M, len(m)+n). This is best effort: it cannot guarantee that no more growth will happen.

func Grow[M ~map[K]V, K comparable, V any](m M, n int)

maps.Grow(dst, len(src))
for k, v := range src {
	dst[k] = v
}

maps.Copy(dst, src) will also pre-grow dst to fit len(src) new entries, so existing callers of Copy get the speedup without code changes.

Add text marshaling to HardwareAddr and IPMask

#29678 · net · medium impact · Implemented in Go 1.28 ·

net.HardwareAddr and net.IPMask are byte slices without text marshaling methods. Because of this, encoding/json encodes them as base64 and can't decode readable strings like "ab:cd:ef:ab:cd:ef". net.IP already marshals to readable text, so this behavior is inconsistent.

The proposal adds MarshalText and UnmarshalText methods to HardwareAddr and IPMask. UnmarshalText accepts both the old base64 form and the readable form, whatever the setting. MarshalText produces the readable form only when GODEBUG=netmarshal=1 is set. HardwareAddr uses its String output. IPMask is formatted as an IP address, such as 255.255.255.0, because IPMask.String output can look like base64. At first, netmarshal defaults to off, so the output stays base64. At least two releases later, the default flips to readable output. IPNet is not included.

var v struct{ MAC net.HardwareAddr }
json.Unmarshal([]byte(`{"MAC":"ab:cd:ef:ab:cd:ef"}`), &v) // now works

Add MustParse function that panics on invalid URLs

#79946 · net/url · medium impact · Implemented in Go 1.28 ·

Many programs parse URLs that are known to be valid, such as constants in code or test fixtures. Today they must handle an error that never happens, or write their own mustParse helper (which they often do).

The proposal adds url.MustParse, which works like url.Parse but panics if parsing fails. It follows the pattern of regexp.MustCompile and netip.MustParseAddr. It is meant for package-level variables and tests.

var apiBase = url.MustParse("https://api.example.com/v1/")

func endpoint(path string) *url.URL {
    return apiBase.JoinPath(path)
}

Add iterator versions of regexp FindAll methods and Split

#61902 · regexp · medium impact · Implemented in Go 1.28 ·

Regexp's FindAll* methods collect every match into a slice, even when the caller only wants to loop over the matches or stop early. This proposal adds iterator versions that return matches one at a time, without building the slice.

Each FindAll* method gets an equivalent named by dropping the Find prefix: All, AllIndex, AllString, AllSubmatch, etc. Each returns an iter.Seq of the type the matching non-All method returns. For example, AllString returns iter.Seq[string] and AllStringSubmatch returns iter.Seq[[]string]. A new SplitSeq method mirrors Split, the same way strings.SplitSeq mirrors strings.Split.

re := regexp.MustCompile(`\d+`)
for m := range re.AllString("a1 b22 c333") {
    fmt.Println(m) // 1, 22, 333
}

for part := range re.SplitSeq("a1b22c") {
    fmt.Println(part) // a, b, c
}

Add a memory profile type

#79179 · runtime/pprof · medium impact · Implemented in Go 1.28 ·

Developers investigating memory usage usually start with process RSS and then look at the heap profile. The live heap often covers less than half of a Go program's memory. It leaves out dead (unreachable but not yet swept) heap objects, goroutine and thread stacks, runtime metadata, and non-Go memory such as cgo allocations and mmap regions. Users today must reconcile RSS, runtime metrics, and the heap profile by hand.

The new memory profile type in runtime/pprof gives one consistent breakdown, taken at the most recent GC mark termination. A "Go Memory" frame splits into heap (live and dead, both with allocation stack traces), stacks (goroutines and OS threads), and runtime overhead (span and mcache metadata, GC metadata, profiling buckets, and other). Its total equals /memory/classes/total:bytes minus /memory/classes/heap/released:bytes.

pprof.Lookup("memory").WriteTo(f, 0)

When the OS reports RSS and RSS is at least Go Memory, the profile adds a "Non-Go Memory" frame equal to RSS minus Go Memory. Otherwise it omits that frame and adds a warning comment to the profile.

Restrict integer-to-string conversions to byte and rune

#3939 · spec · medium impact · Implemented in Go 1.28 ·

Go lets you convert any integer to a string, producing the UTF-8 encoding of that code point. This is a historical leftover. It confuses readers, who often expect string(65) to produce "65" rather than "A". Invalid code points such as 0xD800 silently become "\uFFFD". go vet has flagged these conversions for years.

Starting with language version 1.28, a conversion from an integer to a string will be allowed only if the integer has type byte or rune, or is an untyped rune constant. Converting other integer types, such as int, int64 or uint32, becomes a compile error. Byte and rune slice conversions are unchanged.

var i int = 65
s := string(i)        // error in Go 1.28
s = string(rune(i))   // OK: "A"
s = strconv.Itoa(i)   // OK: "65"
s = string('A')       // OK: untyped rune constant

Add sharded Counter type for scalable concurrent counting

#80645 · sync · medium impact · Implemented in Go 1.28 ·

A single atomic counter becomes a bottleneck on machines with many CPUs, because every update fights over the same cache line. The new generic sync.Counter type splits the counter into per-CPU shards (one per P, up to GOMAXPROCS). It is meant for counters that are updated often and read rarely.

Concurrent Add calls update only their local shard, so writes stay fast under heavy contention. Value sums all shards, so its cost grows with GOMAXPROCS. It is race-free, but while writers are active it returns an approximate total, not a consistent snapshot. Add does not create a happens-before relationship, so don't use it for synchronization. Overflow wraps around. If GOMAXPROCS shrinks, existing shards are kept, so no counts are lost.

var requests sync.Counter[int64]

func handle() {
    requests.Add(1) // fast, even from many goroutines
}

func report() {
    fmt.Println(requests.Value()) // slower; approximate under concurrent writes
}

The type parameter accepts ~int64, ~uint64, and ~float64.

Add Subtest to run a subtest in a synctest bubble

#77320 · testing/synctest · medium impact · Implemented in Go 1.28 ·

Tests that use synctest often run each case as a subtest inside a bubble. That means nesting synctest.Test inside t.Run, which adds an extra level of indentation on top of the table-driven loop. Some developers write their own helper to avoid this.

The new synctest.Subtest function runs f in a bubble as a subtest of t named name. It is equivalent to calling t.Run with a function that calls synctest.Test.

for _, test := range tests {
    synctest.Subtest(t, test.name, func(t *testing.T) {
        // test body runs in a synctest bubble
    })
}

Stop converting plain quotes to smart quotes in doc comments

#76975 · cmd/gofmt · low impact · Implemented in Go 1.28 ·

Since Go 1.19, gofmt rewrites doc comments so that a pair of backquotes (``) becomes a left smart quote (“) and a pair of single quotes ('') becomes a right smart quote (”). This silently changes comment text into characters that are hard to type and easy to confuse with the originals. It also breaks code examples that use these characters and makes the original text impossible to find by searching.

The change removes smart-quote conversion entirely. go/format (and so gofmt and go fmt) will no longer insert smart quotes into source files. go/doc (and so go doc and pkgsite) will also stop converting plain quotes when rendering documentation, so the two stay consistent.

Deprecate the unused ImportDirectory type

#81594 · debug/pe · low impact · Implemented in Go 1.28 ·

The debug/pe.ImportDirectory type will be marked deprecated. It was added about 15 years ago, but no function or field in the package ever returns or accepts it, so it has never been usable.

The type stays in the package for compatibility. A // Deprecated: comment will tell tools and linters to flag any remaining uses. No functionality is removed.

Move analysis framework types into the standard library

#82465 · go/analysis · low impact · Implemented in Go 1.28 ·

The analysis framework, golang.org/x/tools/go/analysis, defines how analyzers (linters) talk to drivers like cmd/vet. The Go toolchain uses a vendored copy of it, and the copy's types are distinct from the x/tools ones. This blocks proposal 82464, which lets go test run the analyzers specified by the workspace. To do that, go test must build vet-like tools that link with third-party analyzers, and those analyzers are written against the x/tools types.

The proposal moves the framework's types, unchanged, into a new standard library package, go/analysis. The x/tools types become aliases of them, so the toolchain and x/tools share the same types, and existing analyzers keep working as is. The API is not redesigned: the move is the only change.

import "go/analysis"

var Analyzer = &analysis.Analyzer{
	Name: "mycheck",
	Doc:  "reports something",
	Run: func(pass *analysis.Pass) (any, error) {
		pass.Reportf(pass.Files[0].Pos(), "found it")
		return nil, nil
	},
}

The package and the aliases will first ship behind a GOEXPERIMENT flag.

Deprecate ArchChar

#75129 · go/build · low impact · Implemented in Go 1.28 ·

go/build.ArchChar once returned the single-character code for an architecture (such as 6 for amd64), which the old toolchain used in tool names like 6g. Since Go 1.5, the toolchain no longer uses these codes. The function now always returns an error, whatever the architecture.

The proposal marks ArchChar as deprecated so that linters and editors warn about it. It has no replacement, and new code should not call it.

// Deprecated: Since Go 1.5 ArchChar always returns an error.
func ArchChar(goarch string) (string, error)

Add deprecated ResolveFile to apply object resolution after parsing

#79802 · go/parser · low impact · Implemented in Go 1.28 ·

Legacy object resolution in go/parser is deprecated. It fills Ident.Obj and File.Scope and is skipped with the SkipObjectResolution mode flag. Some tools still need it occasionally, though. For example, gopls parses without resolution for speed, but must still resolve files before passing them to analyzers. To do that, it keeps its own copy of the parser's resolution algorithm.

The new deprecated function parser.ResolveFile exposes the parser's internal algorithm. It applies resolution to an already parsed file. It is idempotent: calling it more than once is safe, and a sync.Once inside ast.File guards the work.

f, err := parser.ParseFile(fset, "x.go", src, parser.SkipObjectResolution)
// ...later, only when needed:
parser.ResolveFile(f) // fills f.Scope and Ident.Obj

New code should use go/types instead. The function exists to ease migration for programs that disable resolution by default.

Add CommonUnderlying function to report a type's shared underlying type

#60994 · go/types · low impact · Implemented in Go 1.28 ·

Tools built on go/types often need the single underlying type shared by every type in a type parameter's type set. This concept was called the core type. go/types computes it internally but does not export it, so x/tools and other projects have each reimplemented the logic.

The proposal adds an exported function, CommonUnderlying, that returns the common underlying type of a type. For an ordinary type, the result is its underlying type. For a type parameter, the result is the underlying type shared by all types in its type set. If no such type exists, the function returns nil.

// T is a type parameter constrained by ~[]int | MySlice
if u := types.CommonUnderlying(T); u != nil {
    if s, ok := u.(*types.Slice); ok {
        fmt.Println("element type:", s.Elem())
    }
}

Add StrictlyComparable function

#72059 · go/types · low impact · Implemented in Go 1.28 ·

Go has two notions of comparability. A type is comparable if == compiles for it, even if it might panic at run time, as with interfaces. A type is strictly comparable if == never panics. Only strictly comparable types satisfy the comparable constraint in all cases.

An exported type can lose strict comparability without any visible API change, for example by gaining an interface field. That can break callers that use it as a type argument for comparable. go/types exposes Comparable but has no way to check strict comparability, so API-checking tools cannot detect such changes.

The proposal adds types.StrictlyComparable, which reports whether values of a type are strictly comparable as defined by the spec.

func StrictlyComparable(T Type) bool

// Example: a struct with an interface field is comparable but not strictly comparable.
if types.Comparable(t) && !types.StrictlyComparable(t) {
    fmt.Println("== may panic at run time")
}

Add NewTypeParamList and NewTypeList constructors

#79603 · go/types · low impact · Implemented in Go 1.28 ·

Code that works with generic methods sometimes needs to treat the receiver's and the method's type parameters as one list. go/types has no exported way to build a *TypeParamList or *TypeList. Tools like the compiler's noder copy lists into slices. x/tools/go/ssa even uses an unsafe cast that depends on the internal layout of TypeParamList.

The proposal adds two constructors to go/types. NewTypeParamList builds a *TypeParamList from type parameters, and NewTypeList builds a *TypeList from types.

func concat(recv, meth *types.TypeParamList) *types.TypeParamList {
    var all []*types.TypeParam
    for tp := range recv.TypeParams() {
        all = append(all, tp)
    }
    for tp := range meth.TypeParams() {
        all = append(all, tp)
    }
    return types.NewTypeParamList(all...)
}

args := types.NewTypeList(types.Typ[types.Int], types.Typ[types.String])

Add Scope.Objects iterator

#80449 · go/types · low impact · Implemented in Go 1.28 ·

Code that walks the objects in a types.Scope usually loops over Scope.Names() and calls Lookup for each name. This pattern appears dozens of times in x/tools alone.

The proposal adds a Scope.Objects method that returns an iterator. It yields the scope's objects in name order.

for obj := range pkg.Scope().Objects() {
	fmt.Println(obj.Name(), obj.Type())
}

Add FMA32 for single-precision fused multiply-add

#82653 · math · low impact · Implemented in Go 1.28 ·

Go has no correct, fast way to compute a single-precision fused multiply-add. The obvious float32(math.FMA(float64(x), float64(y), float64(z))) rounds twice: once to float64 and again to float32. That can give a different result from a true fused operation. Writing x*y + z may compile to a fused instruction, but the spec allows this without requiring it, so results vary by platform and compiler.

The proposal adds math.FMA32. It computes x*y + z as if with infinite precision and rounds only once:

func FMA32(x, y, z float32) float32

r := math.FMA32(a, b, c) // a*b + c, rounded once to float32

Like math.FMA, the compiler turns it into a single inlined hardware instruction where one is available. This covers arm64, loong64, ppc64x, riscv64, s390x, amd64 (with FMA support) and arm (with VFPv4). On 386, mips and wasm it uses a pure-Go software fallback.

Mark DNSConfigError as deprecated

#63118 · net · low impact · Implemented in Go 1.28 ·

The net.DNSConfigError type has not been used by the net package for years. Its doc comment says "No longer used; kept for compatibility," but it lacks a formal deprecation notice. As a result, tools like staticcheck and gopls don't warn code that still references it.

The proposal adds a standard Deprecated: comment to the type. The type stays in the package for compatibility, so existing code keeps compiling.

// DNSConfigError represents an error reading the machine's DNS configuration.
//
// Deprecated: No longer used; kept for compatibility.
type DNSConfigError struct {
    Err error
}

Add Server.HandleRequest to apply server processing to external requests

#77441 · net/http · low impact · Implemented in Go 1.28 ·

Before passing a request to the user's handler, http.Server does some extra work. It answers OPTIONS * requests, falls back to DefaultServeMux when Server.Handler is nil, and recovers and logs panics. Code that receives requests some other way, such as an HTTP/3 server or a test, can't reuse this logic and has to copy it.

The new Server.HandleRequest method handles a request as if the server had received it, applying the same behavior.

func (s *h3Server) serveRequest(w http.ResponseWriter, r *http.Request) {
    if err := s.httpServer.HandleRequest(w, r); err != nil {
        // handler panicked; reset the stream
        s.resetStream(r)
    }
}

Add MethodQuery constant for the HTTP QUERY method

#80058 · net/http · low impact · Implemented in Go 1.28 ·

RFC 10008 defines the HTTP QUERY method. Like GET, it is safe and idempotent. Like POST, it carries a request body. This makes it useful for complex queries or large or binary query data that don't fit well in a URL. The method was previously known as SEARCH, but it was renamed before the RFC was published.

The net/http package adds a MethodQuery constant alongside MethodGet, MethodPost, MethodPatch, and the others:

const MethodQuery = "QUERY"
req, err := http.NewRequest(http.MethodQuery, "https://example.com/search", body)

The proposal only adds the constant. Any QUERY-specific behavior, such as Content-Length handling or redirects, would be handled separately.

Add Landlock sandboxing and NoNewPrivs to SysProcAttr on Linux

#68595 · syscall · low impact · Implemented in Go 1.28 ·

On Linux, programs that run untrusted work through os/exec often want the child process to have fewer privileges than the parent. For example, a server might run git on untrusted repositories and want git to touch only one temporary directory. Landlock is a Linux kernel feature that restricts file access. Until now, Go had no safe way to apply it to a child process only, because forking manually is hard with Go's threaded runtime.

The proposal adds new fields to syscall.SysProcAttr on Linux. When UseLandlock is set, the child calls landlock_restrict_self(LandlockFD, LandlockFlags) before exec. LandlockFD is a ruleset file descriptor, which can come from a library such as go-landlock. A new NoNewPrivs field calls prctl(PR_SET_NO_NEW_PRIVS) before exec.

cmd := exec.Command("git", "clone", url, tmpDir)
cmd.SysProcAttr = &syscall.SysProcAttr{
    NoNewPrivs:  true,
    UseLandlock: true,
    LandlockFD:  rulesetFD, // e.g. allows only /usr (read) and tmpDir (read-write)
}
err := cmd.Run()