Go Vet Command and Its Usage

The Golang vet command is a built-in tool that is included in the Go programming language. It is designed to help developers identify and diagnose potential problems in their Go code. This can be useful for catching errors before they are compiled, ensuring that the code is as clean and efficient as possible.

Go vet command is a handy tool that can help you write better and cleaner code. It helps you find errors in your application and reports suspicious constructs such as abnormal or useless code, as well as detect common mistakes using different packages.

Vet command (or should we say vet commands?) is a collection of different analysis tool commands and sub-analyzers. It is worth mentioning that vet uses heuristics which can’t guarantee that 100% of the reports will be genuine issues. However, it can detect errors that compliers might omit.

Using the vet command

You can invoke vet with the go command. The following command will vet the current directory package:

go vet

If you wish to vet a package in another directory you need to provide a path:

go vet my_machine/project/...

If you want to vet specific packages you can use:

go help packages

Listing all available checks with tool vet help

You can list all available checks by running the:

go tool vet help

Now, let’s briefly go over what you can exactly get from the go tool vet help commands.


asmdecl reports mismatches between the Go declarations and assembly files.


This is a check for useless assignments.


This is for common mistakes using the sync/atomic package and will check any irregularities in the usage of the atomic function.


Detects common mistakes that involve boolean operators.


Checks the form and location of the +build tags. The +build flags supported by go vet are related to the resolution and execution of the control package.


Checks for violations of the cgo pointer passing rules.


Looks for any composite literals using unkeyed fields.


Detects copied locks passed by value as an error. The locks should never be copied, as the copy of the lock will copy the internal state of the “original” making it the same as the “original”.


Checks for any mistakes in HTTP responses usage


Checks for any references to loop variables from within nested functions.


Detects cancel func that is returned by context.WithCancel. Creating a cancellable context will return a new context with a function that enables you to cancel that particular context. You can use that function to cancel each and every operation linked to that context, however, it has to be called in order. Otherwise, it will leak context.


Searches for useless comparisons between nil and functions.


Checks for consistency in Printf format. Constructs such as Printf calls with arguments that don’t align with the format string will be flagged.


This go vet analysis tool will try to find shifts that either exceed or equal the integer width.


Checks for methods that you have implemented from the standard library interfaces and their compatibility.


Detects fields that don’t conform to the convention defined in the reflect package.


This analyzer catches likely mistakes made while using either a test or an example.


It returns all instances of passing non-interface or non-pointer values to unmarshal.


Simply checks for any code that is unreachable.


Detects any invalid conversion of uintptr to unsafe.Pointer.


Detects unused results of calls to functions.

Conclusions on the go vet analysis tool

Go vet is a very useful collection of tools that can help you find different issues with your source code. By design, all checks are performed, unless any flags are set to true. In that case, only those tests will be run. Analogically, setting a flag to false will disable that particular test.

Please mind that not all returned errors are genuine problems. Moreover, if you wish to look for other subtle issues in your go programs, one that no specific checker detects, there is an option to add additional checks and custom analyzers.


Golang (or Go in short) is a breath of fresh air in the coding market. A long-needed shakeup in the stale programming market with a cute gopher as a mascot. Its development was started in 2007 by designers Robert Griesemer, Rob Pike, and Ken Thompson.

Written by Janek

Cloud services can accelerate your e-commerce business and give it a competitive edge. Find out how you can leverage SaaS solutions to boost efficiency and sales.

Written by Janek

One of the distinguishing features of the Go programming language (often referred to as Golang) is its concurrency model. At its heart are goroutines, lightweight threads managed by the Go runtime, and channels, the conduits that allow these goroutines to communicate safely. The interaction between channels and the select statement represents a core aspect of […]

Written by Janek

Mobile cloud computing allows businesses to provide quality digital products with cost-efficiency. We explain how to leverage cloud technology to develop top-level mobile apps.

Written by Janek

Moving to the cloud has become a necessity for many companies, but the task is hardly easy. What is the best cloud migration strategy for your business, and what are the key factors affecting the successful outcome? Read on to find out!

Written by Janek