version.go 356 B

1234567891011121314151617181920
  1. package sarama
  2. import "runtime/debug"
  3. var v string
  4. func version() string {
  5. if v == "" {
  6. bi, ok := debug.ReadBuildInfo()
  7. if ok {
  8. v = bi.Main.Version
  9. } else {
  10. // if we can't read a go module version then they're using a git
  11. // clone or vendored module so all we can do is report "dev" for
  12. // the version
  13. v = "dev"
  14. }
  15. }
  16. return v
  17. }