Documentation
¶
Overview ¶
Package env loads environment variable files:
http-client.env.json {"dev": {"baseUrl": "..."}, "$shared": {...}}
http-client.private.env.json same shape, for secrets, gitignored
.env KEY=value lines
These are the conventions used by JetBrains HTTP Client, kulala.nvim and httpyac, so one set of files serves every tool.
Index ¶
Constants ¶
const ( PublicFile = "http-client.env.json" PrivateFile = "http-client.private.env.json" DotEnvFile = ".env" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Environments ¶
type Environments struct {
Public map[string]map[string]string // env name -> vars
Private map[string]map[string]string
DotEnv map[string]string
Found []string // files that were present
}
Environments is everything loaded from the env files of a project.
func Load ¶
func Load(root string) (*Environments, error)
Load reads the env files in root. Missing files are fine.
func (*Environments) Has ¶
func (e *Environments) Has(name string) bool
Has reports whether an environment is declared in either JSON file.
func (*Environments) Names ¶
func (e *Environments) Names() []string
Names returns the environment names found in the JSON files, sorted.
func (*Environments) PrivateVars ¶
func (e *Environments) PrivateVars(env string) map[string]string
PrivateVars returns the private vars for env merged over $shared.
func (*Environments) PublicVars ¶
func (e *Environments) PublicVars(env string) map[string]string
PublicVars returns the public vars for env merged over $shared.