durcheck

command module
v0.0.0-...-80aef88 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

durcheck

Build Status License MIT

durcheck is a very simple linter which detects potential bugs with time.Duration in a Go package.

Purpose

Consider the following code:

func doInTime(done chan struct{}) error {
	select {
	case <-time.After(60):
		return errors.New("timeout")
	case <-done:
		return nil
	}
}

There is obviously a problem with time.After(60), where untyped int is actually converted to 60 nanoseconds. But a programmer can miss it, or a Golang newcomer from languages like PHP where sleep function has signature int sleep ( int $seconds ) can make such mistake.

Running the linter against the code above will produce an error:

$ durcheck .
main.go:14:9: implicit time.Duration means nanoseconds in "time.After(60)" 

Install

go get -u github.com/hypnoglow/durcheck
gometalinter integration

Option A: pass these arguments to gometalinter command:

gometalinter --linter=durcheck:durcheck:PATH:LINE:COL:MESSAGE --enable=durcheck ./...

Option B: add this configuration to your .gometalinter.json file:

{
  "Enable": [
    "durcheck"
  ],
  "Linters": {
    "durcheck": {
      "Command": "durcheck",
      "Pattern": "PATH:LINE:COL:MESSAGE"
    }
  }
}

LICENSE

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址