Proposals Unofficial Go proposal tracker

Add Deprecated function to parse deprecation notices in doc comments

#80118 · go/ast · low impact · Accepted ·

Go tools such as gopls and static analyzers detect deprecated symbols by looking for comments that start with "Deprecated:". The rules for this format lived on a wiki page, and each tool implemented its own parsing. This proposal makes one official definition and adds a standard function that tools can share.

The go/doc package gains a Deprecated function. It returns the notice text without the "Deprecated: " prefix, or "", false if there is no notice. Its input can be Func.Doc, Package.Doc, Type.Doc, or Value.Doc.

for _, f := range pkg.Funcs {
    if text, ok := doc.Deprecated(f.Doc); ok {
        fmt.Printf("%s is deprecated: %s\n", f.Name, text)
    }
}
Proposal
#80118 by aputman
Status
Accepted on Nov 4, 2026
Impact
low
Area
go/ast