aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Hanley <felix@userspace.com.au>2020-02-21 11:17:58 +0000
committerFelix Hanley <felix@userspace.com.au>2020-02-21 11:17:58 +0000
commitefe829cec040e7d6157a26bbc4096d6078171f44 (patch)
tree9096ecc3d6777dc2d07770fca367b7c65d200dd5
parent9999fa307bcecf304ef4bf998dc97bf09da46fee (diff)
downloadsws-efe829cec040e7d6157a26bbc4096d6078171f44.tar.gz
sws-efe829cec040e7d6157a26bbc4096d6078171f44.tar.bz2
Add version
-rw-r--r--Makefile1
-rw-r--r--cmd/server/main.go7
-rw-r--r--user_agent_set.go6
3 files changed, 9 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 8614dd5..bbdfd65 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
+VERSION?= $(shell git describe --tags --always)
BINARY= $(patsubst %,dist/%,$(shell find cmd/* -maxdepth 0 -type d -exec basename {} \;))
SRC= $(shell find . -type f -name '*.go')
SQL= $(shell find sql -type f)
diff --git a/cmd/server/main.go b/cmd/server/main.go
index 0d65bb7..7f62f11 100644
--- a/cmd/server/main.go
+++ b/cmd/server/main.go
@@ -22,6 +22,8 @@ import (
"src.userspace.com.au/templates"
)
+var Version string
+
// Flags
var (
verbose *bool
@@ -62,6 +64,7 @@ func main() {
fmt.Fprintln(os.Stdout, v...)
}
}
+ log("version", Version)
driver := strings.SplitN(*dsn, ":", 2)[0]
if driver == "file" {
@@ -69,12 +72,12 @@ func main() {
}
if noMigrate == nil || !*noMigrate {
- version, err := migrateDatabase(driver, *dsn)
+ v, err := migrateDatabase(driver, *dsn)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to migrate: %s", err)
os.Exit(2)
}
- log("database at version", version)
+ log("database at version", v)
}
db, err := sqlx.Open(driver, *dsn)
diff --git a/user_agent_set.go b/user_agent_set.go
index 6e7456b..435e9cd 100644
--- a/user_agent_set.go
+++ b/user_agent_set.go
@@ -43,10 +43,10 @@ func (uas UserAgentSet) YMax() int {
}
return max
}
-func (s UserAgentSet) XSeries() []*UserAgent {
- out := make([]*UserAgent, len(s))
+func (uas UserAgentSet) XSeries() []*UserAgent {
+ out := make([]*UserAgent, len(uas))
i := 0
- for _, v := range s {
+ for _, v := range uas {
out[i] = v
i++
}