Browse Source

Add code comments

Volodymyr Tkach 2 years ago
parent
commit
6256266480
1 changed files with 15 additions and 0 deletions
  1. 15 0
      utils/penv/penv.go

+ 15 - 0
utils/penv/penv.go

@@ -110,6 +110,21 @@ func DumpConfig(config any) map[string]DumpVar {
 	return res
 	return res
 }
 }
 
 
+// ProcessConfig automaticaly read flags and ENVs to structure.
+//
+// config - must be a pointer to structure
+//
+//	var Config struct {
+//	  Deployment string `default:"development"`
+//	  Host       string `default:"127.0.0.1"`
+//	  Port       string `default:"8080"`
+//	}
+//
+//	func init() {
+//	  if err := penv.ProcessConfig(&Config); err != nil {
+//	    panic(err)
+//	  }
+//	}
 func ProcessConfig(config any) error {
 func ProcessConfig(config any) error {
 	v := reflect.ValueOf(config).Elem()
 	v := reflect.ValueOf(config).Elem()
 	t := v.Type()
 	t := v.Type()