replace strings.Split with SplitSeq

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2025-05-31 19:03:41 +02:00
parent 60af36813b
commit b6873768b2
7 changed files with 8 additions and 8 deletions

View File

@@ -767,7 +767,7 @@ func (c *Configuration) renewCertificates() error {
func isDomainValid(domain string) (string, bool) {
isValid := false
for _, d := range strings.Split(domain, ",") {
for d := range strings.SplitSeq(domain, ",") {
d = strings.TrimSpace(d)
if d != "" {
isValid = true
@@ -785,7 +785,7 @@ func getDomains(domain string) []string {
delimiter = " "
}
for _, d := range strings.Split(domain, delimiter) {
for d := range strings.SplitSeq(domain, delimiter) {
d = strings.TrimSpace(d)
if d != "" {
domains = append(domains, d)

View File

@@ -496,7 +496,7 @@ func getPatternsFilterValues(value string) (string, []string) {
if len(dirExts) > 1 {
dir := strings.TrimSpace(dirExts[0])
exts := []string{}
for _, e := range strings.Split(dirExts[1], ",") {
for e := range strings.SplitSeq(dirExts[1], ",") {
cleanedExt := strings.TrimSpace(e)
if cleanedExt != "" {
exts = append(exts, cleanedExt)

View File

@@ -2278,7 +2278,7 @@ func lookupStringListFromEnv(envName string) ([]string, bool) {
value, ok := os.LookupEnv(envName)
if ok {
var result []string
for _, v := range strings.Split(value, ",") {
for v := range strings.SplitSeq(value, ",") {
val := strings.TrimSpace(v)
if val != "" {
result = append(result, val)

View File

@@ -281,7 +281,7 @@ func getPGSQLHostsAndPorts(configHost string, configPort int) (string, string) {
defaultPort = "5432"
}
for _, hostport := range strings.Split(configHost, ",") {
for hostport := range strings.SplitSeq(configHost, ",") {
hostport = strings.TrimSpace(hostport)
if hostport == "" {
continue

View File

@@ -161,7 +161,7 @@ func getURLPath(r *http.Request) string {
func getCommaSeparatedQueryParam(r *http.Request, key string) []string {
var result []string
for _, val := range strings.Split(r.URL.Query().Get(key), ",") {
for val := range strings.SplitSeq(r.URL.Query().Get(key), ",") {
val = strings.TrimSpace(val)
if val != "" {
result = append(result, val)

View File

@@ -107,7 +107,7 @@ type resetPwdPage struct {
func getSliceFromDelimitedValues(values, delimiter string) []string {
result := []string{}
for _, v := range strings.Split(values, delimiter) {
for v := range strings.SplitSeq(values, delimiter) {
cleaned := strings.TrimSpace(v)
if cleaned != "" {
result = append(result, cleaned)

View File

@@ -731,7 +731,7 @@ func GetRealIP(r *http.Request, header string, depth int) string {
var ipAddresses []string
for _, h := range r.Header.Values(header) {
for _, ipStr := range strings.Split(h, ",") {
for ipStr := range strings.SplitSeq(h, ",") {
ipStr = strings.TrimSpace(ipStr)
ipAddresses = append(ipAddresses, ipStr)
}