hostpattern

package
v2.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package hostpattern matches host names against patterns: an exact host, *.example.com for every subdomain of example.com, or * for every host.

Index

Constants

View Source
const (
	// Any matches every host.
	Any = "*"
	// WildcardPrefix starts a pattern that matches subdomains.
	WildcardPrefix = "*."
)

Variables

This section is empty.

Functions

func Canonical

func Canonical(host string) string

Canonical returns host lower-cased, without surrounding spaces, trailing dots, or the brackets of an IPv6 literal.

func Match

func Match(host, pattern string) bool

Match reports whether host matches pattern. A *. pattern matches the subdomains of its domain but not the domain itself.

func MatchAny

func MatchAny(host string, patterns []string) bool

MatchAny reports whether host matches any of patterns.

func Validate

func Validate(pattern string) error

Validate rejects a pattern that is not *, *. followed by a host name, a host name, or an IP address.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL