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

settings

package
v0.1.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package settings defines every Flow-I setting, parses values, and resolves them across layers (built-in default → user → workspace → collection → folder → request → node → environment variable → flag).

It is the only package that reads process environment variables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Editor

func Editor(environ []string) string

Editor returns the user's editor command: $VISUAL, then $EDITOR, then a platform default.

func EnvVarName

func EnvVarName(key string) string

EnvVarName returns the environment variable that overrides a key.

func ParseRate

func ParseRate(s string) (time.Duration, error)

ParseRate reads a rate limit such as "20/s", "120/m" or "5/h" and returns the interval between two calls at that rate.

func ParseValue

func ParseValue(k Key, raw any) (any, error)

ParseValue converts a raw value from YAML (string, bool, int64, []any) or from an environment variable (always string) into the key's type: string, bool, int64, time.Duration or []string.

func ProcessEnviron

func ProcessEnviron() []string

ProcessEnviron returns the process environment. It is the module's only direct access to environment variables; callers pass the result down.

func ProxyConfig

func ProxyConfig(proxySetting string, environ []string) *httpproxy.Config

ProxyConfig decides which proxy outgoing requests use. A non-empty proxy.http setting is used for both HTTP and HTTPS. Otherwise the conventional HTTP_PROXY, HTTPS_PROXY and NO_PROXY variables (or their lower-case forms) are read from environ, so a machine's usual proxy setup works without Flow-I-specific configuration. NO_PROXY applies in both cases.

Types

type Key

type Key struct {
	Name        string
	Description string
	Kind        Kind
	Default     any
	Enum        []string
	Min, Max    int64 // KindInt bounds; Max 0 means unbounded
	FileLayers  []Layer
}

Key describes one setting. Env and flag layers may always set a key; FileLayers lists which file layers may.

func Lookup

func Lookup(schema []Key, name string) (Key, bool)

Lookup finds a key by name.

func Schema

func Schema() []Key

Schema returns every setting in display order.

type Kind

type Kind int

Kind is a setting's value type.

const (
	KindString Kind = iota + 1
	KindBool
	KindInt
	KindDuration
	KindEnum
	KindStringList
)

Kinds.

type Layer

type Layer int

Layer is where a value came from. Higher layers win.

const (
	LayerDefault Layer = iota
	LayerUser
	LayerWorkspace
	LayerCollection
	LayerFolder
	LayerRequest
	LayerNode
	LayerEnv
	LayerFlag
)

Layers in ascending precedence.

func (Layer) String

func (l Layer) String() string

type LayerValues

type LayerValues struct {
	Layer  Layer
	Source string
	Values model.Settings
}

LayerValues are the validated values one layer sets. Source names the file or variable they came from.

func FromBlock

func FromBlock(schema []Key, layer Layer, source string, raw map[string]any) (LayerValues, diag.List)

FromBlock validates a flattened settings block read from a file at the given layer. Unknown keys warn and are dropped; invalid values and keys not allowed at the layer are errors. Diagnostic paths point into the file: "$.<key>" for the user settings file, "$.settings.<key>" elsewhere.

func FromEnviron

func FromEnviron(schema []Key, environ []string) (LayerValues, diag.List)

FromEnviron reads FLOWI_* overrides from an environ slice ("K=V"). Unknown FLOWI_ variables warn, so typos do not pass silently.

type Paths

type Paths struct {
	ConfigDir string
}

Paths are the directories Flow-I keeps its own files in.

func DiscoverPaths

func DiscoverPaths(environ []string) (Paths, error)

DiscoverPaths returns FLOWI_CONFIG_DIR if set, otherwise os.UserConfigDir()/flowi.

type Resolved

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

Resolved holds every layer for lookup and explanation.

func Resolve

func Resolve(schema []Key, layers ...LayerValues) Resolved

Resolve combines layers; their order in the call does not matter. Built-in defaults are always the lowest layer.

func (Resolved) Explain

func (r Resolved) Explain(name string) []Value

Explain returns every layer that sets the key, highest first, ending with the built-in default.

func (Resolved) Get

func (r Resolved) Get(name string) (Value, bool)

Get returns the winning value of a setting.

type Value

type Value struct {
	Value  any
	Layer  Layer
	Source string
}

Value is a resolved setting and where it came from.

Jump to

Keyboard shortcuts

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