Files
EdgeAdmin/internal/utils/strings.go
GoEdgeLab d7d0c8fbfe v1.4.1
2024-07-27 15:42:58 +08:00

33 lines
667 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package utils
import (
"strings"
"github.com/iwind/TeaGo/types"
)
// FormatAddress format address
func FormatAddress(addr string) string {
if strings.HasSuffix(addr, "unix:") {
return addr
}
addr = strings.Replace(addr, " ", "", -1)
addr = strings.Replace(addr, "\t", "", -1)
addr = strings.Replace(addr, "", ":", -1)
addr = strings.TrimSpace(addr)
return addr
}
// SplitNumbers 分割数字
func SplitNumbers(numbers string) (result []int64) {
if len(numbers) == 0 {
return
}
pieces := strings.Split(numbers, ",")
for _, piece := range pieces {
number := types.Int64(strings.TrimSpace(piece))
result = append(result, number)
}
return
}