stringutil

package
v1.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidEmail

func IsValidEmail(s string) bool

IsValidEmail reports whether s is an address of the "Mailbox" rule of RFC 5321 section 4.1.2, which JSON Schema 2020-12 names for the `email` format and OpenAPI's Contact Object `email` takes as an email address.

That is a local part, an at sign, and a domain. The local part is a dot-string of atext characters or a quoted string, and the domain is a name of letter-digit-hyphen labels or an address literal in brackets. A display name, a comment, a list of addresses, and any byte outside printable ASCII are not part of the rule, so none is accepted.

One deliberate reading: an IPv4 address literal may not have a leading zero in an octet. RFC 5321 would allow it, but such a value is read as octal by some parsers, and the JSON Schema `ipv4` format forbids it for that reason.

func IsValidSPDXExpression added in v1.67.0

func IsValidSPDXExpression(s string) bool

IsValidSPDXExpression reports whether s is a well-formed SPDX license expression: ids joined by the uppercase operators AND or OR, an id followed by WITH and an exception id, and parentheses for grouping. The ids are not checked against the SPDX license list.

func IsValidURL added in v1.67.0

func IsValidURL(s string) bool

IsValidURL reports whether s is a URI reference as RFC 3986 defines it, which is the format the OpenAPI Specification's schemas require of its URL fields. A relative reference such as "./terms.html" is valid, and so is any scheme. An http or https URL must also have a host, which RFC 9110 requires. The empty string is not accepted.

Types

This section is empty.

Jump to

Keyboard shortcuts

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