-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathENVUtils.go
More file actions
42 lines (36 loc) · 824 Bytes
/
ENVUtils.go
File metadata and controls
42 lines (36 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"encoding/json"
"fmt"
"net/http"
"os"
)
const ENVFilePath string = "./"
const ENVFileName string = ".env.json"
var ENV ENVStruct
type ENVStruct struct {
AWS struct {
Credentials struct {
AccessKeyId string `json:"ACCESS_KEY_ID"`
SecretKey string `json:"SECRET_ACCESS_KEY"`
}
S3 struct {
BucketName string `json:"BUCKET_NAME"`
Region string `json:"REGION"`
}
}
SetupPackageBasePath string `json:"SETUP_PACKAGE_BASE_PATH"`
}
func loadENVs(filePath, fileName string) bool {
ENVFile, err := os.Open(filePath + fileName)
defer ENVFile.Close()
if err != nil {
return false
}
jsonParser := json.NewDecoder(ENVFile)
_ = jsonParser.Decode(&ENV)
return true
}
func homeLink(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintf(w, "Welcome home!")
}