mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
version: initialize go.mod version regex lazily
This commit is contained in:
parent
f2b77f0433
commit
b597f149b7
1 changed files with 1 additions and 3 deletions
|
|
@ -16,8 +16,6 @@ var VersionWithCommit = Version
|
|||
|
||||
var DefaultUserAgent = "mautrix-go/" + Version + " go/" + strings.TrimPrefix(runtime.Version(), "go")
|
||||
|
||||
var goModVersionRegex = regexp.MustCompile(`v.+\d{14}-([0-9a-f]{12})`)
|
||||
|
||||
func init() {
|
||||
if GoModVersion == "" {
|
||||
info, _ := debug.ReadBuildInfo()
|
||||
|
|
@ -31,7 +29,7 @@ func init() {
|
|||
}
|
||||
}
|
||||
if GoModVersion != "" {
|
||||
match := goModVersionRegex.FindStringSubmatch(GoModVersion)
|
||||
match := regexp.MustCompile(`v.+\d{14}-([0-9a-f]{12})`).FindStringSubmatch(GoModVersion)
|
||||
if match != nil {
|
||||
Commit = match[1]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue