File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,11 @@ import (
8
8
cmd "github.com/aaabhilash97/aadhaar_scrapper_apis/internal/cmd/server"
9
9
)
10
10
11
- func init () {
11
+ var gitCommit , gitTag string
12
12
13
+ func init () {
14
+ os .Setenv ("VERSION_INFO_GIT_COMMIT" , gitCommit )
15
+ os .Setenv ("VERSION_INFO_GIT_TAG" , gitTag )
13
16
}
14
17
15
18
func main () {
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package appconfig
2
2
3
3
import (
4
4
"bytes"
5
+ "fmt"
5
6
"os"
6
7
7
8
"github.com/aaabhilash97/aadhaar_scrapper_apis/configs"
@@ -22,9 +23,21 @@ func Init() *Config {
22
23
23
24
var config Config
24
25
{
26
+ version := pflag .Bool ("version" , false , "Show version information" )
27
+
25
28
pflag .String ("conf" , "" , "config path" )
26
29
pflag .Parse ()
27
30
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
+
28
41
viperConfig := viper .New ()
29
42
viperConfig .AutomaticEnv ()
30
43
_ = viperConfig .BindPFlags (pflag .CommandLine )
You can’t perform that action at this time.
0 commit comments