Просмотр исходного кода

Update golangci-lint

tags/0.16
9seconds 7 лет назад
Родитель
Сommit
f68b195306
8 измененных файлов: 14 добавлений и 30 удалений
  1. 1
    0
      .golangci.toml
  2. 2
    10
      Makefile
  3. 2
    2
      README.md
  4. 1
    3
      main.go
  5. 2
    7
      mtproto/rpc/rpc.go
  6. 3
    3
      obfuscated2/frame_test.go
  7. 1
    1
      stats/server.go
  8. 2
    4
      wrappers/streamcipher_pool.go

+ 1
- 0
.golangci.toml Просмотреть файл

10
 
10
 
11
 [linters]
11
 [linters]
12
 enable-all = true
12
 enable-all = true
13
+disable = ["gochecknoglobals"]

+ 2
- 10
Makefile Просмотреть файл

4
 
4
 
5
 CC_BINARIES  := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
5
 CC_BINARIES  := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
6
 
6
 
7
-GOLANGCI_LINT_VERSION := v1.11.2
7
+GOLANGCI_LINT_VERSION := v1.13
8
 
8
 
9
 VERSION_GO         := $(shell go version)
9
 VERSION_GO         := $(shell go version)
10
 VERSION_DATE       := $(shell date -Ru)
10
 VERSION_DATE       := $(shell date -Ru)
59
 lint: vendor
59
 lint: vendor
60
 	@$(MOD_OFF) golangci-lint run
60
 	@$(MOD_OFF) golangci-lint run
61
 
61
 
62
-.PHONY: critic
63
-critic: vendor
64
-	@$(MOD_OFF) gocritic check-project "$(ROOT_DIR)"
65
-
66
 .PHONY: clean
62
 .PHONY: clean
67
 clean:
63
 clean:
68
 	@git clean -xfd && \
64
 	@git clean -xfd && \
74
 	@docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
70
 	@docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
75
 
71
 
76
 .PHONY: prepare
72
 .PHONY: prepare
77
-prepare: install-lint install-critic
73
+prepare: install-lint
78
 
74
 
79
 .PHONY: install-lint
75
 .PHONY: install-lint
80
 install-lint:
76
 install-lint:
81
 	@curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
77
 	@curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
82
 		| $(MOD_OFF) bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
78
 		| $(MOD_OFF) bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
83
-
84
-.PHONY: install-critic
85
-install-critic:
86
-	@$(MOD_OFF) go get -u github.com/go-critic/go-critic/...

+ 2
- 2
README.md Просмотреть файл

226
 # One-line runner
226
 # One-line runner
227
 
227
 
228
 ```console
228
 ```console
229
-docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16)
229
+docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16)
230
 ```
230
 ```
231
 
231
 
232
 or in secret mode:
232
 or in secret mode:
233
 
233
 
234
 ```console
234
 ```console
235
-docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16)
235
+docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16)
236
 ```
236
 ```
237
 
237
 
238
 You will have this tool up and running on port 3128. Now curl
238
 You will have this tool up and running on port 3128. Now curl

+ 1
- 3
main.go Просмотреть файл

138
 	adtag  = app.Arg("adtag", "ADTag of the proxy.").HexBytes()
138
 	adtag  = app.Arg("adtag", "ADTag of the proxy.").HexBytes()
139
 )
139
 )
140
 
140
 
141
-func init() {
141
+func main() { // nolint: gocyclo
142
 	rand.Seed(time.Now().UTC().UnixNano())
142
 	rand.Seed(time.Now().UTC().UnixNano())
143
 	app.Version(version)
143
 	app.Version(version)
144
 	app.HelpFlag.Short('h')
144
 	app.HelpFlag.Short('h')
145
-}
146
 
145
 
147
-func main() { // nolint: gocyclo
148
 	kingpin.MustParse(app.Parse(os.Args[1:]))
146
 	kingpin.MustParse(app.Parse(os.Args[1:]))
149
 
147
 
150
 	err := setRLimit()
148
 	err := setRLimit()

+ 2
- 7
mtproto/rpc/rpc.go Просмотреть файл

23
 	ProxyRequestExtraSize = []byte{0x18, 0x00, 0x00, 0x00}
23
 	ProxyRequestExtraSize = []byte{0x18, 0x00, 0x00, 0x00}
24
 	ProxyRequestProxyTag  = []byte{0xae, 0x26, 0x1e, 0xdb}
24
 	ProxyRequestProxyTag  = []byte{0xae, 0x26, 0x1e, 0xdb}
25
 
25
 
26
-	HandshakeSenderPID []byte
27
-	HandshakePeerPID   []byte
28
-)
29
-
30
-func init() {
31
 	HandshakeSenderPID = []byte("IPIPPRPDTIME")
26
 	HandshakeSenderPID = []byte("IPIPPRPDTIME")
32
-	HandshakePeerPID = []byte("IPIPPRPDTIME")
33
-}
27
+	HandshakePeerPID   = []byte("IPIPPRPDTIME")
28
+)

+ 3
- 3
obfuscated2/frame_test.go Просмотреть файл

78
 	}
78
 	}
79
 	for _, test := range validTests {
79
 	for _, test := range validTests {
80
 		t.Run(strconv.Itoa(int(test)), func(tt *testing.T) {
80
 		t.Run(strconv.Itoa(int(test)), func(tt *testing.T) {
81
-			frame := generateFrame(test)
81
+			frame := generateFrame(test) // nolint: scopelint
82
 			conType, err := frame.ConnectionType()
82
 			conType, err := frame.ConnectionType()
83
-			assert.Nil(t, err)
84
-			assert.Equal(t, conType, test)
83
+			assert.Nil(tt, err)
84
+			assert.Equal(tt, conType, test) // nolint: scopelint
85
 		})
85
 		})
86
 	}
86
 	}
87
 }
87
 }

+ 1
- 1
stats/server.go Просмотреть файл

12
 func startServer(conf *config.Config, prometheusHandler http.Handler) {
12
 func startServer(conf *config.Config, prometheusHandler http.Handler) {
13
 	log := zap.S().Named("stats")
13
 	log := zap.S().Named("stats")
14
 
14
 
15
-	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
15
+	http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
16
 		w.Header().Set("Content-Type", "application/json")
16
 		w.Header().Set("Content-Type", "application/json")
17
 
17
 
18
 		first, err := json.Marshal(GetStats())
18
 		first, err := json.Marshal(GetStats())

+ 2
- 4
wrappers/streamcipher_pool.go Просмотреть файл

5
 	"sync"
5
 	"sync"
6
 )
6
 )
7
 
7
 
8
-var streamCipherBufferPool sync.Pool
9
-
10
-func init() {
8
+var (
11
 	streamCipherBufferPool = sync.Pool{
9
 	streamCipherBufferPool = sync.Pool{
12
 		New: func() interface{} {
10
 		New: func() interface{} {
13
 			return &bytes.Buffer{}
11
 			return &bytes.Buffer{}
14
 		},
12
 		},
15
 	}
13
 	}
16
-}
14
+)

Загрузка…
Отмена
Сохранить