id

package
v0.0.0-...-c9cfaf6 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package id provides helpers for repeatable ID generation.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyValues

func KeyValues(space uuid.UUID, m map[string]string) uuid.UUID

KeyValues produces a UUID for the given key-value map in the suppied name space.

Example
package main

import (
	"fmt"

	"github.com/google/uuid"

	"github.com/mmcloughlin/goperf/app/id"
)

func main() {
	space := uuid.MustParse("19433b12-5b85-4252-9bb0-594a38156713")
	ident := id.KeyValues(space, map[string]string{"greeting": "hello", "who": "world"})
	fmt.Println(ident)
}
Output:

60376fde-597e-5694-8a19-e6dd930fbec0

func Strings

func Strings(space uuid.UUID, s []string) uuid.UUID

Strings produces a UUID for the given list of strings in the suppied name space.

Example
package main

import (
	"fmt"

	"github.com/google/uuid"

	"github.com/mmcloughlin/goperf/app/id"
)

func main() {
	space := uuid.MustParse("19433b12-5b85-4252-9bb0-594a38156713")
	ident := id.Strings(space, []string{"hello", "world"})
	fmt.Println(ident)
}
Output:

8cf4c7fd-c0a3-5134-90a5-531830a1c3e0

func UUID

func UUID(space uuid.UUID, data []byte) uuid.UUID

UUID generates a UUIDv5 from the given data.

Example
package main

import (
	"fmt"

	"github.com/google/uuid"

	"github.com/mmcloughlin/goperf/app/id"
)

func main() {
	space := uuid.MustParse("19433b12-5b85-4252-9bb0-594a38156713")
	ident := id.UUID(space, []byte("hello world"))
	fmt.Println(ident)
}
Output:

b7ca611e-7a4d-59b9-9ea6-4aabd08ff088

Types

This section is empty.

Jump to

Keyboard shortcuts

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