Skip to content

Commit

Permalink
Overhaul for new linting package
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Oct 3, 2020
1 parent 2d1c4c2 commit 0957f53
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 37 deletions.
14 changes: 6 additions & 8 deletions .make/Makefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ DARWIN=$(BINARY_NAME)-darwin
LINUX=$(BINARY_NAME)-linux
WINDOWS=$(BINARY_NAME)-windows.exe

.PHONY: test lint install
.PHONY: test lint vet install

bench: ## Run all benchmarks in the Go application
@go test -bench=. -benchmem
Expand All @@ -40,27 +40,24 @@ install: ## Install the application
install-go: ## Install the application (Using Native Go)
@go install $(GIT_DOMAIN)/$(REPO_OWNER)/$(REPO_NAME)

lint:: ## Run the Go lint application
@if [ "$(shell command -v golint)" = "" ]; then go get -u golang.org/x/lint/golint; fi
@golint
lint: ## Run the golangci-lint application (install if not found)
@if [ "$(shell command -v golangci-lint)" = "" ]; then curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0; fi;
@echo "running golangci-lint..."
@golangci-lint run

test: ## Runs vet, lint and ALL tests
@$(MAKE) vet
@$(MAKE) lint
@go test ./... -v

test-short: ## Runs vet, lint and tests (excludes integration tests)
@$(MAKE) vet
@$(MAKE) lint
@go test ./... -v -test.short

test-travis: ## Runs all tests via Travis (also exports coverage)
@$(MAKE) vet
@$(MAKE) lint
@go test ./... -race -coverprofile=coverage.txt -covermode=atomic

test-travis-short: ## Runs unit tests via Travis (also exports coverage)
@$(MAKE) vet
@$(MAKE) lint
@go test ./... -test.short -race -coverprofile=coverage.txt -covermode=atomic

Expand All @@ -77,4 +74,5 @@ update: ## Update all project dependencies
@go get -u ./... && go mod tidy

vet: ## Run the Go vet application
@echo "running go vet..."
@go vet -v ./...
32 changes: 10 additions & 22 deletions CODE_STANDARDS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,27 @@ This project uses the following code standards and specifications from:
- [go tests](https://golang.org/pkg/testing/)
- [godoc](https://godoc.org/golang.org/x/tools/cmd/godoc)
- [gofmt](https://golang.org/cmd/gofmt/)
- [golangci-lint](https://golangci-lint.run/usage/quick-start/)
- [golint](https://github.com/golang/lint) (deprecated)
- [golangci-lint](https://golangci-lint.run/)
- [report card](https://goreportcard.com/)
- [vet](https://golang.org/cmd/vet/)

### *effective go* standards
View the [effective go](https://golang.org/doc/effective_go.html) standards documentation.

### *golangci-lint* specifications
The package [golangci-lint](https://golangci-lint.run/usage/quick-start) runs several linters in one package/cmd.

How to install [golangci-lint](https://golangci-lint.run/):
```shell script
brew install golangci-lint
```

### *golint* specifications (deprecated)
The package [golint](https://github.com/golang/lint) differs from [gofmt](https://golang.org/cmd/gofmt/). The package [gofmt](https://golang.org/cmd/gofmt/) formats Go source code, whereas [golint](https://github.com/golang/lint) prints out style mistakes. The package [golint](https://github.com/golang/lint) differs from [vet](https://golang.org/cmd/vet/). The package [vet](https://golang.org/cmd/vet/) is concerned with correctness, whereas [golint](https://github.com/golang/lint) is concerned with coding style. The package [golint](https://github.com/golang/lint) is in use at Google, and it seeks to match the accepted style of the open source [Go project](https://golang.org/).
View the active linters in the [configuration file](.golangci.yml).

How to install [golint](https://github.com/golang/lint):
```shell script
go get -u golang.org/x/lint/golint
cd ../go-bitcoin
golint
Install via macOS:
```shell
brew install golangci-lint
```

### *go vet* specifications
[Vet](https://golang.org/cmd/vet/) examines Go source code and reports suspicious constructs. [Vet](https://golang.org/cmd/vet/) uses heuristics that do not guarantee all reports are genuine problems, but it can find errors not caught by the compilers.

How to run [vet](https://golang.org/cmd/vet/):
```shell script
cd ../go-bitcoin
go vet -v
Install via Linux and Windows:
```shell
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.31.0
golangci-lint --version
```

### *godoc* specifications
Expand Down
5 changes: 2 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ All tests follow the standard Go testing pattern.

This project follows [effective Go standards](https://golang.org/doc/effective_go.html) and uses additional convention tools:
- [godoc](https://godoc.org/golang.org/x/tools/cmd/godoc)
- [golint](https://github.com/golang/lint)
- [vet](https://golang.org/cmd/vet/)
- [GoReportCard.com](https://goreportcard.com/report/github.com/BitcoinSchema/go-bitcoin)
- [golangci-lint](https://golangci-lint.run/)
- [GoReportCard.com](https://goreportcard.com/)
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ clean: ## Remove previous builds and any test cache data
@test $(DISTRIBUTIONS_DIR)
@if [ -d $(DISTRIBUTIONS_DIR) ]; then rm -r $(DISTRIBUTIONS_DIR); fi

lint:: ## Runs the golangci-lint tool
@echo "running golangci-lint..."
@golangci-lint run

release:: ## Runs common.release then runs godocs
@$(MAKE) godocs

Expand Down

0 comments on commit 0957f53

Please sign in to comment.