config

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package config loads + writes the CLI config at ~/.getdebug/config.json.

Index

Constants

This section is empty.

Variables

View Source
var ErrInsecurePerms = errors.New("config file has insecure permissions; run `chmod 600 ~/.getdebug/config.json`")

ErrInsecurePerms is returned when the config file exists but has group/other read bits set. The token in this file is a long-lived bearer credential — any local process running as another user could pick it up. Refuse to use it until the user re-secures the file.

Functions

func Path

func Path() (string, error)

Path returns the path to the on-disk config file (creating parent dirs if missing).

func Save

func Save(c *Config) error

Save writes the config atomically, mode 0600.

Types

type Config

type Config struct {
	APIBaseURL string `json:"apiBaseUrl,omitempty"`
	Token      string `json:"token,omitempty"`
	UserEmail  string `json:"userEmail,omitempty"`
}

Config holds the CLI's persistent state. Tokens live here; the user can delete the file to log out.

func Load

func Load() (*Config, error)

Load reads the config. Returns an empty Config (not an error) when the file doesn't exist — the caller decides whether that's a problem.

If the file exists with group/other bits set (and we're on a Unix-like OS where those bits mean what we think they mean), the load fails with ErrInsecurePerms — better a loud error than silently using a token any local process can scrape.

Jump to

Keyboard shortcuts

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