refactor and fix strings.Split

This commit is contained in:
chrislu 2022-08-07 01:34:32 -07:00
parent 1a4bf0dcb5
commit 67814a5c79
8 changed files with 11 additions and 19 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/seaweedfs/seaweedfs/weed/security"
"github.com/seaweedfs/seaweedfs/weed/util"
"google.golang.org/grpc"
"strings"
"time"
)
@ -87,7 +86,7 @@ func doFilerBackup(grpcDialOption grpc.DialOption, backupOption *FilerBackupOpti
sourceFiler := pb.ServerAddress(*backupOption.filer)
sourcePath := *backupOption.path
excludePaths := strings.Split(*backupOption.excludePaths, ",")
excludePaths := util.StringSplit(*backupOption.excludePaths, ",")
timeAgo := *backupOption.timeAgo
targetPath := dataSink.GetSinkToDirectory()
debug := *backupOption.debug

View File

@ -143,7 +143,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
grpcDialOption,
filerA,
*syncOptions.aPath,
util.Split(*syncOptions.aExcludePaths, ","),
util.StringSplit(*syncOptions.aExcludePaths, ","),
*syncOptions.aProxyByFiler,
filerB,
*syncOptions.bPath,
@ -179,7 +179,7 @@ func runFilerSynchronize(cmd *Command, args []string) bool {
grpcDialOption,
filerB,
*syncOptions.bPath,
util.Split(*syncOptions.bExcludePaths, ","),
util.StringSplit(*syncOptions.bExcludePaths, ","),
*syncOptions.bProxyByFiler,
filerA,
*syncOptions.aPath,

View File

@ -113,10 +113,7 @@ func runMaster(cmd *Command, args []string) bool {
glog.Fatalf("Check Meta Folder (-mdir) Writable %s : %s", *m.metaFolder, err)
}
var masterWhiteList []string
if *m.whiteList != "" {
masterWhiteList = strings.Split(*m.whiteList, ",")
}
masterWhiteList := util.StringSplit(*m.whiteList, ",")
if *m.volumeSizeLimitMB > util.VolumeSizeLimitGB*1000 {
glog.Fatalf("volumeSizeLimitMB should be smaller than 30000")
}

View File

@ -76,8 +76,6 @@ var (
isStartingWebDav = cmdServer.Flag.Bool("webdav", false, "whether to start WebDAV gateway")
isStartingMqBroker = cmdServer.Flag.Bool("mq.broker", false, "whether to start message queue broker")
serverWhiteList []string
False = false
)
@ -248,9 +246,7 @@ func runServer(cmd *Command, args []string) bool {
}
filerOptions.defaultLevelDbDirectory = masterOptions.metaFolder
if *serverWhiteListOption != "" {
serverWhiteList = strings.Split(*serverWhiteListOption, ",")
}
serverWhiteList := util.StringSplit(*serverWhiteListOption, ",")
if *isStartingFiler {
go func() {

View File

@ -188,9 +188,7 @@ func (v VolumeServerOptions) startVolumeServer(volumeFolders, maxVolumeCounts, v
}
// security related white list configuration
if volumeWhiteListOption != "" {
v.whiteList = strings.Split(volumeWhiteListOption, ",")
}
v.whiteList = util.StringSplit(volumeWhiteListOption, ",")
if *v.ip == "" {
*v.ip = util.DetectedHostAddress()

View File

@ -3,6 +3,7 @@ package s3api
import (
"encoding/xml"
"fmt"
"github.com/seaweedfs/seaweedfs/weed/util"
"regexp"
"strings"
)
@ -43,7 +44,7 @@ func FromTags(tags map[string]string) (t *Tagging) {
func parseTagsHeader(tags string) (map[string]string, error) {
parsedTags := make(map[string]string)
for _, v := range strings.Split(tags, "&") {
for _, v := range util.StringSplit(tags, "&") {
tag := strings.Split(v, "=")
if len(tag) == 2 {
parsedTags[tag[0]] = tag[1]

View File

@ -7,6 +7,7 @@ import (
"github.com/seaweedfs/seaweedfs/weed/pb"
"github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
"github.com/seaweedfs/seaweedfs/weed/pb/master_pb"
"github.com/seaweedfs/seaweedfs/weed/util"
"github.com/seaweedfs/seaweedfs/weed/util/grace"
"golang.org/x/exp/slices"
"io"
@ -100,7 +101,7 @@ https://cloud.seaweedfs.com/ui/%s
return
}
for _, c := range strings.Split(cmd, ";") {
for _, c := range util.StringSplit(cmd, ";") {
if processEachCmd(reg, c, commandEnv) {
return
}

View File

@ -71,7 +71,7 @@ func (fp FullPath) IsUnder(other FullPath) bool {
return strings.HasPrefix(string(fp), string(other)+"/")
}
func Split(separatedValues string, sep string) []string {
func StringSplit(separatedValues string, sep string) []string {
if separatedValues == "" {
return nil
}