Browse Source

Chore: format code to fix lint (#1426)

Loyalsoldier 4 years ago
parent
commit
43447aa2e4
47 changed files with 55 additions and 78 deletions
  1. 1 2
      app/dispatcher/fakednssniffer.go
  2. 0 1
      app/dns/dns.go
  3. 0 1
      app/log/log.go
  4. 0 1
      app/observatory/burst/burstobserver.go
  5. 1 1
      app/reverse/portal.go
  6. 5 0
      app/router/strategy_leastload_test.go
  7. 1 1
      common/crypto/internal/chacha_core.generated.go
  8. 0 2
      common/environment/app.go
  9. 0 1
      common/environment/connection.go
  10. 1 2
      common/environment/envimpl/fs.go
  11. 0 3
      common/environment/proxy.go
  12. 0 2
      common/environment/transport.go
  13. 0 1
      common/interfaces.go
  14. 0 1
      common/net/address.go
  15. 0 1
      common/protocol/address.go
  16. 1 2
      common/protocol/bittorrent/bittorrent.go
  17. 1 2
      common/protocol/quic/sniff.go
  18. 1 2
      common/registry/registry.go
  19. 1 2
      common/serial/resolver.go
  20. 2 0
      common/serial/typed_message.go
  21. 4 2
      common/units/bytesize.go
  22. 0 1
      features/extension/instance.go
  23. 0 1
      features/extension/observatory.go
  24. 0 1
      features/extension/storage.go
  25. 0 2
      features/extension/storage/storage.go
  26. 1 0
      infra/conf/json/toml_test.go
  27. 1 0
      infra/conf/json/yaml_test.go
  28. 1 0
      infra/conf/merge/merge_test.go
  29. 4 2
      infra/conf/merge/rules.go
  30. 0 1
      infra/conf/synthetic/dns/dns.go
  31. 6 9
      infra/conf/synthetic/router/router_strategy.go
  32. 0 4
      infra/conf/v2jsonpb/follower.go
  33. 2 0
      infra/conf/v2jsonpb/followerany.go
  34. 0 1
      main/commands/all/api/balancer_info.go
  35. 0 2
      main/commands/all/engineering/convertpb.go
  36. 0 1
      main/commands/all/engineering/engineering.go
  37. 2 1
      main/commands/all/engineering/reversepb.go
  38. 1 0
      main/commands/all/jsonv4/convert.go
  39. 1 3
      main/commands/all/tls/ping.go
  40. 1 3
      main/commands/all/verify.go
  41. 4 2
      main/commands/base/command.go
  42. 1 1
      main/distro/all/all.go
  43. 0 1
      main/v2binding/v2binding.go
  44. 1 1
      proxy/freedom/freedom.go
  45. 0 2
      proxy/shadowsocks/protocol.go
  46. 9 8
      proxy/trojan/simplified/config.go
  47. 1 1
      v2ray_test.go

+ 1 - 2
app/dispatcher/fakednssniffer.go

@@ -86,8 +86,7 @@ func (f DNSThenOthersSniffResult) Domain() string {
 	return f.domainName
 	return f.domainName
 }
 }
 
 
-func newFakeDNSThenOthers(ctx context.Context, fakeDNSSniffer protocolSnifferWithMetadata, others []protocolSnifferWithMetadata) (
-	protocolSnifferWithMetadata, error) { // nolint: unparam
+func newFakeDNSThenOthers(ctx context.Context, fakeDNSSniffer protocolSnifferWithMetadata, others []protocolSnifferWithMetadata) (protocolSnifferWithMetadata, error) { // nolint: unparam
 	// ctx may be used in the future
 	// ctx may be used in the future
 	_ = ctx
 	_ = ctx
 	return protocolSnifferWithMetadata{
 	return protocolSnifferWithMetadata{

+ 0 - 1
app/dns/dns.go

@@ -316,7 +316,6 @@ func init() {
 	}))
 	}))
 
 
 	common.Must(common.RegisterConfig((*SimplifiedConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
 	common.Must(common.RegisterConfig((*SimplifiedConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
-
 		ctx = cfgcommon.NewConfigureLoadingContext(context.Background())
 		ctx = cfgcommon.NewConfigureLoadingContext(context.Background())
 
 
 		geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string {
 		geoloadername := platform.NewEnvFlag("v2ray.conf.geoloader").GetValue(func() string {

+ 0 - 1
app/log/log.go

@@ -23,7 +23,6 @@ type Instance struct {
 
 
 // New creates a new log.Instance based on the given config.
 // New creates a new log.Instance based on the given config.
 func New(ctx context.Context, config *Config) (*Instance, error) {
 func New(ctx context.Context, config *Config) (*Instance, error) {
-
 	if config.Error == nil {
 	if config.Error == nil {
 		config.Error = &LogSpecification{Type: LogType_Console, Level: log.Severity_Warning}
 		config.Error = &LogSpecification{Type: LogType_Console, Level: log.Severity_Warning}
 	}
 	}

+ 0 - 1
app/observatory/burst/burstobserver.go

@@ -66,7 +66,6 @@ func (o *Observer) Start() error {
 		o.hp.StartScheduler(func() ([]string, error) {
 		o.hp.StartScheduler(func() ([]string, error) {
 			hs, ok := o.ohm.(outbound.HandlerSelector)
 			hs, ok := o.ohm.(outbound.HandlerSelector)
 			if !ok {
 			if !ok {
-
 				return nil, newError("outbound.Manager is not a HandlerSelector")
 				return nil, newError("outbound.Manager is not a HandlerSelector")
 			}
 			}
 
 

+ 1 - 1
app/reverse/portal.go

@@ -152,7 +152,7 @@ func (p *StaticMuxPicker) PickAvailable() (*mux.ClientWorker, error) {
 		return nil, newError("empty worker list")
 		return nil, newError("empty worker list")
 	}
 	}
 
 
-	var minIdx = -1
+	minIdx := -1
 	var minConn uint32 = 9999
 	var minConn uint32 = 9999
 	for i, w := range p.workers {
 	for i, w := range p.workers {
 		if w.draining {
 		if w.draining {

+ 5 - 0
app/router/strategy_leastload_test.go

@@ -85,6 +85,7 @@ func TestSelectLeastExpected(t *testing.T) {
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 	}
 	}
 }
 }
+
 func TestSelectLeastExpected2(t *testing.T) {
 func TestSelectLeastExpected2(t *testing.T) {
 	strategy := &LeastLoadStrategy{
 	strategy := &LeastLoadStrategy{
 		settings: &StrategyLeastLoadConfig{
 		settings: &StrategyLeastLoadConfig{
@@ -102,6 +103,7 @@ func TestSelectLeastExpected2(t *testing.T) {
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 	}
 	}
 }
 }
+
 func TestSelectLeastExpectedAndBaselines(t *testing.T) {
 func TestSelectLeastExpectedAndBaselines(t *testing.T) {
 	strategy := &LeastLoadStrategy{
 	strategy := &LeastLoadStrategy{
 		settings: &StrategyLeastLoadConfig{
 		settings: &StrategyLeastLoadConfig{
@@ -122,6 +124,7 @@ func TestSelectLeastExpectedAndBaselines(t *testing.T) {
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 	}
 	}
 }
 }
+
 func TestSelectLeastExpectedAndBaselines2(t *testing.T) {
 func TestSelectLeastExpectedAndBaselines2(t *testing.T) {
 	strategy := &LeastLoadStrategy{
 	strategy := &LeastLoadStrategy{
 		settings: &StrategyLeastLoadConfig{
 		settings: &StrategyLeastLoadConfig{
@@ -142,6 +145,7 @@ func TestSelectLeastExpectedAndBaselines2(t *testing.T) {
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 	}
 	}
 }
 }
+
 func TestSelectLeastLoadBaselines(t *testing.T) {
 func TestSelectLeastLoadBaselines(t *testing.T) {
 	strategy := &LeastLoadStrategy{
 	strategy := &LeastLoadStrategy{
 		settings: &StrategyLeastLoadConfig{
 		settings: &StrategyLeastLoadConfig{
@@ -160,6 +164,7 @@ func TestSelectLeastLoadBaselines(t *testing.T) {
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 		t.Errorf("expected: %v, actual: %v", expected, len(ns))
 	}
 	}
 }
 }
+
 func TestSelectLeastLoadBaselinesNoQualified(t *testing.T) {
 func TestSelectLeastLoadBaselinesNoQualified(t *testing.T) {
 	strategy := &LeastLoadStrategy{
 	strategy := &LeastLoadStrategy{
 		settings: &StrategyLeastLoadConfig{
 		settings: &StrategyLeastLoadConfig{

+ 1 - 1
common/crypto/internal/chacha_core.generated.go

@@ -3,7 +3,7 @@ package internal
 import "encoding/binary"
 import "encoding/binary"
 
 
 func ChaCha20Block(s *[16]uint32, out []byte, rounds int) {
 func ChaCha20Block(s *[16]uint32, out []byte, rounds int) {
-	var x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 = s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], s[12], s[13], s[14], s[15]
+	x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 := s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], s[8], s[9], s[10], s[11], s[12], s[13], s[14], s[15]
 	for i := 0; i < rounds; i += 2 {
 	for i := 0; i < rounds; i += 2 {
 		var x uint32
 		var x uint32
 
 

+ 0 - 2
common/environment/app.go

@@ -9,14 +9,12 @@ type AppEnvironmentCapabilitySet interface {
 	SystemNetworkCapabilitySet
 	SystemNetworkCapabilitySet
 	InstanceNetworkCapabilitySet
 	InstanceNetworkCapabilitySet
 	FileSystemCapabilitySet
 	FileSystemCapabilitySet
-
 	PersistentStorage() storage.ScopedPersistentStorage
 	PersistentStorage() storage.ScopedPersistentStorage
 	TransientStorage() storage.ScopedTransientStorage
 	TransientStorage() storage.ScopedTransientStorage
 }
 }
 
 
 type AppEnvironment interface {
 type AppEnvironment interface {
 	AppEnvironmentCapabilitySet
 	AppEnvironmentCapabilitySet
-
 	NarrowScope(key []byte) (AppEnvironment, error)
 	NarrowScope(key []byte) (AppEnvironment, error)
 	doNotImpl()
 	doNotImpl()
 }
 }

+ 0 - 1
common/environment/connection.go

@@ -8,7 +8,6 @@ type ConnectionCapabilitySet interface {
 
 
 type ConnectionEnvironment interface {
 type ConnectionEnvironment interface {
 	ConnectionCapabilitySet
 	ConnectionCapabilitySet
-
 	doNotImpl()
 	doNotImpl()
 }
 }
 
 

+ 1 - 2
common/environment/envimpl/fs.go

@@ -6,8 +6,7 @@ import (
 	"github.com/v2fly/v2ray-core/v4/common/platform/filesystem/fsifce"
 	"github.com/v2fly/v2ray-core/v4/common/platform/filesystem/fsifce"
 )
 )
 
 
-type fileSystemDefaultImpl struct {
-}
+type fileSystemDefaultImpl struct{}
 
 
 func (f fileSystemDefaultImpl) OpenFileForReadSeek() fsifce.FileSeekerFunc {
 func (f fileSystemDefaultImpl) OpenFileForReadSeek() fsifce.FileSeekerFunc {
 	return filesystem.NewFileSeeker
 	return filesystem.NewFileSeeker

+ 0 - 3
common/environment/proxy.go

@@ -7,15 +7,12 @@ import (
 type ProxyEnvironmentCapabilitySet interface {
 type ProxyEnvironmentCapabilitySet interface {
 	BaseEnvironmentCapabilitySet
 	BaseEnvironmentCapabilitySet
 	InstanceNetworkCapabilitySet
 	InstanceNetworkCapabilitySet
-
 	TransientStorage() storage.ScopedTransientStorage
 	TransientStorage() storage.ScopedTransientStorage
 }
 }
 
 
 type ProxyEnvironment interface {
 type ProxyEnvironment interface {
 	ProxyEnvironmentCapabilitySet
 	ProxyEnvironmentCapabilitySet
-
 	NarrowScope(key []byte) (ProxyEnvironment, error)
 	NarrowScope(key []byte) (ProxyEnvironment, error)
 	NarrowScopeToTransport(key []byte) (TransportEnvironment, error)
 	NarrowScopeToTransport(key []byte) (TransportEnvironment, error)
-
 	doNotImpl()
 	doNotImpl()
 }
 }

+ 0 - 2
common/environment/transport.go

@@ -8,13 +8,11 @@ type TransportEnvironmentCapacitySet interface {
 	BaseEnvironmentCapabilitySet
 	BaseEnvironmentCapabilitySet
 	SystemNetworkCapabilitySet
 	SystemNetworkCapabilitySet
 	InstanceNetworkCapabilitySet
 	InstanceNetworkCapabilitySet
-
 	TransientStorage() storage.ScopedTransientStorage
 	TransientStorage() storage.ScopedTransientStorage
 }
 }
 
 
 type TransportEnvironment interface {
 type TransportEnvironment interface {
 	TransportEnvironmentCapacitySet
 	TransportEnvironmentCapacitySet
-
 	NarrowScope(key []byte) (TransportEnvironment, error)
 	NarrowScope(key []byte) (TransportEnvironment, error)
 	doNotImpl()
 	doNotImpl()
 }
 }

+ 0 - 1
common/interfaces.go

@@ -42,7 +42,6 @@ func Interrupt(obj interface{}) error {
 type Runnable interface {
 type Runnable interface {
 	// Start starts the runnable object. Upon the method returning nil, the object begins to function properly.
 	// Start starts the runnable object. Upon the method returning nil, the object begins to function properly.
 	Start() error
 	Start() error
-
 	Closable
 	Closable
 }
 }
 
 

+ 0 - 1
common/net/address.go

@@ -66,7 +66,6 @@ type Address interface {
 	IP() net.IP     // IP of this Address
 	IP() net.IP     // IP of this Address
 	Domain() string // Domain of this Address
 	Domain() string // Domain of this Address
 	Family() AddressFamily
 	Family() AddressFamily
-
 	String() string // String representation of this Address
 	String() string // String representation of this Address
 }
 }
 
 

+ 0 - 1
common/protocol/address.go

@@ -37,7 +37,6 @@ func WithAddressTypeParser(atp AddressTypeParser) AddressOption {
 
 
 type AddressSerializer interface {
 type AddressSerializer interface {
 	ReadAddressPort(buffer *buf.Buffer, input io.Reader) (net.Address, net.Port, error)
 	ReadAddressPort(buffer *buf.Buffer, input io.Reader) (net.Address, net.Port, error)
-
 	WriteAddressPort(writer io.Writer, addr net.Address, port net.Port) error
 	WriteAddressPort(writer io.Writer, addr net.Address, port net.Port) error
 }
 }
 
 

+ 1 - 2
common/protocol/bittorrent/bittorrent.go

@@ -6,9 +6,8 @@ import (
 	"math"
 	"math"
 	"time"
 	"time"
 
 
-	"github.com/v2fly/v2ray-core/v4/common/buf"
-
 	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common"
+	"github.com/v2fly/v2ray-core/v4/common/buf"
 )
 )
 
 
 type SniffHeader struct{}
 type SniffHeader struct{}

+ 1 - 2
common/protocol/quic/sniff.go

@@ -7,14 +7,13 @@ import (
 	"encoding/binary"
 	"encoding/binary"
 	"io"
 	"io"
 
 
-	"github.com/v2fly/v2ray-core/v4/common/errors"
-
 	"github.com/lucas-clemente/quic-go/quicvarint"
 	"github.com/lucas-clemente/quic-go/quicvarint"
 	"github.com/marten-seemann/qtls-go1-17"
 	"github.com/marten-seemann/qtls-go1-17"
 	"golang.org/x/crypto/hkdf"
 	"golang.org/x/crypto/hkdf"
 
 
 	"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"
+	"github.com/v2fly/v2ray-core/v4/common/errors"
 	ptls "github.com/v2fly/v2ray-core/v4/common/protocol/tls"
 	ptls "github.com/v2fly/v2ray-core/v4/common/protocol/tls"
 )
 )
 
 

+ 1 - 2
common/registry/registry.go

@@ -77,7 +77,6 @@ func (i *implementationRegistry) LoadImplementationByAlias(ctx context.Context,
 	}
 	}
 
 
 	return implementationConfigInstance.(proto.Message), nil
 	return implementationConfigInstance.(proto.Message), nil
-
 }
 }
 
 
 func newImplementationRegistry() *implementationRegistry {
 func newImplementationRegistry() *implementationRegistry {
@@ -107,7 +106,7 @@ func RegisterImplementation(proto interface{}, loader CustomLoader) error {
 
 
 func registerImplementation(proto interface{}, loader CustomLoader) error {
 func registerImplementation(proto interface{}, loader CustomLoader) error {
 	protoReflect := reflect.New(reflect.TypeOf(proto).Elem())
 	protoReflect := reflect.New(reflect.TypeOf(proto).Elem())
-	var proto2 = protoReflect.Interface().(protov2.Message)
+	proto2 := protoReflect.Interface().(protov2.Message)
 	msgDesc := proto2.ProtoReflect().Descriptor()
 	msgDesc := proto2.ProtoReflect().Descriptor()
 	fullName := string(msgDesc.FullName())
 	fullName := string(msgDesc.FullName())
 	msgOpts, err := protoext.GetMessageOptions(msgDesc)
 	msgOpts, err := protoext.GetMessageOptions(msgDesc)

+ 1 - 2
common/serial/resolver.go

@@ -8,8 +8,7 @@ type AnyResolver interface {
 	Resolve(typeURL string) (proto.Message, error)
 	Resolve(typeURL string) (proto.Message, error)
 }
 }
 
 
-type serialResolver struct {
-}
+type serialResolver struct{}
 
 
 func (s serialResolver) Resolve(typeURL string) (proto.Message, error) {
 func (s serialResolver) Resolve(typeURL string) (proto.Message, error) {
 	instance, err := GetInstance(typeURL)
 	instance, err := GetInstance(typeURL)

+ 2 - 0
common/serial/typed_message.go

@@ -52,9 +52,11 @@ func GetInstanceOf(v *anypb.Any) (proto.Message, error) {
 func V2Type(v *anypb.Any) string {
 func V2Type(v *anypb.Any) string {
 	return V2TypeFromURL(v.TypeUrl)
 	return V2TypeFromURL(v.TypeUrl)
 }
 }
+
 func V2TypeFromURL(string2 string) string {
 func V2TypeFromURL(string2 string) string {
 	return strings.TrimPrefix(string2, V2RayTypeURLHeader)
 	return strings.TrimPrefix(string2, V2RayTypeURLHeader)
 }
 }
+
 func V2TypeHumanReadable(v *anypb.Any) string {
 func V2TypeHumanReadable(v *anypb.Any) string {
 	return v.TypeUrl
 	return v.TypeUrl
 }
 }

+ 4 - 2
common/units/bytesize.go

@@ -7,8 +7,10 @@ import (
 	"unicode"
 	"unicode"
 )
 )
 
 
-var errInvalidSize = errors.New("invalid size")
-var errInvalidUnit = errors.New("invalid or unsupported unit")
+var (
+	errInvalidSize = errors.New("invalid size")
+	errInvalidUnit = errors.New("invalid or unsupported unit")
+)
 
 
 // ByteSize is the size of bytes
 // ByteSize is the size of bytes
 type ByteSize uint64
 type ByteSize uint64

+ 0 - 1
features/extension/instance.go

@@ -9,7 +9,6 @@ import (
 // InstanceManagement : unstable
 // InstanceManagement : unstable
 type InstanceManagement interface {
 type InstanceManagement interface {
 	features.Feature
 	features.Feature
-
 	ListInstance(ctx context.Context) ([]string, error)
 	ListInstance(ctx context.Context) ([]string, error)
 	AddInstance(ctx context.Context, name string, config []byte, configType string) error
 	AddInstance(ctx context.Context, name string, config []byte, configType string) error
 	StartInstance(ctx context.Context, name string) error
 	StartInstance(ctx context.Context, name string) error

+ 0 - 1
features/extension/observatory.go

@@ -10,7 +10,6 @@ import (
 
 
 type Observatory interface {
 type Observatory interface {
 	features.Feature
 	features.Feature
-
 	GetObservation(ctx context.Context) (proto.Message, error)
 	GetObservation(ctx context.Context) (proto.Message, error)
 }
 }
 
 

+ 0 - 1
features/extension/storage.go

@@ -8,7 +8,6 @@ import (
 
 
 type PersistentStorageEngine interface {
 type PersistentStorageEngine interface {
 	features.Feature
 	features.Feature
-
 	PersistentStorageEngine()
 	PersistentStorageEngine()
 	Put(ctx context.Context, key []byte, value []byte) error
 	Put(ctx context.Context, key []byte, value []byte) error
 	Get(ctx context.Context, key []byte) ([]byte, error)
 	Get(ctx context.Context, key []byte) ([]byte, error)

+ 0 - 2
features/extension/storage/storage.go

@@ -6,11 +6,9 @@ import (
 
 
 type ScopedPersistentStorage interface {
 type ScopedPersistentStorage interface {
 	ScopedPersistentStorageEngine()
 	ScopedPersistentStorageEngine()
-
 	Put(ctx context.Context, key []byte, value []byte) error
 	Put(ctx context.Context, key []byte, value []byte) error
 	Get(ctx context.Context, key []byte) ([]byte, error)
 	Get(ctx context.Context, key []byte) ([]byte, error)
 	List(ctx context.Context, keyPrefix []byte) ([][]byte, error)
 	List(ctx context.Context, keyPrefix []byte) ([][]byte, error)
-
 	ClearIfCharacteristicMismatch(ctx context.Context, characteristic []byte) error
 	ClearIfCharacteristicMismatch(ctx context.Context, characteristic []byte) error
 	NarrowScope(ctx context.Context, key []byte) (ScopedPersistentStorage, error)
 	NarrowScope(ctx context.Context, key []byte) (ScopedPersistentStorage, error)
 }
 }

+ 1 - 0
infra/conf/json/toml_test.go

@@ -70,6 +70,7 @@ security = 'tls'
 	json.Unmarshal(bs, &m)
 	json.Unmarshal(bs, &m)
 	assertResult(t, m, expected)
 	assertResult(t, m, expected)
 }
 }
+
 func TestTOMLToJSON_ValueTypes(t *testing.T) {
 func TestTOMLToJSON_ValueTypes(t *testing.T) {
 	input := `
 	input := `
 boolean = [ true, false, true, false ]
 boolean = [ true, false, true, false ]

+ 1 - 0
infra/conf/json/yaml_test.go

@@ -67,6 +67,7 @@ outbounds:
 	json.Unmarshal(bs, &m)
 	json.Unmarshal(bs, &m)
 	assertResult(t, m, expected)
 	assertResult(t, m, expected)
 }
 }
+
 func TestYMLToJSON_ValueTypes(t *testing.T) {
 func TestYMLToJSON_ValueTypes(t *testing.T) {
 	input := `
 	input := `
 boolean: 
 boolean: 

+ 1 - 0
infra/conf/merge/merge_test.go

@@ -193,6 +193,7 @@ func TestMergeTagDeep(t *testing.T) {
 	}
 	}
 	assertResult(t, m, expected)
 	assertResult(t, m, expected)
 }
 }
+
 func assertResult(t *testing.T, value []byte, expected string) {
 func assertResult(t *testing.T, value []byte, expected string) {
 	v := make(map[string]interface{})
 	v := make(map[string]interface{})
 	err := serial.DecodeJSON(bytes.NewReader(value), &v)
 	err := serial.DecodeJSON(bytes.NewReader(value), &v)

+ 4 - 2
infra/conf/merge/rules.go

@@ -4,8 +4,10 @@
 
 
 package merge
 package merge
 
 
-const priorityKey string = "_priority"
-const tagKey string = "_tag"
+const (
+	priorityKey string = "_priority"
+	tagKey      string = "_tag"
+)
 
 
 // ApplyRules applies merge rules according to _tag, _priority fields, and remove them
 // ApplyRules applies merge rules according to _tag, _priority fields, and remove them
 func ApplyRules(m map[string]interface{}) error {
 func ApplyRules(m map[string]interface{}) error {

+ 0 - 1
infra/conf/synthetic/dns/dns.go

@@ -204,7 +204,6 @@ func (c *DNSConfig) BuildV5(ctx context.Context) (*dns.Config, error) {
 
 
 // Build implements Buildable
 // Build implements Buildable
 func (c *DNSConfig) Build() (*dns.Config, error) {
 func (c *DNSConfig) Build() (*dns.Config, error) {
-
 	if c.cfgctx == nil {
 	if c.cfgctx == nil {
 		c.cfgctx = cfgcommon.NewConfigureLoadingContext(context.Background())
 		c.cfgctx = cfgcommon.NewConfigureLoadingContext(context.Background())
 
 

+ 6 - 9
infra/conf/synthetic/router/router_strategy.go

@@ -15,16 +15,13 @@ const (
 	strategyLeastPing string = "leastping"
 	strategyLeastPing string = "leastping"
 )
 )
 
 
-var (
-	strategyConfigLoader = loader.NewJSONConfigLoader(loader.ConfigCreatorCache{
-		strategyRandom:    func() interface{} { return new(strategyEmptyConfig) },
-		strategyLeastLoad: func() interface{} { return new(strategyLeastLoadConfig) },
-		strategyLeastPing: func() interface{} { return new(strategyLeastPingConfig) },
-	}, "type", "settings")
-)
+var strategyConfigLoader = loader.NewJSONConfigLoader(loader.ConfigCreatorCache{
+	strategyRandom:    func() interface{} { return new(strategyEmptyConfig) },
+	strategyLeastLoad: func() interface{} { return new(strategyLeastLoadConfig) },
+	strategyLeastPing: func() interface{} { return new(strategyLeastPingConfig) },
+}, "type", "settings")
 
 
-type strategyEmptyConfig struct {
-}
+type strategyEmptyConfig struct{}
 
 
 func (v *strategyEmptyConfig) Build() (proto.Message, error) {
 func (v *strategyEmptyConfig) Build() (proto.Message, error) {
 	return nil, nil
 	return nil, nil

+ 0 - 4
infra/conf/v2jsonpb/follower.go

@@ -33,7 +33,6 @@ func (v *V2JsonProtobufFollower) Range(f func(protoreflect.FieldDescriptor, prot
 		name := descriptor.FullName()
 		name := descriptor.FullName()
 		fullname := v.Message.Descriptor().FullName()
 		fullname := v.Message.Descriptor().FullName()
 		if fullname == "google.protobuf.Any" {
 		if fullname == "google.protobuf.Any" {
-
 			switch name {
 			switch name {
 			case "google.protobuf.Any.type_url":
 			case "google.protobuf.Any.type_url":
 				fd := V2JsonProtobufAnyTypeFieldDescriptor{descriptor}
 				fd := V2JsonProtobufAnyTypeFieldDescriptor{descriptor}
@@ -58,7 +57,6 @@ func (v *V2JsonProtobufFollower) Range(f func(protoreflect.FieldDescriptor, prot
 			default:
 			default:
 				panic("unexpected any value")
 				panic("unexpected any value")
 			}
 			}
-
 		}
 		}
 		return followValue(descriptor, value, f)
 		return followValue(descriptor, value, f)
 	})
 	})
@@ -106,7 +104,6 @@ func (v *V2JsonProtobufFollower) Set(descriptor protoreflect.FieldDescriptor, va
 	default:
 	default:
 		v.Message.Set(descriptor, value)
 		v.Message.Set(descriptor, value)
 	}
 	}
-
 }
 }
 
 
 func (v *V2JsonProtobufFollower) Mutable(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
 func (v *V2JsonProtobufFollower) Mutable(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
@@ -124,7 +121,6 @@ func (v *V2JsonProtobufFollower) Mutable(descriptor protoreflect.FieldDescriptor
 }
 }
 
 
 func (v *V2JsonProtobufFollower) NewField(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
 func (v *V2JsonProtobufFollower) NewField(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
-
 	if _, ok := descriptor.(*V2JsonProtobufAnyValueField); ok {
 	if _, ok := descriptor.(*V2JsonProtobufAnyValueField); ok {
 
 
 		url := v.Message.Get(v.Message.Descriptor().Fields().ByName("type_url")).String()
 		url := v.Message.Get(v.Message.Descriptor().Fields().ByName("type_url")).String()

+ 2 - 0
infra/conf/v2jsonpb/followerany.go

@@ -54,6 +54,7 @@ type V2JsonProtobufAnyTypeFieldDescriptor struct {
 func (v V2JsonProtobufAnyTypeFieldDescriptor) JSONName() string {
 func (v V2JsonProtobufAnyTypeFieldDescriptor) JSONName() string {
 	return "type"
 	return "type"
 }
 }
+
 func (v V2JsonProtobufAnyTypeFieldDescriptor) TextName() string {
 func (v V2JsonProtobufAnyTypeFieldDescriptor) TextName() string {
 	return "type"
 	return "type"
 }
 }
@@ -70,6 +71,7 @@ func (v *V2JsonProtobufAnyValueField) Kind() protoreflect.Kind {
 func (v *V2JsonProtobufAnyValueField) JSONName() string {
 func (v *V2JsonProtobufAnyValueField) JSONName() string {
 	return v.name
 	return v.name
 }
 }
+
 func (v *V2JsonProtobufAnyValueField) TextName() string {
 func (v *V2JsonProtobufAnyValueField) TextName() string {
 	return v.name
 	return v.name
 }
 }

+ 0 - 1
main/commands/all/api/balancer_info.go

@@ -60,7 +60,6 @@ func executeBalancerInfo(cmd *base.Command, args []string) {
 	}
 	}
 
 
 	showBalancerInfo(resp.Balancer)
 	showBalancerInfo(resp.Balancer)
-
 }
 }
 
 
 func showBalancerInfo(b *routerService.BalancerMsg) {
 func showBalancerInfo(b *routerService.BalancerMsg) {

+ 0 - 2
main/commands/all/engineering/convertpb.go

@@ -46,7 +46,6 @@ var cmdConvertPb = &base.Command{
 				base.Fatalf("%s", newError(fmt.Sprintf("failed to load config: %s", configFiles)).Base(err))
 				base.Fatalf("%s", newError(fmt.Sprintf("failed to load config: %s", configFiles)).Base(err))
 				return
 				return
 			}
 			}
-
 		}
 		}
 		bytew, err := proto.Marshal(config)
 		bytew, err := proto.Marshal(config)
 		if err != nil {
 		if err != nil {
@@ -54,6 +53,5 @@ var cmdConvertPb = &base.Command{
 			return
 			return
 		}
 		}
 		io.Copy(os.Stdout, bytes.NewReader(bytew))
 		io.Copy(os.Stdout, bytes.NewReader(bytew))
-
 	},
 	},
 }
 }

+ 0 - 1
main/commands/all/engineering/engineering.go

@@ -14,5 +14,4 @@ var cmdEngineering = &base.Command{
 
 
 func init() {
 func init() {
 	base.RegisterCommand(cmdEngineering)
 	base.RegisterCommand(cmdEngineering)
-
 }
 }

+ 2 - 1
main/commands/all/engineering/reversepb.go

@@ -41,4 +41,5 @@ var cmdReversePb = &base.Command{
 				io.Copy(os.Stdout, bytes.NewReader(value))
 				io.Copy(os.Stdout, bytes.NewReader(value))
 			}
 			}
 		}
 		}
-	}}
+	},
+}

+ 1 - 0
main/commands/all/jsonv4/convert.go

@@ -74,6 +74,7 @@ func setConfArgs(cmd *base.Command) {
 	cmd.Flag.StringVar(&outputFormat, "o", "json", "")
 	cmd.Flag.StringVar(&outputFormat, "o", "json", "")
 	cmd.Flag.BoolVar(&confDirRecursively, "r", false, "")
 	cmd.Flag.BoolVar(&confDirRecursively, "r", false, "")
 }
 }
+
 func executeConvert(cmd *base.Command, args []string) {
 func executeConvert(cmd *base.Command, args []string) {
 	setConfArgs(cmd)
 	setConfArgs(cmd)
 	cmd.Flag.Parse(args)
 	cmd.Flag.Parse(args)

+ 1 - 3
main/commands/all/tls/ping.go

@@ -29,9 +29,7 @@ func init() {
 	cmdPing.Run = executePing // break init loop
 	cmdPing.Run = executePing // break init loop
 }
 }
 
 
-var (
-	pingIPStr = cmdPing.Flag.String("ip", "", "")
-)
+var pingIPStr = cmdPing.Flag.String("ip", "", "")
 
 
 func executePing(cmd *base.Command, args []string) {
 func executePing(cmd *base.Command, args []string) {
 	if cmdPing.Flag.NArg() < 1 {
 	if cmdPing.Flag.NArg() < 1 {

+ 1 - 3
main/commands/all/verify.go

@@ -25,9 +25,7 @@ func init() {
 	cmdVerify.Run = executeVerify // break init loop
 	cmdVerify.Run = executeVerify // break init loop
 }
 }
 
 
-var (
-	verifySigFile = cmdVerify.Flag.String("sig", "", "Path to the signature file")
-)
+var verifySigFile = cmdVerify.Flag.String("sig", "", "Path to the signature file")
 
 
 func executeVerify(cmd *base.Command, args []string) {
 func executeVerify(cmd *base.Command, args []string) {
 	target := cmdVerify.Flag.Arg(0)
 	target := cmdVerify.Flag.Arg(0)

+ 4 - 2
main/commands/base/command.go

@@ -113,8 +113,10 @@ func ExitIfErrors() {
 	}
 	}
 }
 }
 
 
-var exitStatus = 0
-var exitMu sync.Mutex
+var (
+	exitStatus = 0
+	exitMu     sync.Mutex
+)
 
 
 // SetExitStatus set exit status code
 // SetExitStatus set exit status code
 func SetExitStatus(n int) {
 func SetExitStatus(n int) {

+ 1 - 1
main/distro/all/all.go

@@ -79,7 +79,7 @@ import (
 	// commands
 	// commands
 	_ "github.com/v2fly/v2ray-core/v4/main/commands/all"
 	_ "github.com/v2fly/v2ray-core/v4/main/commands/all"
 
 
-	//engineering commands
+	// engineering commands
 	_ "github.com/v2fly/v2ray-core/v4/main/commands/all/engineering"
 	_ "github.com/v2fly/v2ray-core/v4/main/commands/all/engineering"
 
 
 	// Commands that rely on jsonv4 format This disable selective compile
 	// Commands that rely on jsonv4 format This disable selective compile

+ 0 - 1
main/v2binding/v2binding.go

@@ -25,7 +25,6 @@ type bindingInstance struct {
 var binding bindingInstance
 var binding bindingInstance
 
 
 func (b *bindingInstance) startAPIInstance() {
 func (b *bindingInstance) startAPIInstance() {
-
 	bindConfig := &core.Config{
 	bindConfig := &core.Config{
 		App: []*anypb.Any{
 		App: []*anypb.Any{
 			serial.ToTypedMessage(&instman.Config{}),
 			serial.ToTypedMessage(&instman.Config{}),

+ 1 - 1
proxy/freedom/freedom.go

@@ -71,7 +71,7 @@ func (h *Handler) resolveIP(ctx context.Context, domain string, localAddr net.Ad
 		newError("DNS client doesn't implement ClientWithIPOption")
 		newError("DNS client doesn't implement ClientWithIPOption")
 	}
 	}
 
 
-	var lookupFunc = h.dns.LookupIP
+	lookupFunc := h.dns.LookupIP
 	if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) {
 	if h.config.DomainStrategy == Config_USE_IP4 || (localAddr != nil && localAddr.Family().IsIPv4()) {
 		if lookupIPv4, ok := h.dns.(dns.IPv4Lookup); ok {
 		if lookupIPv4, ok := h.dns.(dns.IPv4Lookup); ok {
 			lookupFunc = lookupIPv4.LookupIPv4
 			lookupFunc = lookupIPv4.LookupIPv4

+ 0 - 2
proxy/shadowsocks/protocol.go

@@ -37,7 +37,6 @@ func ReadTCPSession(user *protocol.MemoryUser, reader io.Reader) (*protocol.Requ
 	behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
 	behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
 
 
 	drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(behaviorSeed), 16+38, 3266, 64)
 	drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(behaviorSeed), 16+38, 3266, 64)
-
 	if err != nil {
 	if err != nil {
 		return nil, nil, newError("failed to initialize drainer").Base(err)
 		return nil, nil, newError("failed to initialize drainer").Base(err)
 	}
 	}
@@ -138,7 +137,6 @@ func ReadTCPResponse(user *protocol.MemoryUser, reader io.Reader) (buf.Reader, e
 	behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
 	behaviorSeed := crc32.ChecksumIEEE(hashkdf.Sum(nil))
 
 
 	drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(behaviorSeed), 16+38, 3266, 64)
 	drainer, err := drain.NewBehaviorSeedLimitedDrainer(int64(behaviorSeed), 16+38, 3266, 64)
-
 	if err != nil {
 	if err != nil {
 		return nil, newError("failed to initialize drainer").Base(err)
 		return nil, newError("failed to initialize drainer").Base(err)
 	}
 	}

+ 9 - 8
proxy/trojan/simplified/config.go

@@ -28,17 +28,18 @@ func init() {
 
 
 	common.Must(common.RegisterConfig((*ClientConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
 	common.Must(common.RegisterConfig((*ClientConfig)(nil), func(ctx context.Context, config interface{}) (interface{}, error) {
 		simplifiedClient := config.(*ClientConfig)
 		simplifiedClient := config.(*ClientConfig)
-		fullClient := &trojan.ClientConfig{Server: []*protocol.ServerEndpoint{
-			{
-				Address: simplifiedClient.Address,
-				Port:    simplifiedClient.Port,
-				User: []*protocol.User{
-					{
-						Account: serial.ToTypedMessage(&trojan.Account{Password: simplifiedClient.Password}),
+		fullClient := &trojan.ClientConfig{
+			Server: []*protocol.ServerEndpoint{
+				{
+					Address: simplifiedClient.Address,
+					Port:    simplifiedClient.Port,
+					User: []*protocol.User{
+						{
+							Account: serial.ToTypedMessage(&trojan.Account{Password: simplifiedClient.Password}),
+						},
 					},
 					},
 				},
 				},
 			},
 			},
-		},
 		}
 		}
 		return common.CreateObject(ctx, fullClient)
 		return common.CreateObject(ctx, fullClient)
 	}))
 	}))

+ 1 - 1
v2ray_test.go

@@ -1,10 +1,10 @@
 package core_test
 package core_test
 
 
 import (
 import (
-	"google.golang.org/protobuf/types/known/anypb"
 	"testing"
 	"testing"
 
 
 	"google.golang.org/protobuf/proto"
 	"google.golang.org/protobuf/proto"
+	"google.golang.org/protobuf/types/known/anypb"
 
 
 	. "github.com/v2fly/v2ray-core/v4"
 	. "github.com/v2fly/v2ray-core/v4"
 	"github.com/v2fly/v2ray-core/v4/app/dispatcher"
 	"github.com/v2fly/v2ray-core/v4/app/dispatcher"