diff --git a/Makefile b/Makefile index abce916..8e2f81a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ build: - @GO111MODULE=on go build -ldflags '-s -w' -o durationcheck cmd/main.go + @GO111MODULE=on go build -ldflags '-s -w' -o durationcheck ./cmd/durationcheck/main.go -install: build - @mv durationcheck $(GOPATH)/bin/durationcheck +install: + @GO111MODULE=on go install -ldflags '-s -w' ./cmd/durationcheck diff --git a/README.md b/README.md index 372b0f8..6676fe9 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Duration Check =============== -A Go linter that detects cases where two `time.Duration` values are being multiplied in possibly erroneous ways. +A Go linter to detect cases where two `time.Duration` values are being multiplied in possibly erroneous ways. For example, consider the following snippet: @@ -18,23 +18,18 @@ reasonably expect `waitFor(5 * time.Seconds)` to wait for ~5 seconds but they wo A majority of these problems would be spotted almost immediately but some could still slip through unnoticed. Hopefully this linter will help catch those rare cases before they cause a production issue. +See the [test cases](testdata/src/a/a.go) for more examples of the types of errors detected by the linter. + Installation ------------- -Grab the sources with go-get - -``` -go get -d github.com/charithe/durationcheck -``` - -To install a standalone binary in `$GOPATH/bin`: +Requires Go 1.11 or above. ``` -cd $GOPATH/src/github.com/charithe/durationcheck && make install +go get -u github.com/charithe/durationcheck/cmd/durationcheck ``` - Usage ----- diff --git a/cmd/main.go b/cmd/durationcheck/main.go similarity index 100% rename from cmd/main.go rename to cmd/durationcheck/main.go