xutil

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

* @Date: 2023-07-20 09:34:46 * @LastEditTime: 2023-07-20 10:26:35 * @Description:

* @Date: 2023-07-20 10:23:00 * @LastEditTime: 2023-07-20 10:23:01 * @Description:

* @Date: 2023-09-07 16:40:46 * @LastEditTime: 2023-09-07 16:40:47 * @Description:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b interface{}) int

Compare ...

func CompareNumber

func CompareNumber(a, b interface{}) int

CompareNumber ...

func CompareString

func CompareString(a, b interface{}) int

CompareString ...

func Expand added in v0.0.4

func Expand(s string, m map[string]interface{}) string

Expand replaces {var} of string s based on the value map m For example, Expand("i am {name}", map[string]interface{}{"name": "Li Kexian"})

func GetExtension added in v0.0.4

func GetExtension(domain string) string

func GetExternalIP

func GetExternalIP() string

GetExternalIP 获取公网 IP

func GetIntranetIP

func GetIntranetIP() string

GetIntranetIP 获取内网 IP

func GetLastChars added in v0.0.3

func GetLastChars(str string, num int) string

GetFirstChars returns first num chars of str

func GetLocalMacAddr

func GetLocalMacAddr() (string, error)

GetLocalMacAddr @Description: get local mac address @return string @return error @author cx

func Getenv

func Getenv(key string, defaults ...string) string

Getenv ...

func GetenvMap

func GetenvMap() map[string]string

GetenvMap ...

func If

func If(cond bool, val1, val2 interface{}) interface{}

If 三目运算

func IsLetter added in v0.0.4

func IsLetter(s uint8) bool

IsLetter returns if s is an english letter

func IsLetters added in v0.0.4

func IsLetters(s string) bool

IsLetters returns if s is all english letter

func IsLinux

func IsLinux() bool

IsLinux ...

func IsMac

func IsMac() bool

IsMac ...

func IsNumeric added in v0.0.4

func IsNumeric(s string) bool

IsNumeric returns if s is a number

func IsWin

func IsWin() bool

IsWin ...

func Join added in v0.0.4

func Join(v interface{}, sep string) string

Join concatenates the elements and returns string

func LastInIndex added in v0.0.4

func LastInIndex(s, f string) int

LastInIndex find last position at first index

for example, LastInIndex("{{{{{{{{{{name}", "{")
                                   ↑

func Len

func Len(s string) int

Len ..

func Parse

func Parse(obj interface{}, path string) interface{}

Parse ...

func Replace

func Replace(s string, replace map[string]string) string

Replace ...

func Reverse added in v0.0.4

func Reverse(s string) string

Reverse returns reversed string

func SafeRun added in v0.0.4

func SafeRun(f func()) (backErr error)

SafeRun 能处理 panic 的函数容器

func Setenv

func Setenv(key, value string) error

Setenv ...

func SpiltStr added in v0.0.4

func SpiltStr(str string) []string

SpiltStr retruns string array by \n

func ToString added in v0.0.4

func ToString(v interface{}) string

ToString convert v to string

Types

This section is empty.

Jump to

Keyboard shortcuts

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