chore: modernize the codebase using go 1.26 (#278)

This runs:

```
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./...
```

over the codebase, as this is using go 1.26, it can also use the new
new() functionallity so AsPtr and boolPtr is are needed anymore.

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2026-03-21 21:16:09 +10:00
committed by GitHub
parent a5baf6e5c3
commit 2ab58d24d4
19 changed files with 82 additions and 101 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ func ExpandCommaSeparatedValues(values []string) []string {
var expanded []string
for _, value := range values {
for _, v := range strings.Split(value, ",") {
for v := range strings.SplitSeq(value, ",") {
if v = strings.TrimSpace(v); v != "" {
expanded = append(expanded, v)
}
+1 -1
View File
@@ -26,7 +26,7 @@ type RecordResponse struct {
type AuthErrorResponse struct {
Status int `json:"status,omitempty"`
Message string `json:"msg,omitempty"`
Data authErrorData `json:"data,omitempty"`
Data authErrorData `json:"data"`
}
type authErrorData struct {
+1 -1
View File
@@ -107,7 +107,7 @@ func (d *Director) remoteBackend(addr string) (*RemoteBackend, error) {
// FlushRemoteBackends closes all remote backend connections and removes them from the cache.
func (d *Director) FlushRemoteBackends() {
d.remoteBackends.Range(func(key, value interface{}) bool {
d.remoteBackends.Range(func(key, value any) bool {
backend, ok := value.(*RemoteBackend)
if !ok {
return true
+4 -3
View File
@@ -226,12 +226,13 @@ func (g *CaddyfileGenerator) Generate(
// Append error summary as comment if there were any invalid configs.
if len(configErrors) > 0 {
errorsComment := "# Skipped invalid user-defined configs:\n"
var errorsComment strings.Builder
errorsComment.WriteString("# Skipped invalid user-defined configs:\n")
for _, e := range configErrors {
errorsComment += fmt.Sprintf("# - %s\n", e)
errorsComment.WriteString(fmt.Sprintf("# - %s\n", e))
}
caddyfile += "\n" + errorsComment
caddyfile += "\n" + errorsComment.String()
}
return caddyfileHeader + "\n" + caddyfile, nil
+1 -1
View File
@@ -103,7 +103,7 @@ func createIptablesChains() error {
}
firstRejectRuleNum := 0
for _, line := range strings.Split(string(out), "\n") {
for line := range strings.SplitSeq(string(out), "\n") {
fields := strings.Fields(line)
if len(fields) < 2 {
continue
+1 -1
View File
@@ -116,7 +116,7 @@ func (p *Proxy) handleConnection(ctx context.Context, localConn net.Conn) {
}()
// Wait for both copies to complete or context cancel.
for i := 0; i < 2; i++ {
for range 2 {
select {
case <-ctx.Done():
// Close connections to abort ongoing copies.