conf

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package conf implements the configuration of the application. The configuration is loaded from the configuration file. The configuration file is a TOML file. TODO(@yeqown): store configuration in the database instead of the file, and then we can use CLI application to manage and checkout these configurations.

Example (Save)

Index

Examples

Constants

View Source
const (
	DefaultScopes       = "api read_user read_repository"
	DefaultCallbackHost = "localhost:2333"
)

Variables

This section is empty.

Functions

func Default

func Default() *types.Config

Default get default config which is embedded in the source file, so that this program could run without any configuration file.

func DefaultCWD added in v1.6.2

func DefaultCWD() string

DefaultCWD returns the working directory of current project, default cwd is from git rev-parse --show-toplevel command, but if the command could not execute successfully, `pwd` command will be used instead.

func DefaultConfPath

func DefaultConfPath() string

func Load

func Load(confPath string, parser Parser) (cfg *types.Config, err error)

Load to load config from confPath with specified parser.

func Save

func Save(confPath string, cfg *types.Config, _ Parser) error

Save to save config with specified parser.

Types

type Parser added in v1.8.0

type Parser interface {
	// Unmarshal ...
	Unmarshal(r io.Reader, rcv *types.Config) error

	// Marshal ...
	Marshal(cfg *types.Config) ([]byte, error)
}

Parser is an interface to parse config in different ways. For example: JSON, TOML and YAML;

func NewTOMLParser

func NewTOMLParser() Parser

Jump to

Keyboard shortcuts

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