gluaenv

package module
v0.0.0-...-2888db6 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2016 License: MIT Imports: 5 Imported by: 6 modules, 6 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gluaenv

Utility package for manipulating environment variables for gopher-lua

Installation

go get github.com/kohkimakimoto/gluaenv

API

env.set(key, value)

Same os.setenv

env.get(key)

Same os.getenv

env.loadfile(file)

Loads environment variables from a file. The file is as the following:

AAA=BBB
CCC=DDD

If this function fails, it returns nil, plus a string describing the error.

Usage

package main

import (
    "github.com/yuin/gopher-lua"
    "github.com/kohkimakimoto/gluaenv"
)

func main() {
    L := lua.NewState()
    defer L.Close()

    L.PreloadModule("env", gluaenv.Loader)
    if err := L.DoString(`
local env = require("env")

-- set a environment variable
env.set("HOGE_KEY", "HOGE_VALUE")

-- get a environment variable
local v = env.get("HOGE_KEY")

-- load envrironment variables from a file.
env.loadfile("path/to/.env")

-- file example
-- AAA=BBB
-- CCC=DDD

`); err != nil {
        panic(err)
    }
}

Author

Kohki Makimoto kohki.makimoto@gmail.com

License

MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Loader

func Loader(L *lua.LState) int

Types

This section is empty.

Jump to

Keyboard shortcuts

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