Identifier: New functions to create from string and know if empty
This commit is contained in:
parent
444d064ba9
commit
efdd3a29b3
@ -5,8 +5,18 @@ import (
|
||||
"errors"
|
||||
)
|
||||
|
||||
const IDENTIFIER_LEN = 48
|
||||
|
||||
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 {
|
||||
return base64.RawURLEncoding.EncodeToString(*i)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user