util

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: GPL-3.0 Imports: 14 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// DoNotEditHead added to the beginning of a file to prompt the user not to edit
	DoNotEditHead = "// Code generated by goctl. DO NOT EDIT."
)

Variables

This section is empty.

Functions

func CloneIntoGitHome

func CloneIntoGitHome(url, branch string) (dir string, err error)

func EscapeGolangKeyword

func EscapeGolangKeyword(s string) string

EscapeGolangKeyword escapes the golang keywords.

func GetHead

func GetHead(source string) string

GetHead returns a code head string with source filename

func Index

func Index(slice []string, item string) int

Index returns the index where the item equal,it will return -1 if mismatched

func IsEmptyStringOrWhiteSpace

func IsEmptyStringOrWhiteSpace(s string) bool

func IsTemplateVariable

func IsTemplateVariable(text string) bool

IsTemplateVariable returns true if the text is a template variable. The text must start with a dot and be a valid template.

func SafeString

func SafeString(in string) string

SafeString converts the input string into a safe naming style in golang

func TemplateVariable

func TemplateVariable(text string) string

TemplateVariable returns the variable name of the template.

func Title

func Title(s string) string

Title returns a string value with s[0] which has been convert into upper case that there are not empty input text

func TrimWhiteSpace

func TrimWhiteSpace(s string) string

func Untitle

func Untitle(s string) string

Untitle returns a string value with s[0] which has been convert into lower case that there are not empty input text

Types

type DefaultTemplate

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

DefaultTemplate is a tool to provides the text/template operations

func With

func With(name string) *DefaultTemplate

With returns an instance of DefaultTemplate

func (*DefaultTemplate) Execute

func (t *DefaultTemplate) Execute(data any) (*bytes.Buffer, error)

Execute returns the codes after the template executed

func (*DefaultTemplate) GoFmt

func (t *DefaultTemplate) GoFmt(format bool) *DefaultTemplate

GoFmt sets the value to goFmt and marks the generated codes will be formatted or not

func (*DefaultTemplate) Parse

func (t *DefaultTemplate) Parse(text string) *DefaultTemplate

Parse accepts a source template and returns DefaultTemplate

func (*DefaultTemplate) SaveTo

func (t *DefaultTemplate) SaveTo(data any, path string, forceUpdate bool) error

SaveTo writes the codes to the target path

Directories

Path Synopsis
Package name provides methods to verify naming style and format naming style See the method IsNamingValid, FormatFilename
Package name provides methods to verify naming style and format naming style See the method IsNamingValid, FormatFilename

Jump to

Keyboard shortcuts

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