A fast and simple blog backend.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
mediocre-blog/srv/src/chat/util.go

28 lines
573 B

package chat
import (
"strconv"
"strings"
"github.com/mediocregopher/radix/v4"
)
func parseStreamEntryID(str string) (radix.StreamEntryID, error) {
split := strings.SplitN(str, "-", 2)
if len(split) != 2 {
return radix.StreamEntryID{}, errInvalidMessageID
}
time, err := strconv.ParseUint(split[0], 10, 64)
if err != nil {
return radix.StreamEntryID{}, errInvalidMessageID
}
seq, err := strconv.ParseUint(split[1], 10, 64)
if err != nil {
return radix.StreamEntryID{}, errInvalidMessageID
}
return radix.StreamEntryID{Time: time, Seq: seq}, nil
}