-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.go
More file actions
29 lines (24 loc) · 642 Bytes
/
Copy pathmod.go
File metadata and controls
29 lines (24 loc) · 642 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// NOTE: debug.ReadBuildInfo() only works when it is being ran on main package AND it is not unit tests (see: https://github.com/golang/go/issues/33976)
package mod
import (
_ "embed"
"strings"
)
const Version = "0.0.1"
//go:embed go.mod
var moduleContent string
func mustGetModuleUrl() string {
lines := strings.Split(moduleContent, "\n")
for _, line := range lines {
lineStripped := strings.TrimSpace(line)
if lineStripped == "" {
continue
}
if strings.HasPrefix(line, "module") {
_, url, _ := strings.Cut(line, " ")
return url
}
}
panic("Couldn't find module URL")
}
var Url = "https://" + mustGetModuleUrl()