module: bump minimum Go version to 1.18 and use debug.ReadBuildInfo()

pull/73/head v0.4.3
cn 6 months ago
parent 0268126d70
commit 72c4c94cb7
  1. 2
      .github/workflows/ci.yml
  2. 6
      Makefile
  3. 21
      cmd/miflorad/version.go
  4. 2
      go.mod

@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
go:
- '1.17'
- '1.18'
env:
GO111MODULE: on
GOPROXY: direct

@ -53,8 +53,8 @@ remote-run: clean ## Run clean, build $RUN_COMMAND for Linux on ARM and launch i
release: ## Build and upload release version of miflorad to Github
mkdir -p pkg
pushd cmd/miflorad
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-amd64" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)"
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-arm" -ldflags="-s -w -X main.version=$(MIFLORAD_VERSION)"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-amd64" -ldflags="-s -w"
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -o "../../pkg/miflorad-$(MIFLORAD_VERSION)-linux-arm" -ldflags="-s -w"
popd
# github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --prerelease --github-repository "cmur2/miflorad"
github-release "v$(MIFLORAD_VERSION)" pkg/miflorad-$(MIFLORAD_VERSION)-* --commit "master" --tag "v$(MIFLORAD_VERSION)" --github-repository "cmur2/miflorad"
@ -62,7 +62,7 @@ release: ## Build and upload release version of miflorad to Github
.PHONY: cmd/miflorad/miflorad
cmd/miflorad/miflorad:
pushd cmd/miflorad
CGO_ENABLED=0 go build -buildmode=pie -ldflags "-X main.version=$(MIFLORAD_VERSION)"
CGO_ENABLED=0 go build -buildmode=pie
.PHONY: cmd/munin-miflora/munin-miflora
cmd/munin-miflora/munin-miflora:

@ -1,12 +1,21 @@
package main
// program version, will be populated on build
var version string
import (
"runtime/debug"
)
func getVersion() string {
if version == "" {
return "dev"
} else {
return version
info, ok := debug.ReadBuildInfo()
if !ok {
return "unknown"
}
for _, kv := range info.Settings {
switch kv.Key {
case "vcs.revision":
return kv.Value[0:8]
}
}
return "unknown"
}

@ -1,6 +1,6 @@
module miflorad
go 1.17
go 1.18
require (
github.com/currantlabs/gatt v0.0.0-20161006170101-f949eac78f4e

Loading…
Cancel
Save