Golang Tool Chain Overview (i)

Source: Internet
Author: User
This is a created article in which the information may have evolved or changed.

We all know that Golang offers a lot of rich and powerful command-line tools. But so many tools, what exactly does each one do? This article is a rough chat about the role and usage of several commonly used tools.

gofmt

GOFMT is a code formatting tool that only organizes code formatting to ensure that everyone's code is formatted uniformly.
Attach the effect before and after GOFMT:

golint

The Golint tool is a code quality check that gives some best practice guidelines. Look at the following code:

After the Golint.

main.go:8:5: error var SomeError should have name of the form ErrFoo  main.go:8:5: exported var SomeError should have comment or be unexported  main.go:16:9: if block ends with a return statement, so drop this else and outdent its block  

First line: SomeError the format of the variable should be the beginning of err.

The second line: SomeError the uppercase start can be referenced outside the package, so you need to write a comment at the declaration. or change to lowercase, not to be quoted outside the package.

The third line: the IF condition has a return statement, so the else block is not required.

After the modification, the golint is executed again, and the error disappears.

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.