conf

package
v0.0.0-...-5443325 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

尽量减少 conf 的配置参数侵入到其他包中 conf 包只限于 cmd 包下使用

Index

Constants

View Source
const (

	// 设置默认文件系统权限
	Permissions = fs.FileMode(0755)

	// DefaultConfigJSON configure json string
	DefaultConfigJSON = `` /* 323-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func HasCustom

func HasCustom(path string) bool

HasCustom checked enable custom config

func Load

func Load(file string, opt *ServerConfig) error

Load through a configuration file

Types

type Compressor

type Compressor struct {
	Enable  bool   `json:"enable"`
	Mode    string `json:"mode"`
	Hotspot int64  `json:"hotspot"`
	Second  int64  `json:"second"`
}

type Encoder

type Encoder struct {
	Enable bool   `json:"enable"`
	Secret string `json:"secret"`
}

type ServerConfig

type ServerConfig struct {
	Port       int        `json:"port"`
	Path       string     `json:"path"`
	Mode       string     `json:"mode"`
	Debug      bool       `json:"debug"`
	FileSize   int64      `json:"filesize"`
	LogPath    string     `json:"log"`
	Password   string     `json:"auth"`
	Encoder    Encoder    `json:"encoder"`
	Compressor Compressor `json:"compressor"`
}
var (
	// Settings global configure options
	Settings *ServerConfig = new(ServerConfig)
	// DefaultConfig is the default configuration
	DefaultConfig *ServerConfig = new(ServerConfig)
)

func (*ServerConfig) Marshal

func (opt *ServerConfig) Marshal() ([]byte, error)

func (*ServerConfig) Saved

func (opt *ServerConfig) Saved() error

Saved Settings.Path 存储到配置好的目录中

func (*ServerConfig) SavedAs

func (opt *ServerConfig) SavedAs(path string) error

SavedAs Settings.Path 存储到磁盘文件中

func (*ServerConfig) String

func (opt *ServerConfig) String() string

func (*ServerConfig) Unmarshal

func (opt *ServerConfig) Unmarshal(data []byte) error

Jump to

Keyboard shortcuts

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