goext

package
v0.0.0-...-a780a43 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayChunk

func ArrayChunk(s []interface{}, size int) [][]interface{}

一个数组分割为多个数组

func ArrayColumn

func ArrayColumn(structSlice []interface{}, key string) []interface{}

返回输入数组中某个单一列的值

func ArrayUnique

func ArrayUnique(arr []string) (newArr []string)

数组去重

func ConvertToString

func ConvertToString(src string, srcCode string, tagCode string) string

编码转换 ConvertToString(str, "gbk", "utf-8")

func Date

func Date(format string) string

获取当前日期时间 Date("2006-01-02 15:04:05")

func DateTime

func DateTime(format string, timestamp int64) string

时间戳转日期时间 Date("2006-01-02 15:04:05", 1524799394)

func ExecCommand

func ExecCommand(c string) (string, error)

执行命令行

func Explode

func Explode(delimiter, str string) []string

字符串分割成数组

func FileExists

func FileExists(filename string) bool

检查文件或目录是否存在

func Gexcel

func Gexcel(data [][]string, file string, sheet string) error

生成EXCEL

func HttpGetRequest

func HttpGetRequest(requestUrl string, requestHeaders ...map[string]string) ([]byte, error)

GET请求

func HttpPostRequest

func HttpPostRequest(requestUrl string, postData map[string]string, requestHeaders ...map[string]string) ([]byte, error)

POST请求

func HttpProxyRequest

func HttpProxyRequest(method, requestUrl string, proxy string, timeout int, postData map[string]string, requestHeaders map[string]string) ([]byte, error)

HTTP代理请求

func Implode

func Implode(glue string, pieces []string) string

数组转字符串

func In_Array

func In_Array(val interface{}, array interface{}) (exists bool, index int)

判断某一个值是否含在切片之中

func IsDir

func IsDir(filename string) (bool, error)

检查指定的文件是否是一个目录

func IsDirCreate

func IsDirCreate(path string)

检测目录是否存在,不存在就创建

func IsEmpty

func IsEmpty(val interface{}) bool

检查一个变量是否为空

func IsNumeric

func IsNumeric(val interface{}) bool

检测变量是否为数字或数字字符串

func Lcfirst

func Lcfirst(str string) string

首字符转换为小写

func Ltrim

func Ltrim(str string, characterMask ...string) string

移除字符串左侧的空白字符或其他预定义字符

func MbStrlen

func MbStrlen(str string) int

字符串的长度 MbStrlen("中国人!") = 4 单个汉字 = 1

func Qexcel

func Qexcel(filePath, sheet string) ([][]string, error)

查询EXCEL

func Rand

func Rand(min, max int) int

返回随机数

func ReadFile

func ReadFile(filePath string) ([]byte, error)

读取文件

func Rtrim

func Rtrim(str string, characterMask ...string) string

移除字符串右侧的空白字符或其他预定义字符

func Scanf

func Scanf(a *string)

字符串标准输入一行内容空格不拆分

func Sleep

func Sleep(t int64)

停顿、暂停 Sleep(3) 停顿3秒

func StrReplace

func StrReplace(search, replace, subject string, count int) string

以其他字符替换字符串中的一些字符(区分大小写) StrReplace("go", "1", "You love go, I love go too!", -1)

func Stripos

func Stripos(haystack, needle string, offset int) int

查找字符串在另一字符串中第一次出现的位置(不区分大小写) Stripos("You love go, I love go too!", "go", 0)

func Strlen

func Strlen(str string) int

字符串的长度 Strlen("中国人!") = 10 单个汉字 = 3

func Strpos

func Strpos(haystack, needle string, offset int) int

查找字符串在另一字符串中第一次出现的位置(区分大小写) Strpos("You love go, I love go too!", "go", 0)

func Strripos

func Strripos(haystack, needle string, offset int) int

查找字符串在另一字符串中最后一次出现的位置(不区分大小写) Strripos("You love go, I love go too!", "go", -1)

func Strrpos

func Strrpos(haystack, needle string, offset int) int

查找字符串在另一字符串中最后一次出现的位置(区分大小写) Strrpos("You love go, I love go too!", "go", -1)

func Strstr

func Strstr(haystack string, needle string) string

搜索字符串在另一字符串中第一次出现之后的字符串 Strstr("You love go, I love go too!", "love")

func StrtoTime

func StrtoTime(format, strtime string) (int64, error)

日期时间转换时间戳 Stamptime("2006-01-02 15:04:05", "2016-01-02 15:04:05")

func Strtolower

func Strtolower(str string) string

字符转换为小写

func Strtoupper

func Strtoupper(str string) string

字符转换为大写

func Substr

func Substr(str string, start int, length int) string

返回部分字符串 Substr("You love go, I love go too!", 0, 1)

func Time

func Time() int64

获取当前时间戳

func Tracefile

func Tracefile(content, filename string, mode string, bom ...string) (int, error)

写入文件

func Trim

func Trim(str string, characterMask ...string) string

移除字符串两侧的空白字符或其他预定义字符

func UA

func UA() string

随机UA

func Ucfirst

func Ucfirst(str string) string

首字符转换为大写

func Ucwords

func Ucwords(str string) string

把字符串中每个单词的首字符转换为大写

func XmlDecode

func XmlDecode(data string) map[string]string

解析XML

Types

type Cli

type Cli struct {
	IP       string //IP地址
	Username string //用户名
	Password string //密码
	Port     int    //端口号
}

func (Cli) Ssh

func (c Cli) Ssh() (*ssh.Session, error)

创建命令行对象

type ConfigIni

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

func LoadConfig

func LoadConfig(filepath string) *ConfigIni

func (*ConfigIni) GetValue

func (c *ConfigIni) GetValue(mark, name string) string

返回单个数据

func (*ConfigIni) GetValues

func (c *ConfigIni) GetValues(mark string) map[string]string

批量返回数据

func (*ConfigIni) ReadList

func (c *ConfigIni) ReadList() []map[string]map[string]string

列出所有配置文件

Jump to

Keyboard shortcuts

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