Skip to content

KSUID order not predictable #73

Description

@timofriedlberlin

Hey there

The README states this:

In short, running a set of KSUIDs through the UNIX sort command will result in a list ordered by generation time.

I have the following code:

func TestKsuidOrder(t *testing.T) {
	k1 := ksuid.New()
	k2 := ksuid.New()
	assert.Equal(t, -1, ksuid.Compare(k1, k2))
}

Running it like this go test ./ -v -count=100 -run=TestKsuidOrder results in

    ksuid_test.go:31: 
                Error Trace:    ./ksuid_test.go:31
                Error:          Not equal: 
                                expected: -1
                                actual  : 1
                Test:           TestKsuidOrder

I was expecting that ksuid.New is generating sequences which can be naturally ordered?

If this is the expected behaviour which I see - then I guess the README should be more clear about that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions