func NewToken(t time.Time) Token { token, err := simpleuuid.NewTime(t) if err == nil { return Token(token) } // try again token, err = simpleuuid.NewTime(t) if err == nil { return Token(token) } panic(err) }
func (sm *MemSessionManager) GenerateId() string { uuid, err := simpleuuid.NewTime(time.Now()) if err != nil { panic(err) // never happend } return uuid.String() }
// Id retrieves from the cookie or creates a time-based UUID identifying this // session. func (s Session) Id() string { if uuidStr, ok := s[SESSION_ID_KEY]; ok { return uuidStr } uuid, err := simpleuuid.NewTime(time.Now()) if err != nil { panic(err) // I don't think this can actually happen. } s[SESSION_ID_KEY] = uuid.String() return s[SESSION_ID_KEY] }
func NewDocument(index *Index, body string, data string) *Document { uuid, _ := simpleuuid.NewTime(time.Now()) return &Document{uuid, index, body, data, NewTokenCollection()} }