Documentation
¶
Index ¶
- Variables
- func CheckPort(host string, port int) bool
- func DownloadFile(url, filepath string) error
- func E(c *gin.Context, code int, msg string)
- func EnvGet(key string, defaultValue string) string
- func EnvGetBool(key string, defaultValue bool) bool
- func EnvGetFloat64(key string, defaultValue float64) float64
- func EnvGetInt(key string, defaultValue int) int
- func EnvLoad() error
- func EnvSet(key string, value string)
- func EnvUnset(key string)
- func GetAvailablePort() int
- func GetBaseboardId() string
- func GetComputerName() string
- func GetCpuId() string
- func GetLocalIP() string
- func GetMachineCode() string
- func GetMemoryId() string
- func GetOutboundIP() string
- func GetProxy() (string, string)
- func ResetIPCache()
- func S(c *gin.Context, data interface{}, msg string)
- func SuccessFile(c *gin.Context, filename string, data []byte, contentType string)
- func SuccessHTML(c *gin.Context, html string)
- type ResData
- type SystemInfo
- type ToolMap
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorMessages = map[int]string{
400: "参数错误",
401: "未授权",
403: "禁止访问",
404: "资源不存在",
408: "请求超时",
429: "请求过于频繁",
500: "服务器内部错误",
502: "网关错误",
503: "服务不可用",
504: "网关超时",
}
ErrorMessages 错误码映射消息
View Source
var Ip string = "0.0.0.0"
Functions ¶
func EnvGetBool ¶ added in v1.5.1
GetBool 获取环境变量,如果不存在则返回默认值
func EnvGetFloat64 ¶ added in v1.5.1
GetFloat64 获取环境变量,如果不存在则返回默认值
func GetOutboundIP ¶ added in v1.3.0
func GetOutboundIP() string
GetOutboundIP 获取对外通信的IP地址 如果已缓存有效IP,直接返回;否则尝试多个服务获取IP并缓存结果
func ResetIPCache ¶ added in v1.3.2
func ResetIPCache()
ResetIPCache 重置IP缓存,强制下次调用GetOutboundIP时重新获取
func SuccessFile ¶ added in v1.6.0
SuccessFile 发送文件下载响应
func SuccessHTML ¶ added in v1.6.0
SuccessHTML 发送 HTML 响应
Types ¶
type ResData ¶ added in v1.5.6
type ResData[T any] struct { Code int `json:"code"` Msg string `json:"msg"` Data T `json:"data,omitempty"` Time int64 `json:"time"` Sign string `json:"sign,omitempty"` // 响应签名 }
ResData 统一响应格式
type SystemInfo ¶ added in v1.3.0
type SystemInfo struct {
OS string `json:"os"`
Arch string `json:"arch"`
CPUCores int `json:"cpu_cores"`
GoVersion string `json:"go_version"`
Hostname string `json:"hostname"`
TempDir string `json:"temp_dir"`
HomeDir string `json:"home_dir"`
WorkingDir string `json:"working_dir"`
LocalIP string `json:"local_ip"`
OutboundIP string `json:"outbound_ip"`
ComputerName string `json:"computer_name"`
CPUId string `json:"cpu_id"`
BaseboardId string `json:"baseboard_id"`
MemoryId string `json:"memory_id"`
MachineCode string `json:"machine_code"`
HttpProxy string `json:"http_proxy"`
HttpsProxy string `json:"https_proxy"`
}
SystemInfo 系统信息
Click to show internal directories.
Click to hide internal directories.