Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade golangci linter #416

Merged
merged 1 commit into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc
with:
version: v1.43.0
version: v1.49.0

- name: shellcheck
uses: azohra/shell-linter@6bbeaa868df09c34ddc008e6030cfe89c03394a1
Expand Down
5 changes: 1 addition & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
---
run:
go: "1.17"
go: "1.15"
linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- exhaustive
Expand All @@ -22,10 +21,8 @@ linters:
- lll
- misspell
- staticcheck
- structcheck
- typecheck
- unused
- varcheck
- whitespace
fast: false
linters-settings:
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Unreleased]

* Support go 1.18, 1.19. (@miry)
* Support go 1.18, 1.19. (#415, @miry)
* `toxiproxy.NewProxy` now accepts `name`, `listen addr` and `upstream addr`. (#418, @miry)
* Replace logrus with zerolog. (#413, @miry)
* Log HTTP requests to API server. (#413, #421, @miry)
Expand Down
7 changes: 3 additions & 4 deletions link.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import (
// and removed as they are enabled/disabled. New toxics are always added to the end
// of the chain.
//
// NoopToxic LatencyToxic
// v v
// Input > ToxicStub > ToxicStub > Output.
//
// | NoopToxic LatencyToxic
// | v v
// | Input > ToxicStub > ToxicStub > Output.
type ToxicLink struct {
stubs []*toxics.ToxicStub
proxy *Proxy
Expand Down
19 changes: 16 additions & 3 deletions test/e2e/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import (
"fmt"
"log"
"net/http"
"time"

"github.com/gorilla/mux"
)

var (
Expand Down Expand Up @@ -41,9 +44,19 @@ func main() {
stuff[i] = byte(i % 256)
}
hex.Encode(out, stuff)
http.HandleFunc("/test1", handler1)
http.HandleFunc("/test2", handler2)

r := mux.NewRouter()
r.HandleFunc("/test1", handler1)
r.HandleFunc("/test2", handler2)

log.Println("Listening :20002")
log.Fatal(http.ListenAndServe(":20002", nil))

srv := &http.Server{
Handler: r,
Addr: ":20002",
WriteTimeout: 3 * time.Second,
ReadTimeout: 3 * time.Second,
}

log.Fatal(srv.ListenAndServe())
}
3 changes: 1 addition & 2 deletions toxics/limit_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package toxics_test
import (
"bytes"
"crypto/rand"
"fmt"
"testing"

"github.com/Shopify/toxiproxy/v2/stream"
Expand All @@ -26,7 +25,7 @@ func checkOutgoingChunk(t *testing.T, output chan *stream.StreamChunk, expected

func checkRemainingChunks(t *testing.T, output chan *stream.StreamChunk) {
if len(output) != 0 {
t.Error(fmt.Sprintf("There is %d chunks in output channel. 0 is expected.", len(output)))
t.Errorf("There is %d chunks in output channel. 0 is expected.", len(output))
}
}

Expand Down
4 changes: 2 additions & 2 deletions toxics/slicer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ type SlicerToxic struct {
// Returns a list of chunk offsets to slice up a packet of the
// given total size. For example, for a size of 100, output might be:
//
// []int{0, 18, 18, 43, 43, 67, 67, 77, 77, 100}
// ^---^ ^----^ ^----^ ^----^ ^-----^
// | []int{0, 18, 18, 43, 43, 67, 67, 77, 77, 100}
// | ^---^ ^----^ ^----^ ^----^ ^-----^
//
// This tries to get fairly evenly-varying chunks (no tendency
// to have a small/large chunk at the start/end).
Expand Down