config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxConcurrentDownloads = 10
)

Variables

View Source
var (
	ErrNoConfig = errors.New("config must be loaded")
)

Functions

func GetDir

func GetDir() (string, error)

GetDir returns the user config directory path, if not exists, it creates it.

func Save

func Save(c Config) error

Save saves the configuration to the user's config file.

Types

type Config

type Config struct {
	Personal PersonalConfig `toml:"personal"`
	Share    ShareConfig    `toml:"share"`
	Receive  ReceiveConfig  `toml:"receive"`
}

func Get

func Get() (Config, error)

Get returns the lastest loaded/saved user's config, if it returns ErrNoConfig, Load OR Save must be called.

func Load

func Load() (Config, error)

Load loads the configuration from the user's config file. if not exists, it creates a new config file with default values.

type PersonalConfig

type PersonalConfig struct {
	Username string `toml:"username"`
}

type ReceiveConfig

type ReceiveConfig struct {
	DownloadFolder      string `toml:"download_folder"`
	ConcurrentDownloads int    `toml:"concurrent_downloads"`
}

type ShareConfig

type ShareConfig struct {
	InstanceName      string `toml:"instance_name"`
	StoppableInstance bool   `toml:"stoppable_instance"`
	ZipFiles          bool   `toml:"zip_files"`
	Compression       bool   `toml:"compression"`
	SharedZipName     string `toml:"shared_zip_name"`
}

Jump to

Keyboard shortcuts

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