How to Deprecate a Function or Package in Go

Deprecate Go functions or packages by adding a // Deprecated: comment before the declaration to signal users to migrate to a newer alternative.

Deprecate a function or package in Go by adding a // Deprecated: comment immediately before the declaration. This comment must start with the word "Deprecated" followed by a space and a brief explanation of why it is deprecated and what to use instead.

// Deprecated: Use TypeReg instead.
const TypeRegA = '\x00'

// Deprecated: Use Modified instead.
var ModifiedTime uint16

The go command and documentation tools automatically detect this comment and mark the symbol as deprecated in generated documentation and API diffs.