Help us shape the future of Go! Take the 2026 Go Developer Survey

userconfig

package
v7.6.230 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package userconfig provides a simple way to manage client configuration. It reads and writes configuration to disk and provides a way to listen for changes.

Index

Constants

View Source
const (
	DefaultConfigSaveDir  = ""
	DefaultConfigFilename = "user.conf"
)

Variables

This section is empty.

Functions

func OnConfigChange

func OnConfigChange(fn func(old, new *UserConfig))

OnConfigChange registers a function to be called on config change. This allows callers to respond to each change without having to constantly poll for changes.

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func Init

func Init(saveDir string, readable bool) (*Config, error)

func (*Config) GetConfig

func (c *Config) GetConfig() *UserConfig

GetConfig implements services.ConfigHandler

func (*Config) SetConfig

func (c *Config) SetConfig(new *UserConfig)

SetConfig implements services.ConfigHandler

type UserConfig

type UserConfig = apipb.ConfigResponse

alias for better readability. Using "UserConfig" since "Config" and "ClientConfig" is already taken. This may change in the future if they become available.

func GetConfig

func GetConfig(ctx context.Context) (*UserConfig, error)

GetConfig returns the current client config. An error is returned if the config is not available within the given timeout.

Jump to

Keyboard shortcuts

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