"Deprecated (deprecate)" used in "Golang"

Source: Internet
Author: User
Tags deprecated
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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.