config

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package config manages Upbit CLI credentials stored in $HOME/.upbit/config.

Credential resolution priority:

  1. Environment variables: UPBIT_ACCESS_KEY, UPBIT_SECRET_KEY
  2. Config file: $HOME/.upbit/config (TOML, [default] section)
  3. Empty — callers decide how to handle absence

Config file format:

[default]
access_key = "..."
secret_key = "..."

The file is created/updated exclusively via Save, which enforces 0600 permissions and creates the parent directory (0700) if absent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Path

func Path() (string, error)

Path returns the absolute path to the config file ($HOME/.upbit/config).

func Save

func Save(c Credentials) error

Save writes credentials to $HOME/.upbit/config with 0600 permissions.

Types

type Credentials

type Credentials struct {
	AccessKey       string
	SecretKey       string
	AccessKeySource Source
	SecretKeySource Source
}

Credentials holds the access/secret key pair along with their load sources.

func Load

func Load() (Credentials, error)

Load reads credentials with priority: env > ~/.upbit/config > empty.

func LoadFile

func LoadFile() (Credentials, error)

LoadFile reads credentials from the config file only (no env lookup).

func LoadFrom

func LoadFrom(homeDir func() (string, error), getenv func(string) string) (Credentials, error)

LoadFrom is the testable version of Load. homeDir and getenv are injectable.

func (Credentials) IsEmpty

func (c Credentials) IsEmpty() bool

IsEmpty reports whether both keys are absent.

type Source

type Source int

Source indicates where a credential value was loaded from.

const (
	SourceNone Source = iota
	SourceEnv
	SourceFile
)

func (Source) String

func (s Source) String() string

Jump to

Keyboard shortcuts

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