Files
telemetry/cmd/builder/internal/version.go
Matthieu MORELandGitHub 808fb7c260 [chore]: enable gofumpt linter in client, cmd, component, config and confmap (#11587)
#### Description

[gofumpt](https://golangci-lint.run/usage/linters/#gofumpt) is a
stricter format than gofmt, while being backwards compatible.

Signed-off-by: Matthieu MOREL <[email protected]>
2024-12-11 08:50:57 +00:00

37 lines
783 B
Go

// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package internal // import "go.opentelemetry.io/collector/cmd/builder/internal"
import (
"fmt"
"runtime/debug"
"github.com/spf13/cobra"
)
var version = ""
func init() {
// the second returned value is a boolean, which is true if the binaries are built with module support.
if version != "" {
return
}
info, ok := debug.ReadBuildInfo()
if ok {
version = info.Main.Version
}
}
func versionCommand() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Version of ocb",
Long: "Prints the version of the ocb binary",
RunE: func(cmd *cobra.Command, _ []string) error {
cmd.Println(fmt.Sprintf("%s version %s", cmd.Parent().Name(), version))
return nil
},
}
}