Skip to content

Commit

Permalink
Remove unmaintained golang-linter plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
miry committed Aug 26, 2022
1 parent fd1e655 commit 4fbc7fc
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 21 deletions.
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [Unreleased]

* Support go 1.18.
* Setup timeout 3 seconds for HTTP API server requests. (#416, @miry)

# [2.4.0] - 2022-03-07

Expand Down
12 changes: 9 additions & 3 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"os"
"strings"
"time"

"github.com/Shopify/toxiproxy/v2/toxics"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -81,15 +82,20 @@ func (server *ApiServer) Listen(host string, port string) {
r.Handle("/metrics", server.Metrics.handler())
}

http.Handle("/", StopBrowsersMiddleware(r))

logrus.WithFields(logrus.Fields{
"host": host,
"port": port,
"version": Version,
}).Infof("Starting HTTP server on endpoint %s:%s", host, port)

err := http.ListenAndServe(net.JoinHostPort(host, port), nil)
srv := &http.Server{
Handler: StopBrowsersMiddleware(r),
Addr: net.JoinHostPort(host, port),
WriteTimeout: 5 * time.Second,
ReadTimeout: 5 * time.Second,
}

err := srv.ListenAndServe()
if err != nil {
log.Fatal("ListenAndServe: ", err)
}
Expand Down
2 changes: 1 addition & 1 deletion api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestBrowserGets403(t *testing.T) {
defer resp.Body.Close()

if resp.StatusCode != 403 {
t.Fatal("Browser-like UserAgent was not denied access to Toxiproxy")
t.Fatalf("Browser-like UserAgent was not denied access to Toxiproxy: %v", resp.StatusCode)
}
})
}
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
1 change: 0 additions & 1 deletion proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
// client and upstream.
//
// Client <-> toxiproxy <-> Upstream.
//
type Proxy struct {
sync.Mutex

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

0 comments on commit 4fbc7fc

Please sign in to comment.