utils

package
v0.0.0-...-f3bd3d7 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(col int, row int) string

*

  • @param col 要转换的数字
  • @param row 要转换的数字
  • @return 转换后的结果

func ClearRows

func ClearRows(wb *excelize.File, sheet string, start int, end int)

*

  • @param wb Excel文件对象
  • @param sheet 工作表名称
  • @param start 起始行索引
  • @param end 结束行索引

func ColToInt

func ColToInt(colName string) int

*

  • @param colName 要转换的列名
  • @return 转换后的结果

func CopyRowsBetween

func CopyRowsBetween(wb *excelize.File, sheet string, start int, end int)

*

  • @param wb Excel文件对象
  • @param sheet 工作表名称
  • @param start 起始行索引
  • @param end 结束行索引

func Decode

func Decode(input interface{}, result interface{}) error

func Dir

func Dir(names ...string) *paths.Path

Dir 根据传入的目录名称依次在当前工作目录下创建目录,并返回最终目录的路径。 参数 names 为要创建的目录名称列表(可变参数)。 返回值为最终创建的目录的 *paths.Path 对象。

func GetIPs

func GetIPs(includeLocalhost bool) []string

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

func HeaderIndexByKeywords(rows [][]string, keywords []string) (int, []string, error)

*

  • @param rows 二维字符串数组,每一行表示Excel中的一行数据
  • @param keywords 关键词数组,用于确定标题行的位置
  • @return 标题行索引、标题行数据、错误信息

func IntToCol

func IntToCol(index int) string

*

  • @param index 要转换的数字
  • @return 转换后的结果

func LogServer

func LogServer(https bool, port int)

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 MultipleFiles

func MultipleFiles(c *gin.Context) []string

func MultipleFilesWithTimestamp

func MultipleFilesWithTimestamp(c *gin.Context) []string

func Percentage

func Percentage(value float32, min float32, max float32) (raw float32, safe float32)

获取百分比, 结果为0-100之间的值

func ReadFirstSheetRaw

func ReadFirstSheetRaw(path string) ([][]string, error)

*

  • @param path Excel文件路径
  • @return 转换后的字符串字典数组

func ToTimeHookFunc

func ToTimeHookFunc() mapstructure.DecodeHookFunc

func TryFindMatch

func TryFindMatch(pattern string, stringToMatch string) (*re.Match, error)

func Write1

func Write1[DataType any](wb *excelize.File, sheet string, colIndex int, rowIndex int, values [][]DataType) []error

*

  • @param wb Excel文件对象
  • @param sheet 工作表名称
  • @param colIndex 列索引
  • @param rowIndex 行索引
  • @param values 要写入的值
  • @return 错误数组

func Write2

func Write2[DataType any](wb *excelize.File, sheet string, colName string, rowIndex int, values [][]DataType) []error

*

  • @param wb Excel文件对象
  • @param sheet 工作表名称
  • @param colName 列名
  • @param rowIndex 行索引
  • @param values 要写入的值
  • @return 错误数组

Types

type StringDict

type StringDict map[string]string

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 转换后的字符串字典数组

Jump to

Keyboard shortcuts

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