Skip to content

Commit e9a3699

Browse files
authored
Using golangci-lint (#2)
1 parent 29c9908 commit e9a3699

7 files changed

Lines changed: 79 additions & 11 deletions

File tree

.github/workflows/linter.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Linter
2+
3+
concurrency:
4+
group: linter-${{ github.event_name }}-${{ github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
push:
9+
branches:
10+
- 'main'
11+
pull_request:
12+
13+
jobs:
14+
linter:
15+
name: Linter
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v5
20+
21+
- name: Setup Go
22+
uses: actions/setup-go@v5
23+
with:
24+
check-latest: true
25+
go-version-file: 'go.mod'
26+
27+
- name: GolangCI lint
28+
uses: golangci/golangci-lint-action@v8
29+
with:
30+
version: latest
31+
args: -v

.golangci.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
version: "2"
2+
3+
run:
4+
timeout: 5m
5+
6+
linters:
7+
default: none
8+
enable:
9+
- cyclop
10+
- govet
11+
- ineffassign
12+
- misspell
13+
- staticcheck
14+
- unconvert
15+
- unused
16+
- usestdlibvars
17+
18+
settings:
19+
cyclop:
20+
max-complexity: 20
21+
package-average: 10.0
22+
23+
exclusions:
24+
rules:
25+
- path: _test\.go$
26+
linters:
27+
- cyclop
28+
- errcheck
29+
30+
formatters:
31+
enable:
32+
- gci
33+
- gofmt
34+
settings:
35+
gci:
36+
custom-order: true
37+
sections:
38+
- standard
39+
- default
40+
- prefix(github.com/shahradelahi/wiresocks)

cmd/wiresocks/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ var rootCmd = &cobra.Command{
8989
sigChan := make(chan os.Signal, 1)
9090
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
9191
ctx, cancel := context.WithCancel(context.Background())
92+
defer cancel()
9293

9394
logLevel := wiresocks.LogLevelVerbose
9495
if silent {

proxy/socks5/common.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,6 @@ func readBytes(r io.Reader) ([]byte, error) {
167167
return bytes, nil
168168
}
169169

170-
func writeBytes(w io.Writer, b []byte) error {
171-
_, err := w.Write([]byte{byte(len(b))})
172-
if err != nil {
173-
return err
174-
}
175-
_, err = w.Write(b)
176-
return err
177-
}
178-
179170
func readByte(r io.Reader) (byte, error) {
180171
var buf [1]byte
181172
_, err := r.Read(buf[:])

proxy/socks5/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ func (s *Server) handleAssociate(req *request) error {
432432
if err != nil {
433433
return fmt.Errorf("failed to write UDP packet to source %s for SOCKS5 UDP ASSOCIATE: %w", sourceAddr.String(), err)
434434
}
435-
} else {
435+
} else { //nolint:staticcheck
436436
// Ignoring UDP packet from unknown source
437437
}
438438
}

proxy/statute/tunnel.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212

1313
// isClosedConnError reports whether err is an error from use of a closed
1414
// network connection.
15+
//
16+
//nolint:unused
1517
func isClosedConnError(err error) bool {
1618
if err == nil {
1719
return false
@@ -36,6 +38,7 @@ func isClosedConnError(err error) bool {
3638
return false
3739
}
3840

41+
//nolint:unused
3942
func errno(v error) uintptr {
4043
if rv := reflect.ValueOf(v); rv.Kind() == reflect.Uintptr {
4144
return uintptr(rv.Uint())
@@ -67,8 +70,10 @@ func Tunnel(ctx context.Context, c1, c2 io.ReadWriteCloser, buf1, buf2 []byte) e
6770
}
6871
}
6972

73+
//nolint:unused
7074
type tunnelErr [5]error
7175

76+
//nolint:unused
7277
func (t tunnelErr) FirstError() error {
7378
for _, err := range t {
7479
if err != nil {

vtun.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (vt VirtualTun) CheckConnectivity(ctx context.Context, url string, timeout
8484
DialContext: vt.Tnet.DialContext,
8585
}}
8686

87-
req, err := http.NewRequestWithContext(ctx, "HEAD", url, nil)
87+
req, err := http.NewRequestWithContext(ctx, http.MethodHead, url, nil)
8888
if err != nil {
8989
return fmt.Errorf("failed to create connectivity test request: %w", err)
9090
}

0 commit comments

Comments
 (0)