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' \))
3
3
4
4
SCRIPT_FILES := $(wildcard ./bin/* )
5
5
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
-
13
6
.PHONY : build
14
7
build :
15
8
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
17
10
18
11
.PHONY : clean
19
12
clean :
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ package commands
3
3
4
4
import (
5
5
"fmt"
6
+ "runtime/debug"
6
7
7
- "github.com/eikendev/hackenv/internal/buildconfig"
8
8
"github.com/eikendev/hackenv/internal/options"
9
9
)
10
10
@@ -13,7 +13,11 @@ type VersionCommand struct{}
13
13
14
14
// Run is the function for the version command.
15
15
func (* 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
+ }
17
20
21
+ fmt .Printf ("hackenv %s\n " , buildInfo .Main .Version )
18
22
return nil
19
23
}
You can’t perform that action at this time.
0 commit comments