1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00
mxpv-podsync/pkg/feeds/id_gen.go

25 lines
378 B
Go
Raw Normal View History

2018-11-24 11:58:08 -08:00
package feeds
import (
"time"
2019-01-06 21:36:42 -08:00
shortid "github.com/ventu-io/go-shortid"
2018-11-24 11:58:08 -08:00
)
type IDGen struct {
sid *shortid.Shortid
}
func NewIDGen() (IDGen, error) {
sid, err := shortid.New(1, shortid.DefaultABC, uint64(time.Now().UnixNano()))
if err != nil {
return IDGen{}, err
}
return IDGen{sid}, nil
}
func (id IDGen) Generate() (string, error) {
return id.sid.Generate()
2019-01-06 21:36:42 -08:00
}