env

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cfg

func Cfg() *gcfg.Config

GetCfg 获取配置信息

func GetIP

func GetIP() string

GetIP 获取IP地址

func GetOS

func GetOS() string

GetOS 获取操作系统

func GetResourcesDir

func GetResourcesDir() string

GetResourcesDir 获取资源目录

func GetRootDir

func GetRootDir() string

GetRootDir 获取根目录

func GetServerMode

func GetServerMode() string

GetServerMode 获取服务器模式

func GetServerName

func GetServerName() string

GetServerName 获取服务器名称

func GetServerType

func GetServerType() string

GetServerType 获取服务器类型

func GetServerVersion

func GetServerVersion() string

GetServerVersion 获取服务器版本

func Init

func Init(e *Env)

Init

func IsDebug

func IsDebug() bool

IsDebug 是否调试模式

func IsLinux

func IsLinux() bool

IsLinux 是否Linux系统

func IsMac

func IsMac() bool

IsMac 是否Mac系统

func IsNormal

func IsNormal() bool

IsNormal 是否正常模式

func IsRelease

func IsRelease() bool

IsRelease 是否正式模式

func IsUnknown

func IsUnknown() bool

IsUnknown 是否未知系统

func IsWin

func IsWin() bool

IsWin 是否Windows系统

func Port

func Port() int

GetPort 获取端口

Types

type Config

type Config struct {
	Server string `json:"server"`
	Log    string `json:"log"`
	Var    string `json:"var"`
}

type Env

type Env struct {
	Version       string
	ServerName    string `json:"server_name"`
	ServerVersion string `json:"server_version"`
	Mode          string `json:"mode"`
	OS            string
	Port          int    `json:"port"`
	IP            string `json:"ip"`
	Address       string
	Arch          string
	SystemVersion string
	CPU           int
	PID           int
	Hostname      string
	RootDir       string `json:"root_dir"`
	ResourcesDir  string `json:"resources_dir"`
	ServerType    string `json:"server_type"`
	Cfg           *gcfg.Config
	Var           map[string]any
}

环境

func Instance

func Instance() *Env

Instance 用于懒加载环境信息

type LogConfig

type LogConfig struct {
	Path                string   `json:"path"`
	File                string   `json:"file"`
	Prefix              string   `json:"prefix"`
	Level               string   `json:"level"`
	TimeFormat          string   `json:"time_format"`
	CtxKeys             []string `json:"ctx_keys"`
	Header              bool     `json:"header"`
	Stdout              bool     `json:"stdout"`
	StdoutColorDisabled bool     `json:"stdout_color_disabled"`
	WriterColorEnable   bool     `json:"writer_color_enable"`
}

type Var

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

func GetVar

func GetVar(key string, def ...any) *Var

func (*Var) Any

func (v *Var) Any() any

func (*Var) Bool

func (v *Var) Bool() bool

func (*Var) Float32

func (v *Var) Float32() float32

func (*Var) Float64

func (v *Var) Float64() float64

func (*Var) Int

func (v *Var) Int() int

func (*Var) Int64

func (v *Var) Int64() int64

func (*Var) IsNil

func (v *Var) IsNil() bool

func (*Var) Map

func (v *Var) Map() map[string]any

func (*Var) MapStrStr

func (v *Var) MapStrStr() map[string]string

func (*Var) String

func (v *Var) String() string

Jump to

Keyboard shortcuts

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