MCPcopy
hub / github.com/tinyauthapp/tinyauth / generateExampleEnv

Function generateExampleEnv

gen/gen_env.go:22–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20}
21
22func generateExampleEnv() {
23 cfg := config.NewDefaultConfiguration()
24 entries := make([]EnvEntry, 0)
25
26 root := reflect.TypeOf(cfg).Elem()
27 rootValue := reflect.ValueOf(cfg).Elem()
28 rootPath := "TINYAUTH_"
29
30 walkAndBuild(root, rootValue, rootPath, &entries, buildEnvEntry, buildEnvMapEntry, buildEnvChildPath)
31 compiled := compileEnv(entries)
32
33 err := os.Remove(".env.example")
34 if err != nil && !errors.Is(err, fs.ErrNotExist) {
35 slog.Error("failed to remove example env file", "error", err)
36 os.Exit(1)
37 }
38
39 err = os.WriteFile(".env.example", compiled, 0644)
40 if err != nil {
41 slog.Error("failed to write example env file", "error", err)
42 os.Exit(1)
43 }
44}
45
46func buildEnvEntry(child reflect.StructField, childValue reflect.Value, parentPath string, entries *[]EnvEntry) {
47 desc := child.Tag.Get("description")

Callers 1

mainFunction · 0.85

Calls 3

NewDefaultConfigurationFunction · 0.92
walkAndBuildFunction · 0.85
compileEnvFunction · 0.85

Tested by

no test coverage detected