feat: vendor, makefiles, build settings
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"database/sql"
|
||||
"expvar"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strings"
|
||||
@@ -23,6 +24,10 @@ import (
|
||||
// number as a hard-coded global constant.
|
||||
const version = "1.0.0"
|
||||
|
||||
// Create a buildTime variable to hold the executable binary build time. Note that this
|
||||
// must be a string type, as the -X linker flag will only work with string variables.
|
||||
var buildTime string
|
||||
|
||||
// Define a config struct to hold all the configuration settings for our application.
|
||||
// For now, the only configuration settings will be the network port that we want the
|
||||
// server to listen on, and the name of the current operating environment for the
|
||||
@@ -120,8 +125,20 @@ func main() {
|
||||
return nil
|
||||
})
|
||||
|
||||
// Create a new version boolean flag with the default value of false.
|
||||
displayVersion := flag.Bool("version", false, "Display version and exit")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
// If the version flag value is true, then print out the version number and
|
||||
// immediately exit.
|
||||
if *displayVersion {
|
||||
fmt.Printf("Version:\t%s\n", version)
|
||||
// Print out the contents of the buildTime variable.
|
||||
fmt.Printf("Build time:\t%s\n", buildTime)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// Call the openDB() helper function (see below) to create the connection pool,
|
||||
// passing in the config struct. If this returns an error, we log it and exit the
|
||||
// application immediately.
|
||||
|
||||
Reference in New Issue
Block a user