зеркало из https://github.com/Azure/draft-classic.git
23 строки
370 B
Go
23 строки
370 B
Go
package builder
|
|
|
|
import (
|
|
"math/rand"
|
|
"time"
|
|
|
|
"github.com/oklog/ulid"
|
|
)
|
|
|
|
func getulid() string { return <-ulidc }
|
|
|
|
// A channel which returns build ulids.
|
|
var ulidc = make(chan string)
|
|
|
|
func init() {
|
|
rnd := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
|
|
go func() {
|
|
for {
|
|
ulidc <- ulid.MustNew(ulid.Timestamp(time.Now().UTC()), rnd).String()
|
|
}
|
|
}()
|
|
}
|