mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-04 16:37:12 -05:00
vFormat: use gci instead of customized goimports (#1020)
This commit is contained in:
parent
ebd9adb0b5
commit
b57ebd5c1c
@ -1,4 +1,4 @@
|
|||||||
package core
|
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/
|
//go:generate go run ./infra/vformat/
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/build"
|
"go/build"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -42,7 +41,7 @@ func GetRuntimeEnv(key string) (string, error) {
|
|||||||
}
|
}
|
||||||
var data []byte
|
var data []byte
|
||||||
var runtimeEnv string
|
var runtimeEnv string
|
||||||
data, readErr := ioutil.ReadFile(file)
|
data, readErr := os.ReadFile(file)
|
||||||
if readErr != nil {
|
if readErr != nil {
|
||||||
return "", readErr
|
return "", readErr
|
||||||
}
|
}
|
||||||
@ -50,7 +49,7 @@ func GetRuntimeEnv(key string) (string, error) {
|
|||||||
for _, envItem := range envStrings {
|
for _, envItem := range envStrings {
|
||||||
envItem = strings.TrimSuffix(envItem, "\r")
|
envItem = strings.TrimSuffix(envItem, "\r")
|
||||||
envKeyValue := strings.Split(envItem, "=")
|
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])
|
runtimeEnv = strings.TrimSpace(envKeyValue[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,7 +122,7 @@ func main() {
|
|||||||
suffix = ".exe"
|
suffix = ".exe"
|
||||||
}
|
}
|
||||||
gofmt := "gofmt" + suffix
|
gofmt := "gofmt" + suffix
|
||||||
goimports := "goimports" + suffix
|
goimports := "gci" + suffix
|
||||||
|
|
||||||
if gofmtPath, err := exec.LookPath(gofmt); err != nil {
|
if gofmtPath, err := exec.LookPath(gofmt); err != nil {
|
||||||
fmt.Println("Can not find", gofmt, "in system path or current working directory.")
|
fmt.Println("Can not find", gofmt, "in system path or current working directory.")
|
||||||
@ -172,7 +171,6 @@ func main() {
|
|||||||
|
|
||||||
goimportsArgs := []string{
|
goimportsArgs := []string{
|
||||||
"-w",
|
"-w",
|
||||||
"-r",
|
|
||||||
"-local", "github.com/v2fly/v2ray-core",
|
"-local", "github.com/v2fly/v2ray-core",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package http
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "unsafe" // required to use //go:linkname
|
_ "unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:linkname readRequest net/http.readRequest
|
//go:linkname readRequest net/http.readRequest
|
||||||
|
Loading…
Reference in New Issue
Block a user