Identifier: New functions to create from string and know if empty

This commit is contained in:
nemunaire 2022-10-05 22:33:03 +02:00
parent 444d064ba9
commit efdd3a29b3
1 changed files with 10 additions and 0 deletions

View File

@ -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)
}