transform

package
v4.0.7 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllCases = []Case{
	Stet, Upper, Lower,
}

AllCases lists all 3 values in order.

Functions

This section is empty.

Types

type Case

type Case int
const (
	Stet Case = iota
	Upper
	Lower
)

func AsCase

func AsCase(s string) (Case, error)

AsCase parses a string to find the corresponding Case, accepting either one of the string values or a number. The input representation is determined by caseMarshalTextRep. It wraps Parse.

func CaseOf

func CaseOf(v int) Case

CaseOf returns a Case based on an ordinal number. This is the inverse of Ordinal. If the ordinal is out of range, an invalid Case is returned.

func MustParseCase

func MustParseCase(s string) Case

MustParseCase is similar to AsCase except that it panics on error.

func Of

func Of(lowercase, uppercase bool) Case

func (Case) Expression

func (c Case) Expression(s string) string

func (Case) Imports

func (c Case) Imports() []string

func (Case) IsValid

func (v Case) IsValid() bool

IsValid determines whether a Case is one of the defined constants.

func (Case) NoOp

func (c Case) NoOp() bool

func (Case) Ordinal

func (v Case) Ordinal() int

Ordinal returns the ordinal number of a Case. This is an integer counting from zero. It is *not* the same as the const number assigned to the value.

func (*Case) Parse

func (v *Case) Parse(in string) error

Parse parses a string to find the corresponding Case, accepting one of the string values or a number. The input representation is determined by None. It is used by AsCase.

Usage Example

v := new(Case)
err := v.Parse(s)
...  etc

func (Case) String

func (v Case) String() string

String returns the literal string representation of a Case, which is the same as the const identifier but without prefix or suffix.

func (Case) Transform

func (c Case) Transform(s string) string

type Transform

type Transform interface {
	NoOp() bool
	Transform(s string) string
	Expression(s string) string
	Imports() []string
}

type Transforms

type Transforms []Transform

func ListOf

func ListOf(ts ...Transform) (list Transforms)

func (Transforms) Expression

func (ts Transforms) Expression(s string) string

func (Transforms) Imports

func (ts Transforms) Imports() (list []string)

func (Transforms) Transform

func (ts Transforms) Transform(s string) string

type Unsnake

type Unsnake bool

func (Unsnake) Expression

func (u Unsnake) Expression(s string) string

func (Unsnake) Imports

func (u Unsnake) Imports() []string

func (Unsnake) NoOp

func (u Unsnake) NoOp() bool

func (Unsnake) Transform

func (u Unsnake) Transform(s string) string

Jump to

Keyboard shortcuts

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