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

config

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package config manages profiles stored under the XDG config directory. Credentials are stored separately (see pkg/auth) and never here.

Index

Constants

View Source
const DefaultAPIURL = "https://accounts.icarus.tools"

DefaultAPIURL is the production Oku account API origin. It applies only to fresh profiles created without --api-url and to profile-less commands; existing profiles keep the api_url they stored. --api-url accepts a custom origin.

View Source
const NetworkMainnet = "mainnet"

NetworkMainnet is the only network the Oku backend currently serves (account/src/connectapi/perps/signing.go hardcodes Hyperliquid Mainnet).

Variables

View Source
var ErrLocked = errors.New("lock held by another process")

ErrLocked reports that TryLockPath found the lock held by another process.

Functions

func Dir

func Dir() (string, error)

Dir returns the oku config directory.

func LockPath

func LockPath(path string) (func(), error)

LockPath takes an exclusive, blocking, cross-process lock on path, creating it with mode 0600. The returned function releases it. It uses flock on Unix and LockFileEx on Windows; both are released automatically if the process dies.

func NormalizeAPIURL

func NormalizeAPIURL(raw string) string

NormalizeAPIURL strips a trailing slash.

func Path

func Path() (string, error)

Path returns the config file path.

func StateDir

func StateDir() (string, error)

StateDir returns the oku state directory (journal, nonce state).

func TryLockPath

func TryLockPath(path string) (func(), error)

TryLockPath is LockPath without waiting: it returns ErrLocked when another process holds the lock.

func ValidAddress

func ValidAddress(a string) bool

ValidAddress reports whether a is a 20-byte hex address.

func ValidName

func ValidName(n string) bool

ValidName reports whether n is a valid profile name.

func ValidateAPIURL

func ValidateAPIURL(raw string) error

ValidateAPIURL requires https (http allowed only for loopback testing).

func WriteFileAtomic

func WriteFileAtomic(path string, data []byte, perm os.FileMode) error

WriteFileAtomic writes via a temp file and rename.

Types

type AutoUpdate

type AutoUpdate struct {
	Enabled bool `json:"enabled"`
	// Interval is the minimum time between background checks, as a Go
	// duration string. Empty means the default (24h).
	Interval string `json:"interval,omitempty"`
	// Skills also refreshes installed bundled skills after an update.
	Skills bool `json:"skills"`
}

AutoUpdate holds the opt-in background update preference.

type File

type File struct {
	Version        int                 `json:"version"`
	DefaultProfile string              `json:"default_profile,omitempty"`
	Profiles       map[string]*Profile `json:"profiles"`
	// Telemetry is global (not per profile) and off unless explicitly enabled.
	Telemetry *Telemetry `json:"telemetry,omitempty"`
	// AutoUpdate is global and off unless explicitly enabled.
	AutoUpdate *AutoUpdate `json:"auto_update,omitempty"`
}

File is the persisted config document.

func Load

func Load() (*File, error)

Load reads the config, returning an empty document if absent.

func (*File) Names

func (f *File) Names() []string

Names returns sorted profile names.

func (*File) Save

func (f *File) Save() error

Save writes the config atomically with 0600 permissions.

type Profile

type Profile struct {
	PrivyAppID string `json:"privy_app_id,omitempty"`
	Network    string `json:"network"`
	APIURL     string `json:"api_url"`
	Account    string `json:"account,omitempty"`
	// CredentialStore records where the profile's credential lives on Linux:
	// "file" (default, plain 0600 file) or "keyring" (Secret Service).
	CredentialStore string `json:"credential_store,omitempty"`
}

Profile selects an account, network, and API origin.

func (*Profile) Validate

func (p *Profile) Validate() error

Validate checks a profile.

type Telemetry

type Telemetry struct {
	Enabled bool `json:"enabled"`
	// HintShown records that the one-time login hint was printed.
	HintShown bool `json:"hint_shown,omitempty"`
}

Telemetry holds the opt-in usage telemetry preference.

Jump to

Keyboard shortcuts

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