env

package
v0.0.0-...-b173b6e Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2018 License: MIT Imports: 6 Imported by: 0

README

Componenta / env

Установка переменных окружения из файла.

# Настройки приложения
APP_HOME = "/var/app"
APP_HOST = "localhost"
APP_PORT = "1448"
APP_URL  = "http://${APP_HOST}:${APP_PORT}" # http://localhost:1448
package main

import (
    "fmt"
    "os"
    "github.com/AlexanderGrom/componenta/env"
)

func main() {
    env.Load("${HOME}/.env")

    fmt.Println(os.Getenv("APP_HOME"))
    fmt.Println(os.Getenv("APP_HOST"))
    fmt.Println(os.Getenv("APP_PORT"))
    fmt.Println(os.Getenv("APP_URL"))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPathEmpty    = errors.New("env: path empty")
	ErrFileDontRead = errors.New("env: file don`t read")
)

Ошибки

View Source
var (
	ErrParseKey   = errors.New("env: parse error (key)")
	ErrParseQuote = errors.New("env: parse error (quote)")
)

Ошибки

Functions

func Load

func Load(path string) error

Загрузка файла в системные пременные

func NewParser

func NewParser() *parser

Конструктор

Types

type Env

type Env map[string]string

Jump to

Keyboard shortcuts

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