Documentation
¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-10 17:17:09 * @FilePath: \go-toolbox\pkg\osx\base.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-10-28 09:52:21 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-11 10:53:21 * @FilePath: \go-toolbox\pkg\osx\file.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2023-07-28 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-26 13:32:51 * @FilePath: \go-toolbox\pkg\osx\goos.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2024-11-09 00:50:58 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-11 17:08:09 * @FilePath: \go-toolbox\pkg\osx\path.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- Constants
- Variables
- func CheckImageExists(filename string) error
- func Command(bin string, argv []string, baseDir string) ([]byte, error)
- func Copy(src, dest string) error
- func CreateIfNotExist(file string) (*os.File, error)
- func DirHasContent(dir string) (bool, []string, error)
- func FileExists(file string) bool
- func FileNameWithoutExt(file string) string
- func GetClientPublicIP(r *http.Request) (string, error)
- func GetConNetPublicIp(urls ...string) (string, error)
- func GetDirFiles(dir string) ([]string, error)
- func GetHostName() (string, error)
- func GetLocalInterfaceIeIp() (string, string, error)
- func GetLocalInterfaceIps() ([]net.IP, error)
- func HashUnixMicroCipherText() string
- func IsLinux() bool
- func IsMac() bool
- func IsSupportedOS() bool
- func IsWindows() bool
- func JoinPaths(absolutePath, relativePath string) string
- func MkdirIfNotExist(dir string) error
- func MkdirTemp() string
- func RemoveIfExist(filename string) error
- func SafeGetHostName() string
- func SaveImage(filename string, imgData []byte, quality int) error
- type HashResult
- type RunTimeCaller
Constants ¶
const ( OSMac = "darwin" OSWindows = "windows" OSLinux = "linux" )
定义操作系统常量
Variables ¶
var GetGOOS = func() string { return runtime.GOOS }
GetGOOS 返回当前操作系统
Functions ¶
func CheckImageExists ¶
CheckImageExists 检查图像文件是否存在并且有效
func CreateIfNotExist ¶ added in v0.11.6
CreateIfNotExist 如果文件不存在则创建它
func DirHasContent ¶ added in v0.11.6
DirHasContent 检查目录是否有内容(即是否有非空文件)
func FileNameWithoutExt ¶ added in v0.11.6
FileNameWithoutExt 返回不带扩展名的文件名
func GetClientPublicIP ¶ added in v0.11.5
GetClientPublicIP 从HTTP请求中获取客户端的公网IP地址。 如果无法确定公网IP,则返回空字符串和错误(如果适用)。
func GetConNetPublicIp ¶ added in v0.11.5
GetConNetPublicIp 联网获取本机公网 IP
func GetDirFiles ¶
GetDirFiles 获取指定目录及其子目录下的所有文件路径 参数:dir - 目录路径 返回:所有文件的路径切片和可能的错误
func GetLocalInterfaceIeIp ¶ added in v0.11.5
GetLocalInterfaceIeIp 返回本地网卡对应的外部和内部 IP 地址
func GetLocalInterfaceIps ¶ added in v0.11.5
GetLocalInterfaceIps 查询本机网卡所有IP
func IsSupportedOS ¶ added in v0.11.15
func IsSupportedOS() bool
IsSupportedOS 检查当前操作系统是否在支持的操作系统列表中
func MkdirIfNotExist ¶ added in v0.11.6
MkdirIfNotExist 如果目录不存在则创建它
func RemoveIfExist ¶ added in v0.11.6
RemoveIfExist 如果文件存在则删除它
Types ¶
type HashResult ¶ added in v0.11.6
type HashResult struct { MD5 string SHA1 string SHA224 string SHA256 string SHA384 string SHA512 string }
HashResult 是一个结构体,用于存储不同哈希算法的结果。
func ComputeHashes ¶ added in v0.11.6
func ComputeHashes(filePath string) (*HashResult, error)
ComputeHashes 计算并返回文件的所有哈希值。
type RunTimeCaller ¶ added in v0.11.6
type RunTimeCaller struct { Pc uintptr // 程序计数器 File string // 文件名 Line int // 行号 FuncName string // 函数名 }
RunTimeCaller 结构体用于存储调用栈信息
func GetRuntimeCaller ¶ added in v0.11.34
func GetRuntimeCaller(skip int) *RunTimeCaller
GetRuntimeCaller 获取调用栈信息