transform

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2026 License: MIT Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package transform holds functions for path name transformations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppyTimeGlobs

func AppyTimeGlobs(s string, t time.Time) string

AppyTimeGlobs converts "myfile-{DateOnly}.txt" to "myfile-2006-01-02.txt"

func Help

func Help() string

Help returns the help string cleaned up to simplify appending

func ParseGlobs

func ParseGlobs(s string) (hasGlobs bool, substring string)

ParseGlobs determines whether a string contains {brackets} and returns the substring (including both brackets) for replacing substring is first opening bracket to last closing bracket -- good for {{this}} but not {this}{this}

func Path

func Path(ctx context.Context, s string, isDir bool) string

Path transforms a path s according to the --name-transform options in use

If no transforms are in use, s is returned unchanged

func SetOptions

func SetOptions(ctx context.Context, s ...string) (err error)

SetOptions sets the options in ctx from flags passed in. Any existing flags will be overwritten. s should be in the same format as cmd line flags, i.e. "all,prefix=XXX"

func SuffixKeepExtension

func SuffixKeepExtension(remote string, suffix string) string

SuffixKeepExtension adds a suffix while keeping extension

i.e. file.txt becomes file_somesuffix.txt not file.txt_somesuffix

func TimeFormat

func TimeFormat(timeFormat string) string

TimeFormat converts a user-supplied string to a Go time constant, if possible

func Transforming

func Transforming(ctx context.Context) bool

Transforming returns true when transforms are in use

func TrimBrackets

func TrimBrackets(s string) string

TrimBrackets converts {{this}} to this

Types

type Algo

type Algo = fs.Enum[transformChoices]

Algo describes conversion setting

const (
	ConvNone Algo = iota
	ConvToNFC
	ConvToNFD
	ConvToNFKC
	ConvToNFKD
	ConvFindReplace
	ConvPrefix
	ConvSuffix
	ConvSuffixKeepExtension
	ConvTrimPrefix
	ConvTrimSuffix
	ConvIndex
	ConvDate
	ConvTruncate
	ConvTruncateKeepExtension
	ConvTruncateBytes
	ConvTruncateBytesKeepExtension
	ConvBase64Encode
	ConvBase64Decode
	ConvEncoder
	ConvDecoder
	ConvISO8859_1
	ConvWindows1252
	ConvMacintosh
	ConvCharmap
	ConvLowercase
	ConvUppercase
	ConvTitlecase
	ConvASCII
	ConvURL
	ConvRegex
	ConvCommand
)

Supported transform options

type CharmapChoices

type CharmapChoices = fs.Enum[cmapChoices]

CharmapChoices is an enum of the character map choices.

Jump to

Keyboard shortcuts

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