Documentation ¶
Index ¶
Constants ¶
const ( // ErrEmpty the namespaced key is empty. ErrEmpty = errors.Const("namespace: namespaced key is empty") // ErrNil the namespace or key is nil. // This is returned by methods on the zero value of [NS] or [NSK] ErrNil = errors.Const("namespace: nil namespace or key") // ErrTooLong the namespaced key exceeded the max allowed length. ErrTooLong = errors.Const("namespace: namespaced key is too long") // ErrInvalidChar the namespaced key contained an invalid character ErrInvalidChar = errors.Const("namespace: namespaced key contains illegal characters") // ErrTrailingSep the nsk contained a trailing `:` ErrTrailingSep = errors.Const("namespace: namespace contains trailing ':' character") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NS ¶
type NS struct {
// contains filtered or unexported fields
}
NS is a namespace. A namespace can only contain digits, lowercase letters, underscores and hyphens.
To compare namespaces use `==` operator directly (not on the pointer value) or use the NS.Equal method.
Default this is the namespace used for minecraft items/effects ect. Plugins should use their own namespace if they aren't overriding vanilla features
func Namespace ¶
Namespace creates a new namespace from the given string.
This panics if the length of the namespace is larger than [MaxLength] or is zero. All invalid characters in the namespace are replaced with underscores.
func ParseNamespace ¶
ParseNamespace creates a new namespace from the given string.
This returns an error if the length of the namespace is larger than [MaxLength] or is zero. If strict mode is enabled, this returns an error when it encounters an invalid character. Otherwise, this replaces all invalid characters with underscores.
func (NS) IsNil ¶
IsNil returns if this nsk is nil. if this returns true, calling NS.Key will panic.
func (NS) Key ¶
Key creates a new key inside this namespace. All invalid characters in the will be replaced with an underscore.
This panics if the length of the key is larger than [MaxLength] or is zero. If NS.IsNil returns true, this will panic.
func (*NS) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (NS) ParseKey ¶
ParseKey creates a new key inside this namespace. Unlike NS.Key, this will return an error if any invalid characters are encountered.
This returns an error if the length of the key is larger than [MaxLength] or is zero If NS.IsNil returns true, this will return ErrNil.
func (*NS) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler
type NSK ¶
type NSK struct {
// contains filtered or unexported fields
}
NSK is a namespaced key. A namespace can only contain digits, lowercase letters, underscores, hyphens, forward slash and dots.
To compare namespaces use `==` operator directly (not on the pointer value) or use the NSK.Equal method.
func Key ¶
Key creates a new namespaced key from the given string.
This panics if the length of the key is larger than [MaxLength] or is zero. All invalid characters in the namespaced key are replaced with underscores.
func ParseKey ¶
ParseKey creates a new namespaced key from the given string.
This returns an error if the length of the key is larger than [MaxLength] or is zero. If strict mode is enabled, this returns an error when it encounters an invalid character. Otherwise, this replaces all invalid characters with underscores.
func (NSK) IsNil ¶
IsNil returns if this nsk is nil. if this returns true, calling NSK.Namespace will panic.
func (NSK) Key ¶
Key gets the key part of the namespaced key (the part after the ':'). If the namespaced key is nil, this returns an empty string.
func (*NSK) MarshalText ¶
MarshalText implements encoding.TextMarshaler
func (NSK) Namespace ¶
Namespace gets the namespace for this key. If NSK.IsNil returns true, this will panic.
func (*NSK) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler