Require Go Modules to build (#902)

* Add module info to version

* Add warning if built without Go modules

* Updated source installation instructions for Go modules
This commit is contained in:
Patrick Gaskin 2020-10-10 10:34:04 -04:00 committed by GitHub
parent d27e9d3eb7
commit bc8bcf88c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -120,7 +120,7 @@ To install, simply run
To download the source
go get -d github.com/StackExchange/dnscontrol
git clone github.com/StackExchange/dnscontrol
If these don't work, more info is in [#805](https://github.com/StackExchange/dnscontrol/issues/805).

View file

@ -4,6 +4,7 @@ import (
"fmt"
"log"
"os"
"runtime/debug"
"strconv"
"time"
@ -15,6 +16,9 @@ import (
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
if info, ok := debug.ReadBuildInfo(); !ok && info == nil {
fmt.Fprint(os.Stderr, "Warning: dnscontrol was built without Go modules. See https://github.com/StackExchange/dnscontrol#from-source for more information on how to build dnscontrol correctly.\n\n")
}
os.Exit(commands.Run(versionString()))
}
@ -36,6 +40,9 @@ func versionString() string {
} else {
version = fmt.Sprintf("%s-dev", Version) // no SHA. '0.x.y-dev' indicates it is run from source without build script.
}
if info, ok := debug.ReadBuildInfo(); !ok && info == nil {
version += " (non-modules)"
}
if BuildTime != "" {
i, err := strconv.ParseInt(BuildTime, 10, 64)
if err == nil {