helper

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const TypeB = "bool"
View Source
const TypeI = "int"
View Source
const TypeIArr = "[]int"
View Source
const TypeIArr2d = "[][]int"
View Source
const TypeMapIToI = "map[int]int"
View Source
const TypeMapIToIArr = "map[int][]int"
View Source
const TypeMapIToStr = "map[int]string"
View Source
const TypeMapIToStrArr = "map[int][]string"
View Source
const TypeMapStrToI = "map[string]int"
View Source
const TypeMapStrToIArr = "map[string][]int"
View Source
const TypeMapStrToStr = "map[string]string"
View Source
const TypeMapStrToStrArr = "map[string][]string"
View Source
const TypeStr = "string"
View Source
const TypeStrArr = "[]string"
View Source
const TypeStrArr2d = "[][]string"

Variables

View Source
var TypGlobalNameMatcher = regexp.MustCompile("^[gG]lobal.*$") // global
View Source
var TypI18nNameMatcher = regexp.MustCompile(`^i18n.*$`) // i18n表
View Source
var TypNormalNameMatcher = regexp.MustCompile("^[a-z0-9]+.*$") // 普通表

Functions

func AllValidTypeNames

func AllValidTypeNames() []string

AllValidTypeNames 返回所有合法的类型名称

func BareNameOfCsvFile added in v0.0.4

func BareNameOfCsvFile(fullPath string) string

func DirMustEmpty

func DirMustEmpty(dir string)

func FileCsvRead

func FileCsvRead(item string) [][]string

func FileCsvWrite

func FileCsvWrite(csvFilePath string, grid [][]string)

func FilenameByType

func FilenameByType(bareName string) string

FilenameByType 返回文件名

func FmtCsvFileNameOfCsvFile added in v0.0.4

func FmtCsvFileNameOfCsvFile(fullPath string) string

func FormatTypeName

func FormatTypeName(typeName string) string

FormatTypeName 格式化类型名称

func GetVariableLiteralValue

func GetVariableLiteralValue(typ string, val string) string

func GoLiteralValInt

func GoLiteralValInt(val string) string

func GoLiteralValIntArr

func GoLiteralValIntArr(val string) string

func GoLiteralValIntArr2d added in v0.0.5

func GoLiteralValIntArr2d(val string) string

func GoLiteralValStr

func GoLiteralValStr(val string) string

func GridDoesColumnHasValue

func GridDoesColumnHasValue(grid [][]string) []bool

GridDoesColumnHasValue 判断grid的列是否有值

func GridFillColumn

func GridFillColumn(grid [][]string, colCount int) [][]string

GridFillColumn 填充列

func GridFilterColumn

func GridFilterColumn(grid [][]string, colHasVal []bool) [][]string

GridFilterColumn 过滤grid的列

func GridMaxColumnLen

func GridMaxColumnLen(grids [][]string) int

GridMaxColumnLen 返回有效grid的有效列数(不包含每行尾部的空值)

func GridOmitEmptyRow

func GridOmitEmptyRow(grid [][]string) [][]string

GridOmitEmptyRow 删除空行

func GridSplitHeader

func GridSplitHeader(grid [][]string, headerRowCount int) (headerGrid, dataGrid [][]string)

GridSplitHeader 分裂成两个grid

func GridTrimCellSpace

func GridTrimCellSpace(grid [][]string) [][]string

GridTrimCellSpace 去掉每个cell的空格

func IsExist

func IsExist(filepath string) bool

IsExist filepath 对应的文件是否存在

func ListFilenameByExt

func ListFilenameByExt(dir string, extNames ...string) []string

ListFilenameByExt 根据扩展名取文件, 扩展名不区分大小写

func MakeSureExist

func MakeSureExist(dir string)

func NameBareName added in v0.0.4

func NameBareName(fullPath string) string

func NameRemoveHan added in v0.0.4

func NameRemoveHan(s string) string

func NameToCamelCase added in v0.0.4

func NameToCamelCase(s string) string

NameToCamelCase converts snake_case strings to camelCase.

func NameToSnakeCase added in v0.0.4

func NameToSnakeCase(s string) string

NameToSnakeCase converts CamelCase to snake_case, avoiding consecutive underscores.

func NameUpperFirstLetter added in v0.0.4

func NameUpperFirstLetter(name string) string

func RenderTemplate

func RenderTemplate(outputFilePath string, tmpl *template.Template, param any)

RenderTemplate 渲染模板

func RenderTemplateByFilePath

func RenderTemplateByFilePath(outputFilePath string, templateFilePath string, param any)

RenderTemplateByFilePath 渲染模板

func RowIsEmpty

func RowIsEmpty(row []string) bool

RowIsEmpty 判断行是否为空

Types

type ConfigTyp

type ConfigTyp int
const (
	ConfigTypInvalid ConfigTyp = iota // 占位
	ConfigTypGlobal                   // 枚举配置表
	ConfigTypNormal                   // 普通配置表
	ConfigTypI18n                     // 多语言配置表
)

配置表类型

func GetConfType

func GetConfType(bareName string) (typ ConfigTyp)

GetConfType 获取配置文件的类型

func (ConfigTyp) String

func (t ConfigTyp) String() string

Jump to

Keyboard shortcuts

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