Update golangci-lint

This commit is contained in:
9seconds
2019-01-24 08:15:56 +03:00
parent 16558a7c55
commit f68b195306
8 changed files with 14 additions and 30 deletions
+1
View File
@@ -10,3 +10,4 @@ format = "colored-line-number"
[linters] [linters]
enable-all = true enable-all = true
disable = ["gochecknoglobals"]
+2 -10
View File
@@ -4,7 +4,7 @@ APP_NAME := $(IMAGE_NAME)
CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}") CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
GOLANGCI_LINT_VERSION := v1.11.2 GOLANGCI_LINT_VERSION := v1.13
VERSION_GO := $(shell go version) VERSION_GO := $(shell go version)
VERSION_DATE := $(shell date -Ru) VERSION_DATE := $(shell date -Ru)
@@ -59,10 +59,6 @@ test: vendor
lint: vendor lint: vendor
@$(MOD_OFF) golangci-lint run @$(MOD_OFF) golangci-lint run
.PHONY: critic
critic: vendor
@$(MOD_OFF) gocritic check-project "$(ROOT_DIR)"
.PHONY: clean .PHONY: clean
clean: clean:
@git clean -xfd && \ @git clean -xfd && \
@@ -74,13 +70,9 @@ docker:
@docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)" @docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"
.PHONY: prepare .PHONY: prepare
prepare: install-lint install-critic prepare: install-lint
.PHONY: install-lint .PHONY: install-lint
install-lint: install-lint:
@curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \ @curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
| $(MOD_OFF) bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION) | $(MOD_OFF) bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
.PHONY: install-critic
install-critic:
@$(MOD_OFF) go get -u github.com/go-critic/go-critic/...
+2 -2
View File
@@ -226,13 +226,13 @@ This tool will listen on port 3128 by default with the given secret.
# One-line runner # One-line runner
```console ```console
docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16) docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable $(openssl rand -hex 16)
``` ```
or in secret mode: or in secret mode:
```console ```console
docker run --name mtg --restart=unless-stopped -p 3128:3128 -q 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16) docker run --name mtg --restart=unless-stopped -p 3128:3128 -p 3129:3129 -d nineseconds/mtg:stable dd$(openssl rand -hex 16)
``` ```
You will have this tool up and running on port 3128. Now curl You will have this tool up and running on port 3128. Now curl
+1 -3
View File
@@ -138,13 +138,11 @@ var (
adtag = app.Arg("adtag", "ADTag of the proxy.").HexBytes() adtag = app.Arg("adtag", "ADTag of the proxy.").HexBytes()
) )
func init() { func main() { // nolint: gocyclo
rand.Seed(time.Now().UTC().UnixNano()) rand.Seed(time.Now().UTC().UnixNano())
app.Version(version) app.Version(version)
app.HelpFlag.Short('h') app.HelpFlag.Short('h')
}
func main() { // nolint: gocyclo
kingpin.MustParse(app.Parse(os.Args[1:])) kingpin.MustParse(app.Parse(os.Args[1:]))
err := setRLimit() err := setRLimit()
+2 -7
View File
@@ -23,11 +23,6 @@ var (
ProxyRequestExtraSize = []byte{0x18, 0x00, 0x00, 0x00} ProxyRequestExtraSize = []byte{0x18, 0x00, 0x00, 0x00}
ProxyRequestProxyTag = []byte{0xae, 0x26, 0x1e, 0xdb} ProxyRequestProxyTag = []byte{0xae, 0x26, 0x1e, 0xdb}
HandshakeSenderPID []byte
HandshakePeerPID []byte
)
func init() {
HandshakeSenderPID = []byte("IPIPPRPDTIME") HandshakeSenderPID = []byte("IPIPPRPDTIME")
HandshakePeerPID = []byte("IPIPPRPDTIME") HandshakePeerPID = []byte("IPIPPRPDTIME")
} )
+3 -3
View File
@@ -78,10 +78,10 @@ func TestFrameGenerateValid(t *testing.T) {
} }
for _, test := range validTests { for _, test := range validTests {
t.Run(strconv.Itoa(int(test)), func(tt *testing.T) { t.Run(strconv.Itoa(int(test)), func(tt *testing.T) {
frame := generateFrame(test) frame := generateFrame(test) // nolint: scopelint
conType, err := frame.ConnectionType() conType, err := frame.ConnectionType()
assert.Nil(t, err) assert.Nil(tt, err)
assert.Equal(t, conType, test) assert.Equal(tt, conType, test) // nolint: scopelint
}) })
} }
} }
+1 -1
View File
@@ -12,7 +12,7 @@ import (
func startServer(conf *config.Config, prometheusHandler http.Handler) { func startServer(conf *config.Config, prometheusHandler http.Handler) {
log := zap.S().Named("stats") log := zap.S().Named("stats")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
first, err := json.Marshal(GetStats()) first, err := json.Marshal(GetStats())
+2 -4
View File
@@ -5,12 +5,10 @@ import (
"sync" "sync"
) )
var streamCipherBufferPool sync.Pool var (
func init() {
streamCipherBufferPool = sync.Pool{ streamCipherBufferPool = sync.Pool{
New: func() interface{} { New: func() interface{} {
return &bytes.Buffer{} return &bytes.Buffer{}
}, },
} }
} )