Skip to content

Commit 8e08f50

Browse files
committed
minor changes in config
1 parent 2c893bc commit 8e08f50

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

cmd/server/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ import (
88
cmd "github.com/aaabhilash97/aadhaar_scrapper_apis/internal/cmd/server"
99
)
1010

11-
func init() {
11+
var gitCommit, gitTag string
1212

13+
func init() {
14+
os.Setenv("VERSION_INFO_GIT_COMMIT", gitCommit)
15+
os.Setenv("VERSION_INFO_GIT_TAG", gitTag)
1316
}
1417

1518
func main() {

internal/appconfig/appconfig.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package appconfig
22

33
import (
44
"bytes"
5+
"fmt"
56
"os"
67

78
"github.com/aaabhilash97/aadhaar_scrapper_apis/configs"
@@ -22,9 +23,21 @@ func Init() *Config {
2223

2324
var config Config
2425
{
26+
version := pflag.Bool("version", false, "Show version information")
27+
2528
pflag.String("conf", "", "config path")
2629
pflag.Parse()
2730

31+
if *version {
32+
msg := fmt.Sprintf(`Git Tag: %s
33+
Git commit: %s`,
34+
os.Getenv("VERSION_INFO_GIT_TAG"),
35+
os.Getenv("VERSION_INFO_GIT_COMMIT"))
36+
37+
fmt.Println(msg)
38+
os.Exit(0)
39+
}
40+
2841
viperConfig := viper.New()
2942
viperConfig.AutomaticEnv()
3043
_ = viperConfig.BindPFlags(pflag.CommandLine)

0 commit comments

Comments
 (0)