uniquename

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = Options{
	TimePrefixEnabled: true,
	TimePrefixLayout:  "2006-01-02T150405",
	TimePrefixSupportedLayouts: []string{
		"2006-01-02T150405-0700",
		"2006-01-02T150405",
	},
	BeforeExtension:    true,
	MaxExtensionLength: 10,
}
View Source
var DefaultRuntime = Runtime{
	Clock:   clockwork.NewRealClock(),
	Loc:     time.Local,
	RandInt: rand.Int31,
}
View Source
var ErrMissingTime = errors.New("missing timestamp")

Functions

func ExtractTime

func ExtractTime(path string, opts Options) (time.Time, error)

func SetRuntime

func SetRuntime(r Runtime) func()

Types

type Generator

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

func New

func New(path string, opts Options) (*Generator, error)

func (*Generator) Next

func (g *Generator) Next() (path string, ok bool)

type Options

type Options struct {
	// prepend current time to name, even for original name
	TimePrefixEnabled          bool
	TimePrefixLayout           string
	TimePrefixSupportedLayouts []string

	// if name contains an extension
	BeforeExtension    bool
	MaxExtensionLength int
}

type Runtime

type Runtime struct {
	Clock interface {
		Now() time.Time
	}
	Loc     *time.Location
	RandInt func() int32
}

Jump to

Keyboard shortcuts

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