util

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Camel2KebabCase

func Camel2KebabCase(inName string) string

Kebab2CamelCase convert a kebab case command line flag or subcommand to a camel case name in Go

func Camel2MiddotCase

func Camel2MiddotCase(inName string) string

Middot2CamelCase convert a middot case command line flag or subcommand to a camel case name in Go

func Camel2SnakeCase

func Camel2SnakeCase(inName string) string

Snake2CamelCase convert a snake case command line flag or subcommand to a camel case name in Go

func CmdInputName2GoVar

func CmdInputName2GoVar(exported bool, inName string, sep rune) string

CmdInputName2GoVar convert `inName` into Camel or Pascal case base on `sep` separation

func GoVar2CmdInputName

func GoVar2CmdInputName(inName string, sep rune) string

GoVar2CmdInputName convert `inName`, a Camel or Pascal case, into other case base on `sep` separation

func Kebab2CamelCase

func Kebab2CamelCase(exported bool, inName string) string

Kebab2CamelCase convert a kebab case command line flag or subcommand to a camel case name in Go

func Middot2CamelCase

func Middot2CamelCase(exported bool, inName string) string

Middot2CamelCase convert a middot case command line flag or subcommand to a camel case name in Go

func PrintError

func PrintError(err error, args ...any)

PrintError print message and error undernate of the message into os.Stderr. If no message then only error message is being printed. The first element of `args` must be a string or formatted string which is used with function `fmt.Fprintf`. For better visualization the message should be short in one line of text.

func PrintErrorMessage

func PrintErrorMessage(msg string, args ...any)

PrintErrorMessage print message into os.Stderr

func Snake2CamelCase

func Snake2CamelCase(exported bool, inName string) string

Snake2CamelCase convert a snake case command line flag or subcommand to a camel case name in Go

func WrapText

func WrapText(s string, indent, width int) string

WrapText wrap string `s` into multiple line with space as indent. the `indent` is the number of space use for indentation. the `width` is the actual number of unicode character per line, it should be exclude the indentation. e.g, total width of terminal is 80 and indent is 6 then the width should be 74.

Currently function does not support general unicode text. Only English has been tested.

Types

type CmdInputName2GoVarFunc

type CmdInputName2GoVarFunc func(exported bool, inName string) string

NameConvention define how name is interpreted from command line to Go variable, field name or structure name.

type GoVar2CmdInputNameFunc

type GoVar2CmdInputNameFunc func(inName string) string

NameConvention define how name is interpreted from command line to Go variable, field name or structure name.

Jump to

Keyboard shortcuts

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