env

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 8 Imported by: 2

README

Noob-Env

Go Reference GitHub go.mod Go version (subdirectory of monorepo) GitHub release (latest by date)

Noob Env is a tools for working with .env, such as:

  • Load Env
  • Get Env

Noob Env use GoDotEnv v1.4.0 to load & parse .env. Thanks to godotenv**

Contents

Installation

To install this package, you need to install Go (version 1.17+ is required) & initiate your Go workspace first.

  1. After you initiate your workspace then you can install this package with below command.
go get -u github.com/alfarih31/nb-go-env
  1. Import it in your code
import "github.com/alfarih31/nb-go-env"

Quick Start & Usage

See the test:

Contributors

License

This project is licensed under the - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrorVarNotExist = NewEnvErr("variable not exist")

Functions

This section is empty.

Types

type ConfigServer added in v1.1.1

type ConfigServer interface {
	Get(key string) (string, bool)
	Dump() (string, error)
}

func NewDefaultConfigServer added in v1.1.1

func NewDefaultConfigServer(envPath string, fallbackToWide ...bool) (ConfigServer, error)

type Env

type Env interface {
	GetInt(k string, def ...int) (int, error)
	MustGetInt(k string, def ...int) int
	GetString(k string, def ...string) (string, error)
	MustGetString(k string, def ...string) string
	GetBool(k string, def ...bool) (bool, error)
	MustGetBool(k string, def ...bool) bool
	GetStringArr(k string, def ...[]string) ([]string, error)
	MustGetStringArr(k string, def ...[]string) []string
	GetIntArr(k string, def ...[]int) ([]int, error)
	MustGetIntArr(k string, def ...[]int) []int
	Dump() (string, error)
}

func LoadEnv

func LoadEnv(envPath string, fallbackToWide ...bool) (Env, error)

func LoadWithConfigServer added in v1.1.1

func LoadWithConfigServer(configServer ConfigServer) (Env, error)

type Err added in v1.0.2

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

func NewEnvErr added in v1.0.2

func NewEnvErr(s string) *Err

func (*Err) Error added in v1.0.2

func (e *Err) Error() string

func (*Err) Errorf added in v1.0.2

func (e *Err) Errorf(f string, s ...interface{}) *Err

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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