Movatterモバイル変換


[0]ホーム

URL:


uid

package
v0.123.0Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License:Apache-2.0Imports:5Imported by:0

Details

Repository

github.com/googleapis/google-cloud-go

Links

Documentation

Overview

Package uid supports generating unique IDs. Its chief purpose is to preventmultiple test executions from interfering with each other, and to facilitatecleanup of old entities that may remain if tests exit early.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

typeOptions

type Options struct {Seprune// Separates parts of the UID. Defaults to '-'.Timetime.Time// Timestamp for all UIDs made with this space. Defaults to current time.// Short, if true, makes the result of space.New shorter by 6 characters.// This can be useful for character restricted IDs. It will use a shorter// but less readable time representation, and will only use two characters// for the count suffix instead of four.//// e.x. normal: gotest-20181030-59751273685000-0001// e.x. short:  gotest-1540917351273685000-01Shortbool}

Options are optional values for a Space.

typeSpace

type Space struct {Prefixstring// Prefix of UIDs. Read-only.Seprune// Separates UID parts. Read-only.Timetime.Time// Timestamp for UIDs. Read-only.// contains filtered or unexported fields}

A Space manages a set of unique IDs distinguished by a prefix.

funcNewSpace

func NewSpace(prefixstring, opts *Options) *Space

NewSpace creates a new UID space. A UID Space is used to generate unique IDs.

func (*Space)New

func (s *Space) New()string

New generates a new unique ID. The ID consists of the Space's prefix, atimestamp, and a counter value. All unique IDs generated in the same testexecution will have the same timestamp.

Aside from the characters in the prefix, IDs contain only letters, numbersand sep.

func (*Space)Older

func (s *Space) Older(uidstring, dtime.Duration)bool

Older reports whether uid was created by m and has a timestamp older thanthe current time by at least d.

func (*Space)Timestamp

func (s *Space) Timestamp(uidstring) (time.Time,bool)

Timestamp extracts the timestamp of uid, which must have been generated bys. The second return value is true on success, false if there was a problem.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp