Proposals Unofficial Go proposal tracker

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)
}
Proposal
#79946 by sfllaw
Status
Implemented on Jul 15, 2026
Release
Go 1.28
Impact
medium
Area
net/url