config

package
v0.0.0-...-76ae43c Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

View Source
const (
	// EnvConfigDir 配置路径环境变量
	EnvConfigDir = "GEEKTIME_GO_CONFIG_DIR"
	// ConfigName 配置文件名
	ConfigName = "config.json"
)

Variables

View Source
var (
	//ErrNotLogin 未登录帐号错误
	ErrNotLogin = errors.New("请先登录极客时间账户")
	//ErrHasLoginedNotLogin 有登录用户,但是当前并未有有效用户
	ErrHasLoginedNotLogin = errors.New("存在登录的用户,可以进行切换登录用户")
	//ErrConfigFilePathNotSet 未设置配置文件
	ErrConfigFilePathNotSet = errors.New("config file not set")
	//ErrConfigFileNotExist 未设置Config, 未初始化
	ErrConfigFileNotExist = errors.New("config file not exist")
	//ErrConfigFileNoPermission Config文件无权限访问
	ErrConfigFileNoPermission = errors.New("config file permission denied")
	//ErrConfigContentsParseError 解析Config数据错误
	ErrConfigContentsParseError = errors.New("config contents parse error")
)
View Source
var (

	//Instance 配置信息 全局调用
	Instance = NewConfig(configFilePath)
)

Functions

func GetConfigDir

func GetConfigDir() string

GetConfigDir 配置文件夹

Types

type ConfigsData

type ConfigsData struct {
	AcitveUID    int
	Geektimes    Geektimes
	DownloadPath string
	// contains filtered or unexported fields
}

ConfigsData 配置数据

func NewConfig

func NewConfig(configFilePath string) *ConfigsData

NewConfig new config

func (*ConfigsData) ActiveUser

func (c *ConfigsData) ActiveUser() *Geektime

ActiveUser active user

func (*ConfigsData) ActiveUserService

func (c *ConfigsData) ActiveUserService() *service.Service

ActiveUserService user service

func (*ConfigsData) DeleteUser

func (c *ConfigsData) DeleteUser(u *User)

DeleteUser delete

func (*ConfigsData) Init

func (c *ConfigsData) Init() error

Init 初始化配置

func (*ConfigsData) LoginUserCount

func (c *ConfigsData) LoginUserCount() int

LoginUserCount 登录用户数量

func (*ConfigsData) Save

func (c *ConfigsData) Save() error

Save 保存配置

func (*ConfigsData) SetUserByGcidAndGcess

func (c *ConfigsData) SetUserByGcidAndGcess(gcid, gcess, serverID string) (*Geektime, error)

SetUserByGcidAndGcess set user

func (*ConfigsData) SwitchUser

func (c *ConfigsData) SwitchUser(u *User) error

SwitchUser switch user

type Geektime

type Geektime struct {
	User
	GCID         string `json:"gcid"`
	GCESS        string `json:"gcess"`
	ServerID     string `json:"serverId"`
	Ticket       string `json:"ticket"`
	CookieString string `json:"cookieString"`
}

Geektime geek time info

func (*Geektime) Service

func (g *Geektime) Service() *service.Service

Service geek time service

type Geektimes

type Geektimes []*Geektime

Geektimes 极客时间用户

type User

type User struct {
	ID     int    `json:"id"`
	Name   string `json:"name"`
	Avatar string `json:"avatar"`
}

User geek time user info

Jump to

Keyboard shortcuts

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