username

package
v0.0.0-...-f348597 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const UsernameMaxLen = 40
View Source
const UsernameMinLen = 3

Variables

View Source
var (
	ErrInvalidUsername = errors.New("Invalid username")
	ErrUnexpected      = errors.New("unknown error")
)
View Source
var (
	ErrInvalidUsernameBase = errors.New("Invalid username base")
)
View Source
var UsernameBaseRegexp = fmt.Sprintf(
	`^(?:@)?[a-zA-Z0-9]{%d,%d}$`,
	UsernameMinLen, UsernameMaxLen)
View Source
var UsernameRegexp = fmt.Sprintf(`%s:[0-9]+$`, UsernameBaseRegexp)

Functions

This section is empty.

Types

type NilUsername

type NilUsername struct{}

func (*NilUsername) Base

func (nu *NilUsername) Base() string

func (*NilUsername) ID

func (nu *NilUsername) ID() int

func (*NilUsername) IsNil

func (nu *NilUsername) IsNil() bool

func (*NilUsername) String

func (nu *NilUsername) String() string

func (*NilUsername) StringWithoutAt

func (nu *NilUsername) StringWithoutAt() string

type Username

type Username interface {
	// 4nd3rs0n
	IsNil() bool
	Base() string
	// 666
	ID() int

	// @4nd3rs0n:666
	String() string
	// 4nd3rs0n:666
	StringWithoutAt() string
}

Username: (@)<base>:<id>

func NewUsername

func NewUsername(base string, id int) (Username, error)

func Parse

func Parse(user string) (uname Username, err error)

Jump to

Keyboard shortcuts

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