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
2018-11-24 11:58:08 -08:00

24 lines
369 B
Go

package feeds
import (
"time"
"github.com/ventu-io/go-shortid"
)
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()
}