This is a creation in Article, where the information may have evolved or changed.
The go language does not have a defined specification for a set of markup deprecated APIs for a long time. In the past few years, a specification has been introduced to add deprecated annotations to a document.
Now the standard library is starting to use this format.
For example, the Go 1.8 package sql/driver.Execer
is deprecated, adding a set of annotations, which can be godoc
identified.
// Execer is an optional interface that may be implemented by a Conn.//// If a Conn does not implement Execer, the sql package's DB.Exec will// first prepare a query, execute the statement, and then close the// statement.//// Exec may return ErrSkip.//// Deprecated: Drivers should implement ExecerContext instead (or additionally).type Execer interface {Exec(query string, args []Value) (Result, error)}
Deprecated notifications appear in Godoc, and comments need to be preceded by a Deprecated
hint that replaces the API.
// Deprecated: Use strings.HasPrefix instead.
Users using the API can use the new API based on this hint.
Additional to the notices, there is a effort going on to discourage users to keep depending on the deprecated APIs. In addition to comment notifications , there are ways to prevent users from using deprecated APIs.
You can refer to the following article:
- How to hide deprecated APIs by default
- Hide deprecated APIs on godoc.org
- Deprecated API via Golint notification
In summary, you can use this annotation format to support deprecation notifications. Don't use DEPRECATED
or This type is deprecated
. In the future, you can use some tools to notify users to stop using deprecated APIs.
Read the original deprecating things in Go
The original link: "Golang" in the Use of "Discard (deprecate)", reproduced please indicate the source!