Skip to content

Commit b53f57d

Browse files
authored
[chore] delete code to set a version and date, as it it not used (#10715)
1 parent ea769c5 commit b53f57d

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

cmd/builder/internal/command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ configuration is provided, ocb will generate a default Collector.
123123

124124
func initConfig(flags *flag.FlagSet) error {
125125
cfg.Logger.Info("OpenTelemetry Collector Builder",
126-
zap.String("version", version), zap.String("date", date))
126+
zap.String("version", version))
127127

128128
var provider koanf.Provider
129129

cmd/builder/internal/version.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,12 @@ import (
1212

1313
var (
1414
version = ""
15-
date = "unknown"
1615
)
1716

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
3021
}
3122

3223
func versionCommand() *cobra.Command {
@@ -35,10 +26,6 @@ func versionCommand() *cobra.Command {
3526
Short: "Version of ocb",
3627
Long: "Prints the version of the ocb binary",
3728
RunE: func(cmd *cobra.Command, _ []string) error {
38-
version, err := binVersion()
39-
if err != nil {
40-
return err
41-
}
4229
cmd.Println(fmt.Sprintf("%s version %s", cmd.Parent().Name(), version))
4330
return nil
4431
},

0 commit comments

Comments
 (0)