| Abhay Kumar | 40252eb | 2025-10-13 13:25:53 +0000 | [diff] [blame^] | 1 | package sarama |
| 2 | |
| 3 | import ( |
| 4 | "runtime/debug" |
| 5 | "sync" |
| 6 | ) |
| 7 | |
| 8 | var ( |
| 9 | v string |
| 10 | vOnce sync.Once |
| 11 | ) |
| 12 | |
| 13 | func version() string { |
| 14 | vOnce.Do(func() { |
| 15 | bi, ok := debug.ReadBuildInfo() |
| 16 | if ok { |
| 17 | v = bi.Main.Version |
| 18 | } |
| 19 | if v == "" || v == "(devel)" { |
| 20 | // if we can't read a go module version then they're using a git |
| 21 | // clone or vendored module so all we can do is report "dev" for |
| 22 | // the version to make a valid ApiVersions request |
| 23 | v = "dev" |
| 24 | } |
| 25 | }) |
| 26 | return v |
| 27 | } |