Documentation
¶
Index ¶
- Variables
- func AppendStringToFile(filePath, content string) error
- func BindJSON[T any](r *http.Request) (*T, error)
- func ByteCountIEC(b uint64) string
- func BytesToHexString(bytes []byte) string
- func BytesToString(b []byte, r ...int) string
- func CheckBinaryPack(data []byte) (byte, byte, bool)
- func CheckDir(dirPath string) bool
- func CleanExt(name string) string
- func CompareVersions(v1, v2 string) int
- func DecAES(data []byte, key []byte) ([]byte, error)
- func Decrypt(cipherHex string, key []byte) string
- func Delete(filePath string, args ...string)
- func DirCheck(path string) error
- func Divide(a, b int) int
- func DivideAndCeil(a, b int) int
- func DownLoadGeneric(baseUrl, username, password, destPath string) error
- func EncAES(data []byte, key []byte) ([]byte, error)
- func Encrypt(text []byte, key []byte) string
- func EnsureDir(path string) error
- func Export(obj model.CloudApi) error
- func FormatSize(size int64) string
- func GenRandByte(n int) []byte
- func GetAppSpace() (string, string, string)
- func GetDataByJson[T any](r *http.Request) (*T, error)
- func GetFileNameByTime() string
- func GetFileNameFromUrl(rawURL string) string
- func GetFilenameFromHeader(header http.Header) string
- func GetFirstPathSegment(path string) string
- func GetListeningPorts()
- func GetLocalIp() string
- func GetLocalMac() string
- func GetMD5(data []byte) ([]byte, string)
- func GetPointerInstance[T any](name string, obj interface{}) (t *T, err error)
- func GetPrimaryIP() (string, error)
- func GetSelfSize() uint64
- func GetSliceChunk[T any](data *[]T, start, end int) *[]T
- func GetSlicePrefix[T any](data *[]T, n int) *[]T
- func GetSliceSuffix[T any](data *[]T, n int) *[]T
- func GetStrUUID() string
- func GetTime() string
- func GetUUID() []byte
- func GetUserDir() (string, error)
- func GetVersion() map[string]interface{}
- func GetVersionByFileName(filename string) string
- func HasDiskSpace() bool
- func If[T any](b bool, t, f T) T
- func Import(obj model.CloudApi) error
- func IsClassC(ip net.IP) bool
- func IsClassCC(ip net.IP) bool
- func IsDirEmpty(dirPath string) (bool, error)
- func IsDirectoryExist(dirPath string) bool
- func IsExist(filePath string) bool
- func IsLinux() bool
- func IsMacOs() bool
- func IsPortOpen(host string, port int, timeout time.Duration) bool
- func IsPublicIPv4(ip net.IP) bool
- func IsURLValidAndAccessible(rawURL string) bool
- func IsWindows() bool
- func IsZipOrJson(filename string) (isZip, isJSON bool)
- func MakeDir(path string) error
- func Max[T int | int32 | int64 | uint | uint32 | uint64 | float32 | float64](a, b T) T
- func Min[T int | int32 | int64 | uint | uint32 | uint64 | float32 | float64](a, b T) T
- func MoveFileToDir(src string, dstDir string) error
- func ObjectToTomlText(obj interface{}) []byte
- func PingRaw(ip string) bool
- func Read(filePath string) ([]byte, error)
- func ReadToml(filePath string) ([]byte, error)
- func RemoveSlice[T comparable](slice []T, value T) []T
- func ReplaceNewVersionBinName(filename, v string) string
- func RestartProgram() error
- func SaveFile(file multipart.File, fileSize int64, saveFilePath string) error
- func ScanIP() []string
- func ScanPort(host string, duration time.Duration, start, end int) []int
- func ScanPorts(host string, start, end int) []int
- func SetFieldValue(obj interface{}, fieldName string, value interface{}) error
- func ShowUpDirSize()
- func Shutdown() error
- func SplitLastTwoByUnderscore(s string) []string
- func SplitVersion(v string) []string
- func SseHandler(queue *LogQueue) http.HandlerFunc
- func StringContains(element string, data []string) bool
- func StringToBytes(s string, r ...int) []byte
- func TestToml()
- func ToUpperFirst(s string) string
- func TomlTextToObject(tomlBytes []byte, obj interface{}) error
- func Unzip(src, dest string) error
- func UnzipToRoot(zipFile, destDir string, strich bool) error
- func UploadGeneric(baseUrl, method, cfgpath string, username, password string) error
- func Write(filePath string, content []byte) error
- func WriteAppend(filePath string, content []byte) error
- func WriteFile(filePath string, data []byte) error
- func WriteToml(filePath string, data []byte) error
- func XOR(data []byte, key []byte) []byte
- func Zip(dir, dst string) error
- func ZipFiles(zipPath string, files []string) error
- type AutoReplaceQueue
- type FixedQueue
- type GeneralResponse
- type LogQueue
- type NetworkInterface
- type Node
- type Option
- type ProgressWriter
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEntityInvalid = errors.New(`common.ENTITY_INVALID`) ErrFailedVerification = errors.New(`common.ENTITY_CHECK_FAILED`) )
Functions ¶
func AppendStringToFile ¶
func ByteCountIEC ¶ added in v0.1.91
func BytesToHexString ¶
func BytesToString ¶
func CompareVersions ¶
CompareVersions 0:相等;1:v1>v2;-1:v1<v2
func DownLoadGeneric ¶ added in v0.2.28
func FormatSize ¶
func GenRandByte ¶
func GetAppSpace ¶ added in v0.2.15
func GetFileNameByTime ¶
func GetFileNameByTime() string
func GetFileNameFromUrl ¶
func GetFilenameFromHeader ¶
func GetFirstPathSegment ¶ added in v0.2.6
GetFirstPathSegment 获取路径第一个有效段(优化实现)
func GetListeningPorts ¶
func GetListeningPorts()
func GetLocalIp ¶ added in v0.2.62
func GetLocalIp() string
func GetLocalMac ¶ added in v0.2.70
func GetLocalMac() string
func GetPointerInstance ¶
func GetPrimaryIP ¶ added in v0.2.70
GetPrimaryIP 获取主IP地址(默认网关所在接口的IP)
func GetSelfSize ¶ added in v0.1.68
func GetSelfSize() uint64
func GetSliceChunk ¶
func GetSlicePrefix ¶
func GetSliceSuffix ¶
func GetStrUUID ¶
func GetStrUUID() string
func GetUserDir ¶ added in v0.2.37
func GetVersion ¶ added in v0.3.8
func GetVersion() map[string]interface{}
func GetVersionByFileName ¶ added in v0.1.82
func HasDiskSpace ¶ added in v0.1.83
func HasDiskSpace() bool
func IsDirEmpty ¶ added in v0.3.59
func IsDirectoryExist ¶
func IsPublicIPv4 ¶ added in v0.3.39
func IsURLValidAndAccessible ¶
IsURLValidAndAccessible 检查 URL 是否有效并且可访问
func IsZipOrJson ¶
IsZipOrJson 根据后缀判断文件类型(仅后缀匹配)
func MoveFileToDir ¶ added in v0.1.82
func ObjectToTomlText ¶
func ObjectToTomlText(obj interface{}) []byte
func SetFieldValue ¶
SetFieldValue 使用反射给结构体的字段赋值
func ShowUpDirSize ¶ added in v0.1.83
func ShowUpDirSize()
func SplitLastTwoByUnderscore ¶ added in v0.1.92
func SplitVersion ¶
func SseHandler ¶ added in v0.2.69
func SseHandler(queue *LogQueue) http.HandlerFunc
SseHandler 处理函数
func StringContains ¶
func StringToBytes ¶
func TomlTextToObject ¶
func UnzipToRoot ¶
func UploadGeneric ¶ added in v0.2.28
func WriteAppend ¶
Types ¶
type AutoReplaceQueue ¶ added in v0.2.69
type AutoReplaceQueue struct {
// contains filtered or unexported fields
}
func NewAutoReplaceQueue ¶ added in v0.2.69
func NewAutoReplaceQueue(capacity int) *AutoReplaceQueue
func (*AutoReplaceQueue) Pop ¶ added in v0.2.69
func (q *AutoReplaceQueue) Pop() interface{}
Pop 取出元素
func (*AutoReplaceQueue) Push ¶ added in v0.2.69
func (q *AutoReplaceQueue) Push(item interface{})
Push 添加元素,通道满时自动丢弃旧元素
type FixedQueue ¶ added in v0.2.69
type FixedQueue[T any] struct { // contains filtered or unexported fields }
FixedQueue 泛型固定长度队列结构体
func NewFixedQueue ¶ added in v0.2.69
func NewFixedQueue[T any](capacity int) *FixedQueue[T]
NewFixedQueue 创建一个新的固定长度队列
func (*FixedQueue[T]) Capacity ¶ added in v0.2.69
func (q *FixedQueue[T]) Capacity() int
Capacity 返回队列容量
func (*FixedQueue[T]) Dequeue ¶ added in v0.2.69
func (q *FixedQueue[T]) Dequeue() (T, bool)
Dequeue 出队操作
func (*FixedQueue[T]) Enqueue ¶ added in v0.2.69
func (q *FixedQueue[T]) Enqueue(item T)
Enqueue 入队操作
type GeneralResponse ¶
type LogQueue ¶ added in v0.2.69
type LogQueue struct {
// contains filtered or unexported fields
}
LogQueue 定义日志队列
func (*LogQueue) AddMessage ¶ added in v0.2.69
AddMessage 生产者添加日志消息
func (*LogQueue) RegisterClient ¶ added in v0.2.69
RegisterClient 消费者注册客户端
func (*LogQueue) UnregisterClient ¶ added in v0.2.69
UnregisterClient 消费者注销客户端
type NetworkInterface ¶ added in v0.2.70
type NetworkInterface struct {
Name string `json:"name"` // 接口名称
DisplayName string `json:"displayName"` // 显示名称
MacAddress string `json:"macAddress"` // MAC地址
Ipv4 string `json:"ipv4"` // MAC地址
IPAddresses []string `json:"ipAddresses"` // IP地址列表
}
NetworkInterface 网络接口信息
func GetDeviceInfo ¶ added in v0.2.70
func GetDeviceInfo() (*NetworkInterface, error)
GetDeviceInfo 获取主IP地址、Mac地址(默认网关所在接口的IP)
func GetNetworkInterfaces ¶ added in v0.2.70
func GetNetworkInterfaces() ([]NetworkInterface, error)
GetNetworkInterfaces 获取所有网络接口信息
Click to show internal directories.
Click to hide internal directories.