Identifier: New functions to create from string and know if empty
This commit is contained in:
parent
afac453e08
commit
6e6521c814
@ -5,8 +5,18 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const IDENTIFIER_LEN = 48
|
||||||
|
|
||||||
type Identifier []byte
|
type Identifier []byte
|
||||||
|
|
||||||
|
func NewIdentifierFromString(src string) (id Identifier, err error) {
|
||||||
|
return base64.RawURLEncoding.DecodeString(src)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *Identifier) IsEmpty() bool {
|
||||||
|
return len(*i) == 0
|
||||||
|
}
|
||||||
|
|
||||||
func (i *Identifier) ToString() string {
|
func (i *Identifier) ToString() string {
|
||||||
return base64.RawURLEncoding.EncodeToString(*i)
|
return base64.RawURLEncoding.EncodeToString(*i)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user