mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-12-23 11:53:33 +02:00
Restore usage of slices
package
This commit is contained in:
parent
db934f0832
commit
de40dc2265
2 changed files with 28 additions and 33 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
cnet "github.com/xtls/xray-core/common/net"
|
cnet "github.com/xtls/xray-core/common/net"
|
||||||
|
@ -31,9 +32,6 @@ func JSONMarshalWithoutEscape(t interface{}) ([]byte, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
func marshalTypedMessage(v *cserial.TypedMessage, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||||
if v == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
tmsg, err := v.GetInstance()
|
tmsg, err := v.GetInstance()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -194,9 +192,8 @@ func marshalKnownType(v interface{}, ignoreNullValue bool, insertTypeInfo bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func isValueKind(kind reflect.Kind) bool {
|
var valueKinds = []reflect.Kind{
|
||||||
switch kind {
|
reflect.Bool,
|
||||||
case reflect.Bool,
|
|
||||||
reflect.Int,
|
reflect.Int,
|
||||||
reflect.Int8,
|
reflect.Int8,
|
||||||
reflect.Int16,
|
reflect.Int16,
|
||||||
|
@ -212,11 +209,11 @@ func isValueKind(kind reflect.Kind) bool {
|
||||||
reflect.Float64,
|
reflect.Float64,
|
||||||
reflect.Complex64,
|
reflect.Complex64,
|
||||||
reflect.Complex128,
|
reflect.Complex128,
|
||||||
reflect.String:
|
reflect.String,
|
||||||
return true
|
}
|
||||||
default:
|
|
||||||
return false
|
func isValueKind(kind reflect.Kind) bool {
|
||||||
}
|
return slices.Contains(valueKinds, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
func marshalInterface(v interface{}, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
func marshalInterface(v interface{}, ignoreNullValue bool, insertTypeInfo bool) interface{} {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package core
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/xtls/xray-core/common"
|
"github.com/xtls/xray-core/common"
|
||||||
|
@ -64,14 +65,11 @@ func GetMergedConfig(args cmdarg.Arg) (string, error) {
|
||||||
supported := []string{"json", "yaml", "toml"}
|
supported := []string{"json", "yaml", "toml"}
|
||||||
for _, file := range args {
|
for _, file := range args {
|
||||||
format := getFormat(file)
|
format := getFormat(file)
|
||||||
for _, s := range supported {
|
if slices.Contains(supported, format) {
|
||||||
if s == format {
|
|
||||||
files = append(files, &ConfigSource{
|
files = append(files, &ConfigSource{
|
||||||
Name: file,
|
Name: file,
|
||||||
Format: format,
|
Format: format,
|
||||||
})
|
})
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ConfigMergedFormFiles(files)
|
return ConfigMergedFormFiles(files)
|
||||||
|
|
Loading…
Reference in a new issue