Archived
1
0

add git version to srnd version string

This commit is contained in:
Jeff Becker 2017-09-24 08:10:35 -04:00
parent a85622854b
commit dee8c005fd
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
3 changed files with 10 additions and 6 deletions

View File

@ -11,7 +11,7 @@ assert-go:
test $(VERSION) = go1.9
srndv2: assert-go
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -v
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) build -ldflags "-X srnd.GitVersion=-$(shell git rev-parse --short HEAD)" -v
clean:
GOPATH=$(REPO) GOROOT=$(GOROOT) $(GO) clean -v

View File

@ -6,10 +6,12 @@ package srnd
import "fmt"
var major_version = 5
var minor_version = 0
var program_name = "srnd"
const major_version = 5
const minor_version = 0
const program_name = "srnd"
var GitVersion string
func Version() string {
return fmt.Sprintf("%s version 2.%d.%d", program_name, major_version, minor_version)
return fmt.Sprintf("%s-2.%d.%d%s", program_name, major_version, minor_version, GitVersion)
}

View File

@ -140,10 +140,12 @@ func main() {
} else {
fmt.Fprintf(os.Stdout, "Usage: %s tool [rethumb|keygen|nntp|mod|expire]\n", os.Args[0])
}
} else if action == "version" {
fmt.Println(srnd.Version())
} else {
log.Println("Invalid action:", action)
}
} else {
fmt.Fprintf(os.Stdout, "Usage: %s [setup|run|tool]\n", os.Args[0])
fmt.Fprintf(os.Stdout, "Usage: %s [setup|run|tool|version]\n", os.Args[0])
}
}