Fix go vet IPv6 address format errors in email notifier and server

Replace fmt.Sprintf("%s:%d") with net.JoinHostPort() for IPv6 compatibility.
Bump setup-go action to v5 to resolve Node.js 20 deprecation warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Shankar
2026-03-15 11:59:31 -04:00
parent 1904a92359
commit e2160c15d0
3 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v4 uses: actions/setup-go@v5
with: with:
go-version: '1.22' go-version: '1.22'
+3 -1
View File
@@ -4,9 +4,11 @@ import (
"context" "context"
"fmt" "fmt"
"log/slog" "log/slog"
"net"
"net/http" "net/http"
"os" "os"
"os/signal" "os/signal"
"strconv"
"syscall" "syscall"
"time" "time"
@@ -241,7 +243,7 @@ func main() {
} }
// Server configuration // Server configuration
addr := fmt.Sprintf("%s:%d", cfg.Server.Host, cfg.Server.Port) addr := net.JoinHostPort(cfg.Server.Host, strconv.Itoa(cfg.Server.Port))
httpServer := &http.Server{ httpServer := &http.Server{
Addr: addr, Addr: addr,
Handler: finalHandler, Handler: finalHandler,
+3 -2
View File
@@ -8,6 +8,7 @@ import (
"log/slog" "log/slog"
"net" "net"
"net/smtp" "net/smtp"
"strconv"
"strings" "strings"
"time" "time"
@@ -56,7 +57,7 @@ func (c *Connector) ValidateConfig(ctx context.Context, rawConfig json.RawMessag
"smtp_port", cfg.SMTPPort) "smtp_port", cfg.SMTPPort)
// Test SMTP connectivity with timeout // Test SMTP connectivity with timeout
addr := fmt.Sprintf("%s:%d", cfg.SMTPHost, cfg.SMTPPort) addr := net.JoinHostPort(cfg.SMTPHost, strconv.Itoa(cfg.SMTPPort))
conn, err := net.DialTimeout("tcp", addr, 10*time.Second) conn, err := net.DialTimeout("tcp", addr, 10*time.Second)
if err != nil { if err != nil {
return fmt.Errorf("failed to reach SMTP server %s: %w", addr, err) return fmt.Errorf("failed to reach SMTP server %s: %w", addr, err)
@@ -123,7 +124,7 @@ func (c *Connector) SendEvent(ctx context.Context, event notifier.Event) error {
// sendEmail sends an email message using the configured SMTP server. // sendEmail sends an email message using the configured SMTP server.
// It handles both TLS and plain authentication modes. // It handles both TLS and plain authentication modes.
func (c *Connector) sendEmail(ctx context.Context, to, subject, body string) error { func (c *Connector) sendEmail(ctx context.Context, to, subject, body string) error {
addr := fmt.Sprintf("%s:%d", c.config.SMTPHost, c.config.SMTPPort) addr := net.JoinHostPort(c.config.SMTPHost, strconv.Itoa(c.config.SMTPPort))
// Connect to SMTP server // Connect to SMTP server
var auth smtp.Auth var auth smtp.Auth