Skip to content

Commit 7f08c46

Browse files
anjannathpraveenkumar
authored andcommitted
build: replace gofmt with goimports
goimports formats the import lines and also formats the code style as per gofmt so now `make fmt` will fix both this usefull in the absence of a full ide with golang support
1 parent 8296a0e commit 7f08c46

File tree

10 files changed

+479
-3
lines changed

10 files changed

+479
-3
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@ e2e-story-registry: install
249249

250250

251251
.PHONY: fmt
252-
fmt:
253-
@gofmt -l -w $(SOURCE_DIRS)
252+
fmt: $(TOOLS_BINDIR)/goimports
253+
@$(TOOLS_BINDIR)/goimports -l -w $(SOURCE_DIRS)
254254

255255
# Run golangci-lint against code
256256
.PHONY: lint cross-lint

tools/bin/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ golangci-lint.exe
33
gomod2rpmdeps
44
makefat
55
mockery
6+
goimports
7+
goimports.exe

tools/dummy.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ import (
77
_ "github.com/cfergeau/gomod2rpmdeps/cmd/gomod2rpmdeps"
88
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
99
_ "github.com/randall77/makefat"
10+
_ "golang.org/x/tools/cmd/goimports"
1011
)

tools/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ require (
66
github.com/cfergeau/gomod2rpmdeps v0.0.0-20210223144124-2042c4850ca8
77
github.com/golangci/golangci-lint v1.51.2
88
github.com/randall77/makefat v0.0.0-20210315173500-7ddd0e42c844
9+
golang.org/x/tools v0.6.0
910
)
1011

1112
require (
@@ -171,7 +172,6 @@ require (
171172
golang.org/x/sync v0.1.0 // indirect
172173
golang.org/x/sys v0.5.0 // indirect
173174
golang.org/x/text v0.7.0 // indirect
174-
golang.org/x/tools v0.6.0 // indirect
175175
google.golang.org/protobuf v1.28.0 // indirect
176176
gopkg.in/ini.v1 v1.67.0 // indirect
177177
gopkg.in/yaml.v2 v2.4.0 // indirect

tools/tools.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ $(TOOLS_BINDIR)/gomod2rpmdeps: $(TOOLS_DIR)/go.mod
1111

1212
$(TOOLS_BINDIR)/mockery: $(TOOLS_DIR)/go.mod
1313
cd $(TOOLS_DIR) && GOBIN="$(TOOLS_BINDIR)" go install github.com/vektra/mockery/v2@latest
14+
15+
$(TOOLS_BINDIR)/goimports: $(TOOLS_DIR)/go.mod
16+
cd $(TOOLS_DIR) && GOBIN="$(TOOLS_BINDIR)" go install golang.org/x/tools/cmd/goimports@latest

tools/vendor/golang.org/x/tools/cmd/goimports/doc.go

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)