Skip to content

Commit 4e185d4

Browse files
author
ekarlso
committed
Fix linter issues
1 parent 3fa1300 commit 4e185d4

File tree

20 files changed

+315
-159
lines changed

20 files changed

+315
-159
lines changed

.golangci.yml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
version: "2"
2+
linters:
3+
default: none
4+
enable:
5+
- asciicheck
6+
- bodyclose
7+
- copyloopvar
8+
- depguard
9+
- dogsled
10+
- errcheck
11+
- goconst
12+
- gocritic
13+
- gocyclo
14+
- godot
15+
- goprintffuncname
16+
- gosec
17+
- govet
18+
- importas
19+
- ineffassign
20+
- misspell
21+
- nakedret
22+
- nilerr
23+
- noctx
24+
- nolintlint
25+
- prealloc
26+
- predeclared
27+
- revive
28+
- rowserrcheck
29+
- staticcheck
30+
- thelper
31+
- unconvert
32+
- unparam
33+
- unused
34+
- whitespace
35+
settings:
36+
depguard:
37+
rules:
38+
main:
39+
allow:
40+
- $gostd
41+
- go.trollit.tech/binance-proxy
42+
- github.com/adshao/go-binance
43+
- github.com/jessevdk/go-flags
44+
- golang.org/x/time/rate
45+
- github.com/samber/slog-multi
46+
- google.golang.org/grpc
47+
- go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp
48+
- github.com/go-slog/otelslog
49+
- go.opentelemetry.io/otel
50+
- github.com/stash86/binance-proxy
51+
godot:
52+
scope: toplevel
53+
exclude:
54+
- ^ \+.*
55+
- ^ ANCHOR.*
56+
gosec:
57+
excludes:
58+
- G307
59+
- G108
60+
importas:
61+
no-unaliased: true
62+
nolintlint:
63+
require-specific: true
64+
revive:
65+
rules:
66+
- name: exported
67+
arguments:
68+
- disableStutteringCheck
69+
- name: unused-parameter
70+
disabled: true
71+
tagliatelle:
72+
case:
73+
rules:
74+
json: goCamel
75+
exclusions:
76+
generated: lax
77+
presets:
78+
- comments
79+
- common-false-positives
80+
- legacy
81+
- std-error-handling
82+
paths:
83+
- third_party$
84+
- builtin$
85+
- examples$
86+
formatters:
87+
enable:
88+
- gci
89+
- gofmt
90+
- goimports
91+
settings:
92+
gci:
93+
sections:
94+
- standard
95+
- default
96+
- prefix(go.trollit.tech/binance-proxy)
97+
goimports:
98+
local-prefixes:
99+
- go.trollit.tech/binance-proxy
100+
exclusions:
101+
generated: lax
102+
paths:
103+
- third_party$
104+
- builtin$
105+
- examples$

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ The status endpoint provides comprehensive information about the proxy service:
125125
```json
126126
{
127127
"proxy_status": {
128-
"service": "binance-proxy",
128+
"service": "github.com/stash86/binance-proxy",
129129
"healthy": true,
130130
"start_time": "2025-06-15T10:30:00Z",
131131
"uptime": "2h15m30s",
@@ -535,7 +535,6 @@ By submitting a pull request to this project, you agree to license your contribu
535535
- [go-binance](https://github.com/adshao/go-binance/blob/master/LICENSE)
536536

537537
- [go-flags](https://github.com/jessevdk/go-flags/blob/master/LICENSE)
538-
- [logrus](https://github.com/sirupsen/logrus/blob/master/LICENSE)
539538
- [go-time](https://cs.opensource.google/go/x/time/+/master:LICENSE)
540539
- [go-simplejson](https://github.com/bitly/go-simplejson/blob/master/LICENSE)
541540
- [websocket](https://github.com/gorilla/websocket/blob/master/LICENSE)

cmd/binance-proxy/main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
package main
22

33
import (
4-
"binance-proxy/internal/handler"
5-
"binance-proxy/internal/logcache"
6-
"binance-proxy/internal/service"
74
"context"
85
"errors"
96
"fmt"
107
stdlog "log"
118
"log/slog"
129
"net/http"
10+
_ "net/http/pprof"
1311
"os"
1412
"os/signal"
1513
"syscall"
1614
"time"
1715

18-
_ "net/http/pprof"
19-
2016
"github.com/jessevdk/go-flags"
17+
"github.com/stash86/binance-proxy/internal/handler"
18+
"github.com/stash86/binance-proxy/internal/logcache"
19+
"github.com/stash86/binance-proxy/internal/service"
2120
)
2221

2322
func startProxy(ctx context.Context, logger *slog.Logger, bd *service.BanDetector, port int, class service.Class, disablefakekline bool, alwaysshowforwards bool, errChan chan<- error) {

go.mod

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
module binance-proxy
1+
module github.com/stash86/binance-proxy
22

3-
go 1.23.0
4-
5-
toolchain go1.24.4
3+
go 1.25.3
64

75
require (
86
github.com/adshao/go-binance/v2 v2.8.2
97
github.com/jessevdk/go-flags v1.6.1
10-
github.com/sirupsen/logrus v1.9.3
118
golang.org/x/time v0.12.0
129
)
1310

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ github.com/adshao/go-binance/v2 v2.8.2 h1:cpMaoBnrg9g7aTNEAeMRIIMwVZ8S/oR5Fca+Py
22
github.com/adshao/go-binance/v2 v2.8.2/go.mod h1:XkkuecSyJKPolaCGf/q4ovJYB3t0P+7RUYTbGr+LMGM=
33
github.com/bitly/go-simplejson v0.5.1 h1:xgwPbetQScXt1gh9BmoJ6j9JMr3TElvuIyjR8pgdoow=
44
github.com/bitly/go-simplejson v0.5.1/go.mod h1:YOPVLzCfwK14b4Sff3oP1AmGhI9T9Vsg84etUnlyp+Q=
5-
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
65
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
76
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
87
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
@@ -19,20 +18,13 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
1918
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2019
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
2120
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
22-
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
23-
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
24-
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
2521
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
2622
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
27-
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
2823
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
2924
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
30-
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
3125
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
3226
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
3327
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
3428
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
35-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
36-
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
3729
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
3830
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/handler/depth.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,8 @@ func (s *Handler) depth(w http.ResponseWriter, r *http.Request) {
7474
return
7575
}
7676

77-
w.Write(buf.Bytes())
77+
if _, err := w.Write(buf.Bytes()); err != nil {
78+
http.Error(w, "Failed to write response", http.StatusInternalServerError)
79+
return
80+
}
7881
}

internal/handler/exchangeinfo.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ func (s *Handler) exchangeInfo(w http.ResponseWriter) {
1414
w.Header().Set("Content-Type", "application/json")
1515
w.Header().Set("Data-Source", "cache")
1616

17-
w.Write(data)
17+
if _, err := w.Write(data); err != nil {
18+
http.Error(w, "Failed to write response", http.StatusInternalServerError)
19+
return
20+
}
1821
}

0 commit comments

Comments
 (0)