idgen

package
v4.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Example (GenObjectID)

Checking that our IDs are pretty random...

rand.Seed(time.Now().UnixNano())

ids := map[string]bool{}

var g IDGen

for c := 0; c < 1000000; c++ {
	id := g.GenObjectID()
	_, exists := ids[id]
	if exists {
		fmt.Printf("match: %v\n", c)
		break
	}
	ids[id] = true
}

fmt.Println("done")
Output:

done

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IDGen

type IDGen struct {
}

IDGen - Implementation of ID generator interface

func (*IDGen) GenObjectID

func (i *IDGen) GenObjectID() string

GenObjectID - Implementation of ID generator interface

type IDGenerator

type IDGenerator interface {
	GenObjectID() string
}

IDGenerator - Generates ID strings

type MockIDGenerator

type MockIDGenerator struct {
	IDs []string
}

Here we really just expose some test helpers

func (*MockIDGenerator) GenObjectID

func (m *MockIDGenerator) GenObjectID() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL