envutil

package
v0.85.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: BSD-3-Clause Imports: 2 Imported by: 0

README

kit/envutil

github.com/vormadev/vorma/kit/envutil

Small helpers for reading environment variables with defaults.

Import

import "github.com/vormadev/vorma/kit/envutil"

Quick Start

port := envutil.GetInt("PORT", 8080)
debug := envutil.GetBool("DEBUG", false)
service := envutil.GetStr("SERVICE_NAME", "api")

Behavior

  • If a variable is unset, the default is returned.
  • If parse fails (GetInt/GetBool), the default is returned.
  • No function returns an error.

Parsing details:

  • GetInt uses strconv.Atoi.
  • GetBool uses strconv.ParseBool (1/0, t/f, true/false, case-insensitive).

When Not To Use

Do not use this package for strict config validation flows where invalid values must fail startup loudly.
In those cases, parse explicitly and return/report errors.

API Reference

  • func GetStr(key string, defaultValue string) string
  • func GetInt(key string, defaultValue int) int
  • func GetBool(key string, defaultValue bool) bool

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBool

func GetBool(key string, defaultValue bool) bool

func GetInt

func GetInt(key string, defaultValue int) int

func GetStr

func GetStr(key string, defaultValue string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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