osx

package
v0.11.18 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 21 Imported by: 3

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.

* @Author: kamalyes 501893067@qq.com * @Date: 2024-10-24 11:25:16 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2024-11-08 13:18:55 * @FilePath: \go-toolbox\pkg\osx\pool.go * @Description: * * Copyright (c) 2024 by kamalyes, All Rights Reserved.

Index

Constants

View Source
const (
	OSMac     = "darwin"
	OSWindows = "windows"
	OSLinux   = "linux"
)

定义操作系统常量

Variables

View Source
var GetGOOS = func() string {
	return runtime.GOOS
}

GetGOOS 返回当前操作系统

Functions

func CheckImageExists

func CheckImageExists(filename string) error

CheckImageExists 检查图像文件是否存在并且有效

func Command added in v0.11.9

func Command(bin string, argv []string, baseDir string) ([]byte, error)

Command 执行系统命令

func Copy added in v0.11.6

func Copy(src, dest string) error

Copy 复制文件从源路径到目标路径

func CreateIfNotExist added in v0.11.6

func CreateIfNotExist(file string) (*os.File, error)

CreateIfNotExist 如果文件不存在则创建它

func DirHasContent added in v0.11.6

func DirHasContent(dir string) (bool, []string, error)

DirHasContent 检查目录是否有内容(即是否有非空文件)

func FileExists added in v0.11.6

func FileExists(file string) bool

FileExists 检查文件是否存在

func FileNameWithoutExt added in v0.11.6

func FileNameWithoutExt(file string) string

FileNameWithoutExt 返回不带扩展名的文件名

func GetClientPublicIP added in v0.11.5

func GetClientPublicIP(r *http.Request) (string, error)

GetClientPublicIP 从HTTP请求中获取客户端的公网IP地址。 如果无法确定公网IP,则返回空字符串和错误(如果适用)。

func GetConNetPublicIp added in v0.11.5

func GetConNetPublicIp(urls ...string) (string, error)

GetConNetPublicIp 联网获取本机公网 IP

func GetDirFiles

func GetDirFiles(dir string) ([]string, error)

GetDirFiles 获取指定目录及其子目录下的所有文件路径 参数:dir - 目录路径 返回:所有文件的路径切片和可能的错误

func GetHostName added in v0.11.5

func GetHostName() (string, error)

GetHostName 获取主机名,如果失败则返回错误

func GetLocalInterfaceIeIp added in v0.11.5

func GetLocalInterfaceIeIp() (string, string, error)

GetLocalInterfaceIeIp 返回本地网卡对应的外部和内部 IP 地址

func GetLocalInterfaceIps added in v0.11.5

func GetLocalInterfaceIps() ([]net.IP, error)

GetLocalInterfaceIps 查询本机网卡所有IP

func HashUnixMicroCipherText

func HashUnixMicroCipherText() string

HashUnixMicroCipherText

func IsLinux added in v0.11.15

func IsLinux() bool

IsLinux 检查当前操作系统是否为 Linux

func IsMac added in v0.11.15

func IsMac() bool

IsMac 检查当前操作系统是否为 macOS

func IsSupportedOS added in v0.11.15

func IsSupportedOS() bool

IsSupportedOS 检查当前操作系统是否在支持的操作系统列表中

func IsWindows added in v0.11.15

func IsWindows() bool

IsWindows 检查当前操作系统是否为 Windows

func JoinPaths added in v0.11.6

func JoinPaths(absolutePath, relativePath string) string

JoinPaths 连接绝对路径和相对路径。

func MkdirIfNotExist added in v0.11.6

func MkdirIfNotExist(dir string) error

MkdirIfNotExist 如果目录不存在则创建它

func MkdirTemp added in v0.11.6

func MkdirTemp() string

MkdirTemp 创建一个临时目录,如果创建失败则程序退出

func RemoveIfExist added in v0.11.6

func RemoveIfExist(filename string) error

RemoveIfExist 如果文件存在则删除它

func SafeGetHostName

func SafeGetHostName() string

获取主机名函数

func SaveImage

func SaveImage(filename string, imgData []byte, quality int) error

SaveImage 将字节数据保存为指定文件名的图片

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 LimitedPool added in v0.11.5

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

LimitedPool 管理多个 levelPool,以支持不同大小的字节切片

func NewLimitedPool added in v0.11.5

func NewLimitedPool(minSize, maxSize int) *LimitedPool

NewLimitedPool 创建一个新的 LimitedPool,指定最小和最大大小

func (*LimitedPool) Get added in v0.11.5

func (p *LimitedPool) Get(size int) *[]byte

Get 从池中获取指定大小的字节切片

func (*LimitedPool) Put added in v0.11.5

func (p *LimitedPool) Put(b *[]byte)

Put 将字节切片放回池中以供重用

type RunTimeCaller added in v0.11.6

type RunTimeCaller struct {
	Pc       uintptr // 程序计数器
	File     string  // 文件名
	Line     int     // 行号
	FuncName string  // 函数名
}

RunTimeCaller 结构体用于存储调用栈信息

func GetCallerInfo added in v0.11.6

func GetCallerInfo(skip int) *RunTimeCaller

GetCallerInfo 获取调用栈信息

Jump to

Keyboard shortcuts

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