port

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRule

func CheckRule(rule string) (ok bool)

CheckRule validates that the validation rule itself is valid.

Valid rules are:

str ^[a-zA-Z0-9]+$
bool
int [0,60]
float [0.0,1.0)
dur (0s,24h]
set Red|Green|Blue
url
email
json

Whereas the following types are synonymous:

str, string, text, (empty)
bool, boolean
int, integer, long
float, double, decimal, number
dur, duration

func IsLowerCaseIdentifier

func IsLowerCaseIdentifier(id string) bool

IsLowerCaseIdentifier accepts only lowerCaseIdentifiers.

func IsUpperCaseIdentifier

func IsUpperCaseIdentifier(id string) bool

IsUpperCaseIdentifier accepts only UpperCaseIdentifiers.

func JoinHostAndPath

func JoinHostAndPath(host string, path string) string

JoinHostAndPath combines the path shorthand with a hostname.

func ParseURL

func ParseURL(rawURL string) (canonical *url.URL, err error)

ParseURL returns a canonical version of the parsed URL with the scheme and port filled in if omitted. This method should only be used on internal URLs because it limits the hostname to certain specifications.

func ToKebabCase

func ToKebabCase(id string) string

ToKebabCase converts a CamelCase identifier to kebab-case. Consecutive non-letters or numbers are compressed into a single hyphen.

func ToSnakeCase

func ToSnakeCase(id string) string

ToSnakeCase converts a CamelCase identifier to snake_case. Consecutive non-letters are compressed into a single underscore.

func Validate

func Validate(rule string, value string) (ok bool)

Validate validates that the value matches the rule. The rule itself is assumed to be valid.

func ValidateHostname

func ValidateHostname(hostname string) error

ValidateHostname indicates if the hostname is a valid microservice hostname. Hostnames must contain only alphanumeric characters, hyphens, underscores and dot separators.

Types

This section is empty.

Jump to

Keyboard shortcuts

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