github.com/philhug/dnscontrol@v0.2.4-0.20180625181521-921fa9849001/main.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"log"
     6  	"os"
     7  	"strconv"
     8  	"time"
     9  
    10  	"github.com/StackExchange/dnscontrol/commands"
    11  	_ "github.com/StackExchange/dnscontrol/providers/_all"
    12  )
    13  
    14  //go:generate go run build/generate/generate.go build/generate/featureMatrix.go
    15  
    16  func main() {
    17  	log.SetFlags(log.LstdFlags | log.Lshortfile)
    18  	os.Exit(commands.Run(versionString()))
    19  }
    20  
    21  // Version management. 2 Goals:
    22  // 1. Someone who just does "go get" has at least some information.
    23  // 2. If built with build/build.go, more specific build information gets put in.
    24  // Update the number here manually each release, so at least we have a range for go-get people.
    25  var (
    26  	SHA       = ""
    27  	Version   = "0.2.6"
    28  	BuildTime = ""
    29  )
    30  
    31  // printVersion prints the version banner.
    32  func versionString() string {
    33  	var version string
    34  	if SHA != "" {
    35  		version = fmt.Sprintf("%s (%s)", Version, SHA)
    36  	} else {
    37  		version = fmt.Sprintf("%s-dev", Version) // no SHA. '0.x.y-dev' indicates it is run from source without build script.
    38  	}
    39  	if BuildTime != "" {
    40  		i, err := strconv.ParseInt(BuildTime, 10, 64)
    41  		if err == nil {
    42  			tm := time.Unix(i, 0)
    43  			version += fmt.Sprintf(" built %s", tm.Format(time.RFC822))
    44  		}
    45  	}
    46  	return fmt.Sprintf("dnscontrol %s", version)
    47  }