config

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNTPAllowedDifference         = 50000000
	DefaultNTPAllowedNegativeDifference = 50000000
	DefaultFileMode                     = os.FileMode(0755)
)

Variables

This section is empty.

Functions

func Example

func Example()

Example quick start example for a common use case of this module.

func ExampleLocalCache

func ExampleLocalCache()

ExampleLocalCache example for getting a user-specific cache folder.

func ExampleLocalConfig

func ExampleLocalConfig()

ExampleLocalConfig example for getting a user-specific configuration path.

func ExampleMakePath

func ExampleMakePath()

ExampleMakePath example for automatically creating config directories.

func ExampleRefresh

func ExampleRefresh()

ExampleRefresh example for recalculating what the directories should be.

func ExampleSystemConfig

func ExampleSystemConfig()

ExampleSystemConfig example for getting a global system configuration path.

func LocalCache

func LocalCache(folder ...string) string

LocalCache returns the local user cache folder, with optional path components added to the end for vendor/application-specific settings.

func LocalConfig

func LocalConfig(folder ...string) string

LocalConfig returns the local user configuration path, with optional path components added to the end for vendor/application-specific settings.

func Refresh

func Refresh()

Refresh will rediscover the config paths, checking current environment variables again.

This function is automatically called when the program initializes. If you change the environment variables at run-time, though, you may call the Refresh() function to reevaluate the config paths.

func SystemConfig

func SystemConfig(folder ...string) []string

SystemConfig returns the system-wide configuration paths, with optional path components added to the end for vendor/application-specific settings.

Types

type Config

type Config struct {
	ConfigDir       string
	GoMaxProcessors int
	Logger          *log.Config
	Database        *database.Config
	Webserver       *webserver.Config
}

func NewConfig

func NewConfig() (*Config, error)

NewConfig will create the Config object and set the default data paths for the application.

func (*Config) CheckConfig

func (c *Config) CheckConfig() error

CheckConfig will run private functions to verify the system config, and all subsystem configs are valid

func (*Config) GetDataPath

func (c *Config) GetDataPath(elem ...string) string

GetDataPath gets the data path for the given sub-path

func (*Config) SaveConfig

func (c *Config) SaveConfig() error

func (*Config) SetupDefaultConfig

func (c *Config) SetupDefaultConfig(configDir string)

Jump to

Keyboard shortcuts

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