Skip to content

the UUID of version 6 time back #199

@dxasu

Description

@dxasu

uuid/time.go

Line 35 in 2d3c2a9

func (t Time) UnixTime() (sec, nsec int64) {

The time in the UUID of version 6 is not strictly monotonically increasing, as the sixth byte is reset by the version. Will it be improved?

As follow code, it will panic with bad

`

t := make([]time.Time, 0, 10000)

for i := 0; i < 10000; i++ {

u, _ := uuid.NewV6()

t = append(t, time.Unix(u.Time().UnixTime()).UTC())

if i > 0 && t[len(t)-1].Before(t[len(t)-2]) {
	panic("bad")
}

}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions