예제 #1
0
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)
}
예제 #2
0
파일: session.go 프로젝트: Joinhack/peony
func (sm *MemSessionManager) GenerateId() string {
	uuid, err := simpleuuid.NewTime(time.Now())
	if err != nil {
		panic(err) // never happend
	}
	return uuid.String()
}
예제 #3
0
파일: session.go 프로젝트: huaguzi/revel
// 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]
}
예제 #4
0
func NewDocument(index *Index, body string, data string) *Document {
	uuid, _ := simpleuuid.NewTime(time.Now())
	return &Document{uuid, index, body, data, NewTokenCollection()}
}