Documentation
¶
Index ¶
- func Address(col int, row int) string
- func ClearRows(wb *excelize.File, sheet string, start int, end int)
- func ColToInt(colName string) int
- func CopyRowsBetween(wb *excelize.File, sheet string, start int, end int)
- func Decode(input interface{}, result interface{}) error
- func Dir(names ...string) *paths.Path
- func GetIPs(includeLocalhost bool) []string
- func HeaderIndexByKeywords(rows [][]string, keywords []string) (int, []string, error)
- func IntToCol(index int) string
- func LogServer(https bool, port int)
- func LogServerWithBasePath(https bool, port int, basePath string)
- func LogServerWithQR(https bool, port int, includeLocalhost bool)
- func LogServerWithQRAndBasePath(https bool, port int, includeLocalhost bool, basePath string)
- func MultipleFiles(c *gin.Context) []string
- func MultipleFilesWithTimestamp(c *gin.Context) []string
- func NewUUID() string
- func NewXID() string
- func ParseAddress(address string) (int, int, error)
- func ParseDecimal(value string) (decimal.Decimal, error)
- func ParseDecimalOrZero(value string) decimal.Decimal
- func ParseTimeAny(value string) (time.Time, error)
- func ParseUUID(value string) (uuid.UUID, error)
- func Percentage(value float32, min float32, max float32) (raw float32, safe float32)
- func Print(v ...any)
- func PrintMulti(lines ...string)
- func ReadFirstSheetRaw(path string) ([][]string, error)
- func SetServerLogStyle(style ServerLogStyle)
- func ToTimeHookFunc() mapstructure.DecodeHookFunc
- func TryFindMatch(pattern string, stringToMatch string) (*re.Match, error)
- func ValidateStruct(value interface{}) error
- func ValidateVar(value interface{}, tag string) error
- func Validator() *validator.Validate
- func Write1[DataType any](wb *excelize.File, sheet string, colIndex int, rowIndex int, ...) []error
- func Write2[DataType any](wb *excelize.File, sheet string, colName string, rowIndex int, ...) []error
- type ServerLogStyle
- type StringDict
- func ReadFirstSheet1(path string, headerIndex int, dataIndex int) ([](StringDict), error)
- func ReadFirstSheet2(path string, colNameExamples []string, dataIndexOffset int) ([](StringDict), error)
- func RowsToDict1(rows [][]string, headerIndex int, dataIndex int) [](StringDict)
- func RowsToDict2(rows [][]string, colNameExamples []string, dataIndexOffset int) ([](StringDict), error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dir ¶
Dir 根据传入的目录名称依次在当前工作目录下创建目录,并返回最终目录的路径。 参数 names 为要创建的目录名称列表(可变参数)。 返回值为最终创建的目录的 *paths.Path 对象。
func GetIPs ¶
GetIPs returns a slice of IP addresses of the local machine. If includeLocalhost is true, it also includes "localhost" in the result. It filters out loopback addresses and only includes IPv4 addresses. Note: This function does not handle errors from net.InterfaceAddrs(). It is assumed that the caller will handle any potential errors. The function is useful for logging or displaying server addresses.
func HeaderIndexByKeywords ¶
*
- @param rows 二维字符串数组,每一行表示Excel中的一行数据
- @param keywords 关键词数组,用于确定标题行的位置
- @return 标题行索引、标题行数据、错误信息
func LogServer ¶
LogServer prints the server address in a formatted way. It takes a boolean indicating whether to use HTTPS and an integer for the port.
func LogServerWithBasePath ¶ added in v0.1.5
LogServerWithBasePath prints Local/Network URLs with a styled format.
func LogServerWithQR ¶ added in v0.0.3
LogServerWithQR prints the server address and renders a QR code in terminal. It will prioritize the first non-localhost URL for QR, fallback to localhost.
func LogServerWithQRAndBasePath ¶ added in v0.1.5
LogServerWithQRAndBasePath prints Local/Network URLs and renders QR code.
func MultipleFiles ¶
func NewXID ¶ added in v0.0.3
func NewXID() string
NewXID returns a lexicographically sortable XID string.
func ParseDecimal ¶ added in v0.0.3
ParseDecimal parses a decimal string.
func ParseDecimalOrZero ¶ added in v0.0.3
ParseDecimalOrZero parses a decimal string and returns zero on error.
func ParseTimeAny ¶ added in v0.0.3
ParseTimeAny parses a date/time string with dateparse.
func Percentage ¶
获取百分比, 结果为0-100之间的值
func Print ¶ added in v0.1.4
func Print(v ...any)
Print prints a single log line with a green [go] prefix.
func PrintMulti ¶ added in v0.1.4
func PrintMulti(lines ...string)
PrintMulti prints multiple lines, each prefixed with a green [go] tag.
func SetServerLogStyle ¶ added in v0.1.5
func SetServerLogStyle(style ServerLogStyle)
SetServerLogStyle changes LogServer output color theme.
func ToTimeHookFunc ¶
func ToTimeHookFunc() mapstructure.DecodeHookFunc
func ValidateStruct ¶ added in v0.0.3
func ValidateStruct(value interface{}) error
ValidateStruct validates a struct using a new validator instance.
func ValidateVar ¶ added in v0.0.3
ValidateVar validates a variable against a tag using a new validator instance.
Types ¶
type ServerLogStyle ¶ added in v0.1.5
type ServerLogStyle string
ServerLogStyle controls the color theme of LogServer output.
const ( // ServerLogStyleNeon keeps the current bright green/magenta/cyan style. ServerLogStyleNeon ServerLogStyle = "neon" // ServerLogStyleSunset uses a warm orange/yellow palette. ServerLogStyleSunset ServerLogStyle = "sunset" // ServerLogStyleOcean uses cool blue/cyan tones. ServerLogStyleOcean ServerLogStyle = "ocean" // ServerLogStyleForest uses green/yellow tones. ServerLogStyleForest ServerLogStyle = "forest" // ServerLogStyleMono uses grayscale output. ServerLogStyleMono ServerLogStyle = "mono" )
func ServerLogStyles ¶ added in v0.1.6
func ServerLogStyles() []ServerLogStyle
ServerLogStyles returns all available styles.
type StringDict ¶
func ReadFirstSheet1 ¶
func ReadFirstSheet1(path string, headerIndex int, dataIndex int) ([](StringDict), error)
*
- @param path Excel文件路径
- @param headerIndex 标题行索引
- @param dataIndex 数据行索引
- @return 转换后的字符串字典数组
func ReadFirstSheet2 ¶
func ReadFirstSheet2(path string, colNameExamples []string, dataIndexOffset int) ([](StringDict), error)
*
- @param path Excel文件路径
- @param colNameExamples 列名示例,用于确定标题行的位置
- @param dataIndexOffset 数据行索引的偏移量,用于确定数据行的位置
- @return 转换后的字符串字典数组
func RowsToDict1 ¶
func RowsToDict1(rows [][]string, headerIndex int, dataIndex int) [](StringDict)
*
- @param rows 二维字符串数组,每一行表示Excel中的一行数据
- @param headerIndex 标题行索引
- @param dataIndex 数据行索引
- @return 转换后的字符串字典数组
func RowsToDict2 ¶
func RowsToDict2(rows [][]string, colNameExamples []string, dataIndexOffset int) ([](StringDict), error)
*
@param rows 二维字符串数组,每一行表示Excel中的一行数据 @param colNameExamples 列名示例,用于确定标题行的位置 @param dataIndexOffset 数据行索引的偏移量,用于确定数据行的位置 @return 转换后的字符串字典数组