File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 5
5
require (
6
6
github.com/barelyhuman/go v0.2.2-0.20230713173609-2ee88bb52634
7
7
github.com/cjoudrey/gluahttp v0.0.0-20201111170219-25003d9adfa9
8
+ github.com/joho/godotenv v1.5.1
8
9
github.com/otiai10/copy v1.9.0
9
10
github.com/vadv/gopher-lua-libs v0.4.1
10
11
github.com/yuin/goldmark v1.5.4
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
41
41
github.com/google/go-cmp v0.4.0 /go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE =
42
42
github.com/google/gofuzz v1.0.0 /go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg =
43
43
github.com/jmespath/go-jmespath v0.3.0 /go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik =
44
+ github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0 =
45
+ github.com/joho/godotenv v1.5.1 /go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4 =
44
46
github.com/json-iterator/go v1.1.6 /go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU =
45
47
github.com/json-iterator/go v1.1.9 /go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4 =
46
48
github.com/julienschmidt/httprouter v1.2.0 /go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w =
Original file line number Diff line number Diff line change @@ -4,11 +4,13 @@ import (
4
4
"os"
5
5
"path"
6
6
7
+ dotenv "github.com/joho/godotenv"
7
8
lua "github.com/yuin/gopher-lua"
8
9
)
9
10
10
11
var api = map [string ]lua.LGFunction {
11
- "files" : GetFilesIndex ,
12
+ "files" : GetFilesIndex ,
13
+ "get_env" : GetEnv ,
12
14
}
13
15
14
16
// Preload adds json to the given Lua state's package.preload table. After it
@@ -81,3 +83,19 @@ func getFilesIndex(pathToIndex string) (paths []string, err error) {
81
83
82
84
return
83
85
}
86
+
87
+ func GetEnv (L * lua.LState ) int {
88
+ // path to get the env from
89
+ str := L .CheckString (1 )
90
+ // key to get from index
91
+ key := L .CheckString (2 )
92
+ value := LGetEnv (L , str , key )
93
+ L .Push (value )
94
+ return 1
95
+ }
96
+
97
+ func LGetEnv (L * lua.LState , fromFile string , str string ) lua.LString {
98
+ dotenv .Load (fromFile )
99
+ val := os .Getenv (str )
100
+ return lua .LString (val )
101
+ }
You can’t perform that action at this time.
0 commit comments