package server import "testing" func TestHostOnly(t *testing.T) { tests := []struct { in, want string }{ {"example.com:8080", "example.com"}, {"[::1]:443", "::1"}, {"127.0.0.1", "127.0.0.1"}, {"", ""}, } for _, tt := range tests { if got := hostOnly(tt.in); got != tt.want { t.Errorf("hostOnly(%q) = %q, want %q", tt.in, got, tt.want) } } }