File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed
Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -3,17 +3,10 @@ GO_FILES := $(shell find . -type f \( -iname '*.go' \))
33
44SCRIPT_FILES := $(wildcard ./bin/* )
55
6- HE_BUILD_VERSION ?= $(shell git describe --tags)
7- ifeq ($(HE_BUILD_VERSION ) ,)
8- _ := $(error Cannot determine build version)
9- endif
10-
11- BUILD_VERSION_FLAG := github.com/eikendev/hackenv/internal/buildconfig.Version=$(HE_BUILD_VERSION )
12-
136.PHONY : build
147build :
158 mkdir -p $(OUT_DIR )
16- go build -ldflags " -w -s -X $( BUILD_VERSION_FLAG ) " -o $(OUT_DIR ) /hackenv ./cmd/hackenv
9+ go build -ldflags " -w -s" -o $(OUT_DIR ) /hackenv ./cmd/hackenv
1710
1811.PHONY : clean
1912clean :
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ package commands
33
44import (
55 "fmt"
6+ "runtime/debug"
67
7- "github.com/eikendev/hackenv/internal/buildconfig"
88 "github.com/eikendev/hackenv/internal/options"
99)
1010
@@ -13,7 +13,11 @@ type VersionCommand struct{}
1313
1414// Run is the function for the version command.
1515func (* VersionCommand ) Run (_ * options.Options ) error {
16- fmt .Printf ("hackenv %s\n " , buildconfig .Version )
16+ buildInfo , ok := debug .ReadBuildInfo ()
17+ if ! ok {
18+ return fmt .Errorf ("build info not available" )
19+ }
1720
21+ fmt .Printf ("hackenv %s\n " , buildInfo .Main .Version )
1822 return nil
1923}
You can’t perform that action at this time.
0 commit comments