Skip to content

Commit

Permalink
add tools. update golangci-lint. fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Oct 22, 2020
1 parent b24d883 commit 946c6d7
Show file tree
Hide file tree
Showing 8 changed files with 454 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
env:
GO111MODULE: on
GOLANGCI_LINT_VERSION: v1.27.0
GOLANGCI_LINT_VERSION: v1.31.0

steps:
- name: Set up Go
Expand Down
10 changes: 9 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ issues:

# sync.once copy in pacer test
- path: load/pacer_test.go
text: "copylocks"
text: "copylocks"

# TODO fix protobuf deprecated
- path: runner/
text: "SA1019: package github.com/golang/protobuf"

# TODO fix protobuf deprecated
- path: protodesc/
text: "SA1019: package github.com/golang/protobuf"
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ setup:
go mod download
.PHONY: setup

tools:
go generate -tags tools tools/tools.go
.PHONY: tools

# All runs the default lint, test, and code coverage targets.
.PHONY: all
all: lint cover build
Expand Down
24 changes: 8 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,31 @@ module github.com/bojand/ghz
go 1.14

require (
cloud.google.com/go v0.46.3 // indirect
github.com/alecthomas/kingpin v1.3.8-0.20191105203113-8c96d1c22481
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/bojand/hri v1.1.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/go-playground/locales v0.13.0 // indirect
github.com/go-playground/universal-translator v0.16.0 // indirect
github.com/go-playground/validator v9.30.0+incompatible
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/golang/protobuf v1.4.2
github.com/golangci/golangci-lint v1.31.0
github.com/google/uuid v1.1.1
github.com/jhump/protoreflect v1.5.0
github.com/jinzhu/configor v1.1.1
github.com/jinzhu/gorm v1.9.11
github.com/kr/text v0.2.0 // indirect
github.com/labstack/echo v3.3.10+incompatible
github.com/labstack/gommon v0.3.0
github.com/leodido/go-urn v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pkg/errors v0.8.1
github.com/mfridman/tparse v0.8.3
github.com/pkg/errors v0.9.1
github.com/rakyll/statik v0.1.6
github.com/stretchr/testify v1.5.1
github.com/stretchr/testify v1.6.1
go.uber.org/multierr v1.3.0
go.uber.org/zap v1.13.0
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e // indirect
golang.org/x/tools v0.0.0-20200502202811-ed308ab3e770 // indirect
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
golang.org/x/net v0.0.0-20200625001655-4c5254603344
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
golang.org/x/tools v0.0.0-20200812195022-5ae4c3c160a0
google.golang.org/grpc v1.24.0
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
honnef.co/go/tools v0.0.1-2020.1.3 // indirect
)
410 changes: 406 additions & 4 deletions go.sum

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions load/pacer.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,6 @@ func (p *LinearPacer) Rate(elapsed time.Duration) float64 {
return p.sp.Rate(elapsed)
}

// hits returns the number of hits that have been sent during an attack
// lasting t nanoseconds. It returns a float so we can tell exactly how
// much we've missed our target by when solving numerically in Pace.
func (p *LinearPacer) hits(t time.Duration) float64 {
p.initialize()

return p.sp.hits(t)
}

// String returns a pretty-printed description of the LinearPacer's behaviour:
// LinearPacer{Slope: 1} => Linear{1 hits/1s}
func (p *LinearPacer) String() string {
Expand Down
30 changes: 0 additions & 30 deletions load/pacer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,36 +415,6 @@ func TestLinearPacer(t *testing.T) {
}
}

func TestLinearPacer_hits(t *testing.T) {
t.Skip()

// TODO improve this to have different pacer params
p := LinearPacer{
Start: ConstantPacer{Freq: 100},
Slope: 10,
}

for _, tc := range []struct {
elapsed time.Duration
hits float64
}{
{0, 0},
{1 * time.Second, 105},
{2 * time.Second, 220},
{4 * time.Second, 480},
{8 * time.Second, 1120},
{16 * time.Second, 2880},
{32 * time.Second, 8320},
{64 * time.Second, 26880},
{128 * time.Second, 94720},
} {
actual := p.hits(tc.elapsed)
expected := tc.hits

assert.True(t, floatEqual(actual, expected), "%+v.hits(%v) = %v, expected: %v", p, tc.elapsed, actual, expected)
}
}

func TestStepPacer_hits(t *testing.T) {
t.Parallel()

Expand Down
26 changes: 26 additions & 0 deletions tools/tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// +build tools

// This file ensures tool dependencies are kept in sync. This is the
// recommended way of doing this according to
// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
// To install the following tools at the version used by this repo run:
// $ make tools
// or
// $ go generate -tags tools tools/tools.go

package tools

// NOTE: This must not be indented, so to stop goimports from trying to be
// helpful, it's separated out from the import block below. Please try to keep
// them in the same order.
//go:generate go install github.com/mfridman/tparse
//go:generate go install golang.org/x/tools/cmd/goimports
//go:generate go install github.com/golangci/golangci-lint/cmd/golangci-lint

import (
_ "github.com/mfridman/tparse"

_ "github.com/golangci/golangci-lint/cmd/golangci-lint"

_ "golang.org/x/tools/cmd/goimports"
)

0 comments on commit 946c6d7

Please sign in to comment.