Browse Source

Fix: format & lint (#1759)

* Fix: gci command for formatting code
* Chore: format code
* Fix: replace golint with revive
Loyalsoldier 3 years ago
parent
commit
6dce0d98c1

+ 7 - 5
.github/linters/.golangci.yml

@@ -2,14 +2,12 @@ run:
   timeout: 5m
   timeout: 5m
   skip-files:
   skip-files:
     - generated.*
     - generated.*
-
 issues:
 issues:
   new: true
   new: true
   exclude-rules:
   exclude-rules:
     - linters:
     - linters:
-      - staticcheck
+        - staticcheck
       text: "SA1019:"
       text: "SA1019:"
-
 linters:
 linters:
   enable:
   enable:
     - asciicheck
     - asciicheck
@@ -19,13 +17,13 @@ linters:
     - gofmt
     - gofmt
     - gofumpt
     - gofumpt
     - goimports
     - goimports
-    - golint
     - goprintffuncname
     - goprintffuncname
     - gosimple
     - gosimple
     - govet
     - govet
     - ineffassign
     - ineffassign
     - misspell
     - misspell
     - nakedret
     - nakedret
+    - revive
     - rowserrcheck
     - rowserrcheck
     - staticcheck
     - staticcheck
     - structcheck
     - structcheck
@@ -39,7 +37,11 @@ linters:
     - deadcode
     - deadcode
     - errcheck
     - errcheck
     - unused
     - unused
-
 linters-settings:
 linters-settings:
   goimports:
   goimports:
     local-prefixes: github.com/v2fly/v2ray-core
     local-prefixes: github.com/v2fly/v2ray-core
+  revive:
+    rules:
+      - name: blank-imports
+        severity: warning
+        disabled: true

+ 6 - 2
infra/vformat/main.go

@@ -170,8 +170,12 @@ func main() {
 	}
 	}
 
 
 	goimportsArgs := []string{
 	goimportsArgs := []string{
-		"-w",
-		"-local", "github.com/v2fly/v2ray-core",
+		"write",
+		"--NoInlineComments",
+		"--NoPrefixComments",
+		"--Section", "Standard",
+		"--Section", "Default",
+		"--Section", "pkgPrefix(github.com/v2fly/v2ray-core)",
 	}
 	}
 
 
 	RunMany(gofmt, gofmtArgs, rawFilesSlice)
 	RunMany(gofmt, gofmtArgs, rawFilesSlice)

+ 1 - 1
proxy/vmess/encoding/commands_test.go

@@ -1,10 +1,10 @@
 package encoding_test
 package encoding_test
 
 
 import (
 import (
-	"github.com/stretchr/testify/assert"
 	"testing"
 	"testing"
 
 
 	"github.com/google/go-cmp/cmp"
 	"github.com/google/go-cmp/cmp"
+	"github.com/stretchr/testify/assert"
 
 
 	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common/buf"
 	"github.com/v2fly/v2ray-core/v4/common/buf"

+ 0 - 2
transport/internet/headers/http/linkedreadRequest.go

@@ -3,8 +3,6 @@ package http
 import (
 import (
 	"bufio"
 	"bufio"
 	"net/http"
 	"net/http"
-
-	// required to use go:linkname
 	_ "unsafe"
 	_ "unsafe"
 )
 )