global

package
v0.0.56 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ERROR_BASE_PATH = 10011
	ErrorBasePath   = "无法获取根路径"
)

Variables

View Source
var (
	BasePath string // 定义项目的根目录

	Debug bool = false

	Swagger bool = true

	EnableRegister bool = false

	EventDestroyPrefix = "Destroy_" //  程序退出时需要销毁的事件前缀
	ConfigKeyPrefix    = "Config_"  //  配置文件键值缓存时,键的前缀

	DateFormat = "2006-01-02 15:04:05" //  配置文件键值缓存时,键的前缀

	//gorm 数据库客户端,如果您操作数据库使用的是gorm,请取消以下注释,在 bootstrap>init 文件,进行初始化即可使用
	DB *gorm.DB // 全局gorm的客户端连接

	//gin engine
	Engine *gin.Engine

	//websocket
	WebsocketHub interface{}

	//casbin 全局操作指针
	Enforcer *casbin.SyncedEnforcer

	// CORS
	Cors *CORS = &CORS{
		Mode: "allow-all",
	}
)

Functions

func DurationVar

func DurationVar(name string) time.Duration

func DurationVarDefault

func DurationVarDefault(name string, v interface{}) time.Duration

func Int64Var

func Int64Var(name string) int64

func Int64VarDefault

func Int64VarDefault(name string, v int64) int64

func IntVar

func IntVar(name string) int

func IntVarDefault

func IntVarDefault(name string, v int) int

func Set

func Set(name string, value interface{})

func Sets

func Sets(vars map[string]interface{})

func StringVar

func StringVar(name string) string

func StringVarDefault

func StringVarDefault(name string, v string) string

func Var

func Var(name string) interface{}

func VarValue

func VarValue[T any](name string, t T) T

Types

type CORS

type CORS struct {
	Mode      string          `mapstructure:"mode" json:"mode" yaml:"mode"`
	Whitelist []CORSWhitelist `mapstructure:"whitelist" json:"whitelist" yaml:"whitelist"`
}

type CORSWhitelist

type CORSWhitelist struct {
	AllowOrigin      string `mapstructure:"allow-origin" json:"allow-origin" yaml:"allow-origin"`
	AllowMethods     string `mapstructure:"allow-methods" json:"allow-methods" yaml:"allow-methods"`
	AllowHeaders     string `mapstructure:"allow-headers" json:"allow-headers" yaml:"allow-headers"`
	ExposeHeaders    string `mapstructure:"expose-headers" json:"expose-headers" yaml:"expose-headers"`
	AllowCredentials bool   `mapstructure:"allow-credentials" json:"allow-credentials" yaml:"allow-credentials"`
}

Jump to

Keyboard shortcuts

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