forked from jadudm/cgov-util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
41 lines (35 loc) · 1.06 KB
/
main.go
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
/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package main
import (
"os"
"golang.org/x/exp/slices"
"gov.gsa.fac.cgov-util/cmd"
"gov.gsa.fac.cgov-util/internal/util"
"gov.gsa.fac.cgov-util/internal/vcap"
)
// Useful documentation for people new to Go, and
// related to modules in this command.
// https://www.digitalocean.com/community/tutorials/how-to-use-the-cobra-package-in-go
// https://github.com/tidwall/gjson
// https://martengartner.medium.com/my-favourite-go-project-setup-479563662834
// https://github.com/spf13/cobra
// https://github.com/spf13/viper
// https://go.dev/doc/tutorial/handle-errors
// Looks for config.yaml in the same directory as the app.
// Optionally, the config can be in `$HOME/.fac/config.yaml`
func readConfig() {
// Do the right thing in the right env.
if slices.Contains([]string{"LOCAL", "TESTING"}, os.Getenv("ENV")) {
// Locally, load the file from one of two places.
vcap.ReadVCAPConfigFile("config.json")
} else {
vcap.ReadVCAPConfig()
}
}
func main() {
readConfig()
util.SetPaths(os.Getenv("ENV"))
cmd.Execute()
}