Created
December 28, 2022 08:01
-
-
Save ismdeep/4d75f3303d255da3d68399babe72c941 to your computer and use it in GitHub Desktop.
golang load config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Config struct { | |
Server struct { | |
Bind string `config:"default:0.0.0.0:9000;env:CONFIG_SERVER_BIND"` | |
Mode string `config:"default:debug;env:CONFIG_SERVER_MODE"` | |
} | |
} | |
var Data Config | |
func Load(v interface{}) error { | |
// TODO | |
return nil | |
} | |
func main() { | |
if err := Load(&Data); err != nil { | |
panic(err) | |
} | |
} |
NekoTashi
commented
Dec 28, 2022
•
envconfig does this, might meet your needs
Thanks, that's awesome.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment