Skip to content

Commit

Permalink
vFormat: use gci instead of customized goimports (v2fly#1020)
Browse files Browse the repository at this point in the history
  • Loading branch information
Loyalsoldier authored May 19, 2021
1 parent ebd9adb commit b57ebd5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion format.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package core

//go:generate go install -v github.com/v2fly/tools/cmd/goimports@latest
//go:generate go install -v github.com/daixiang0/gci@latest
//go:generate go run ./infra/vformat/
8 changes: 3 additions & 5 deletions infra/vformat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"go/build"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
Expand Down Expand Up @@ -42,15 +41,15 @@ func GetRuntimeEnv(key string) (string, error) {
}
var data []byte
var runtimeEnv string
data, readErr := ioutil.ReadFile(file)
data, readErr := os.ReadFile(file)
if readErr != nil {
return "", readErr
}
envStrings := strings.Split(string(data), "\n")
for _, envItem := range envStrings {
envItem = strings.TrimSuffix(envItem, "\r")
envKeyValue := strings.Split(envItem, "=")
if strings.EqualFold(strings.TrimSpace(envKeyValue[0]), key) {
if len(envKeyValue) == 2 && strings.TrimSpace(envKeyValue[0]) == key {
runtimeEnv = strings.TrimSpace(envKeyValue[1])
}
}
Expand Down Expand Up @@ -123,7 +122,7 @@ func main() {
suffix = ".exe"
}
gofmt := "gofmt" + suffix
goimports := "goimports" + suffix
goimports := "gci" + suffix

if gofmtPath, err := exec.LookPath(gofmt); err != nil {
fmt.Println("Can not find", gofmt, "in system path or current working directory.")
Expand Down Expand Up @@ -172,7 +171,6 @@ func main() {

goimportsArgs := []string{
"-w",
"-r",
"-local", "github.com/v2fly/v2ray-core",
}

Expand Down
2 changes: 1 addition & 1 deletion transport/internet/headers/http/linkedreadRequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package http
import (
"bufio"
"net/http"
_ "unsafe" // required to use //go:linkname
_ "unsafe"
)

//go:linkname readRequest net/http.readRequest
Expand Down

0 comments on commit b57ebd5

Please sign in to comment.