Help us shape the future of Go! Take the 2026 Go Developer Survey

bufuuid

package
v1.20.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator provides thread-safe convenience methods to generate random v4 UUIDs, leveraging a buffer to amortize the cost of reading from the random source.

func New

func New() *Generator

New returns a new object that can be used to generate random v4 UUID instances, analogously to "github.com/google/uuid".New(). It leverages an internal buffer (via a thread-safe bufio.Reader) to amortize the cost of reading from the random source when generating a large number of UUIDs. This behavior is similar to "github.com/google/uuid".EnableRandPool, but confined to this specific generator instance, so that it can be used when security is not a concern (i.e., it is not a problem that the buffer is stored on the Go heap), without needing to enable it globally. In addition, the generator provides a NewInto method that does not cause allocations (opposed to "github.com/google/uuid".NewRandomFromReader()).

func (*Generator) New

func (g *Generator) New() uuid.UUID

New creates a new random UUID or panics.

func (*Generator) NewInto

func (g *Generator) NewInto(target *uuid.UUID)

NewInto writes a new random UUID into target, or panics.

Jump to

Keyboard shortcuts

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