File tree Expand file tree Collapse file tree 2 files changed +5
-18
lines changed Expand file tree Collapse file tree 2 files changed +5
-18
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ configuration is provided, ocb will generate a default Collector.
123
123
124
124
func initConfig (flags * flag.FlagSet ) error {
125
125
cfg .Logger .Info ("OpenTelemetry Collector Builder" ,
126
- zap .String ("version" , version ), zap . String ( "date" , date ) )
126
+ zap .String ("version" , version ))
127
127
128
128
var provider koanf.Provider
129
129
Original file line number Diff line number Diff line change @@ -12,21 +12,12 @@ import (
12
12
13
13
var (
14
14
version = ""
15
- date = "unknown"
16
15
)
17
16
18
- // binVersion returns the version of the binary.
19
- // If the version is not set, it attempts to read the build information.
20
- // Returns an error if the build information cannot be read.
21
- func binVersion () (string , error ) {
22
- if version != "" {
23
- return version , nil
24
- }
25
- info , ok := debug .ReadBuildInfo ()
26
- if ! ok {
27
- return "" , fmt .Errorf ("failed to read build info" )
28
- }
29
- return info .Main .Version , nil
17
+ func init () {
18
+ // the second returned value is a boolean, which is true if the binaries are built with module support.
19
+ info , _ := debug .ReadBuildInfo ()
20
+ version = info .Main .Version
30
21
}
31
22
32
23
func versionCommand () * cobra.Command {
@@ -35,10 +26,6 @@ func versionCommand() *cobra.Command {
35
26
Short : "Version of ocb" ,
36
27
Long : "Prints the version of the ocb binary" ,
37
28
RunE : func (cmd * cobra.Command , _ []string ) error {
38
- version , err := binVersion ()
39
- if err != nil {
40
- return err
41
- }
42
29
cmd .Println (fmt .Sprintf ("%s version %s" , cmd .Parent ().Name (), version ))
43
30
return nil
44
31
},
You can’t perform that action at this time.
0 commit comments