Skip to content

Commit 168a903

Browse files
committed
Apply AI‑suggested Makefile enhancement to generated scaffolded projects
1 parent 83e9ed7 commit 168a903

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ GOLANGCI_LINT_VERSION ?= v2.3.0
236236
# $2 - package url which can be installed
237237
# $3 - specific version of package
238238
define go-install-tool
239-
@[ -f "$(1)-$(3)" ] || { \
239+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
240240
set -e; \
241241
package=$(2)@$(3) ;\
242242
echo "Downloading $${package}" ;\
243-
rm -f $(1) || true ;\
243+
rm -f $(1) ;\
244244
GOBIN=$(LOCALBIN) go install $${package} ;\
245245
mv $(1) $(1)-$(3) ;\
246246
} ;\
247-
ln -sf $(1)-$(3) $(1)
247+
ln -sf $$(realpath $(1)-$(3)) $(1)
248248
endef

docs/book/src/cronjob-tutorial/testdata/project/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ $(GOLANGCI_LINT): $(LOCALBIN)
230230
# $2 - package url which can be installed
231231
# $3 - specific version of package
232232
define go-install-tool
233-
@[ -f "$(1)-$(3)" ] || { \
233+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
234234
set -e; \
235235
package=$(2)@$(3) ;\
236236
echo "Downloading $${package}" ;\
237-
rm -f $(1) || true ;\
237+
rm -f $(1) ;\
238238
GOBIN=$(LOCALBIN) go install $${package} ;\
239239
mv $(1) $(1)-$(3) ;\
240240
} ;\
241-
ln -sf $(1)-$(3) $(1)
241+
ln -sf $$(realpath $(1)-$(3)) $(1)
242242
endef

docs/book/src/getting-started/testdata/project/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ $(GOLANGCI_LINT): $(LOCALBIN)
226226
# $2 - package url which can be installed
227227
# $3 - specific version of package
228228
define go-install-tool
229-
@[ -f "$(1)-$(3)" ] || { \
229+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
230230
set -e; \
231231
package=$(2)@$(3) ;\
232232
echo "Downloading $${package}" ;\
233-
rm -f $(1) || true ;\
233+
rm -f $(1) ;\
234234
GOBIN=$(LOCALBIN) go install $${package} ;\
235235
mv $(1) $(1)-$(3) ;\
236236
} ;\
237-
ln -sf $(1)-$(3) $(1)
237+
ln -sf $$(realpath $(1)-$(3)) $(1)
238238
endef

docs/book/src/multiversion-tutorial/testdata/project/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ $(GOLANGCI_LINT): $(LOCALBIN)
230230
# $2 - package url which can be installed
231231
# $3 - specific version of package
232232
define go-install-tool
233-
@[ -f "$(1)-$(3)" ] || { \
233+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
234234
set -e; \
235235
package=$(2)@$(3) ;\
236236
echo "Downloading $${package}" ;\
237-
rm -f $(1) || true ;\
237+
rm -f $(1) ;\
238238
GOBIN=$(LOCALBIN) go install $${package} ;\
239239
mv $(1) $(1)-$(3) ;\
240240
} ;\
241-
ln -sf $(1)-$(3) $(1)
241+
ln -sf $$(realpath $(1)-$(3)) $(1)
242242
endef

pkg/plugins/golang/v4/scaffolds/internal/templates/makefile.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ $(GOLANGCI_LINT): $(LOCALBIN)
305305
# $2 - package url which can be installed
306306
# $3 - specific version of package
307307
define go-install-tool
308-
@[ -f "$(1)-$(3)" ] || { \
308+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
309309
set -e; \
310310
package=$(2)@$(3) ;\
311311
echo "Downloading $${package}" ;\
312-
rm -f $(1) || true ;\
312+
rm -f $(1) ;\
313313
GOBIN=$(LOCALBIN) go install $${package} ;\
314314
mv $(1) $(1)-$(3) ;\
315315
} ;\
316-
ln -sf $(1)-$(3) $(1)
316+
ln -sf $$(realpath $(1)-$(3)) $(1)
317317
endef
318318
`

testdata/project-v4-multigroup/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ $(GOLANGCI_LINT): $(LOCALBIN)
226226
# $2 - package url which can be installed
227227
# $3 - specific version of package
228228
define go-install-tool
229-
@[ -f "$(1)-$(3)" ] || { \
229+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
230230
set -e; \
231231
package=$(2)@$(3) ;\
232232
echo "Downloading $${package}" ;\
233-
rm -f $(1) || true ;\
233+
rm -f $(1) ;\
234234
GOBIN=$(LOCALBIN) go install $${package} ;\
235235
mv $(1) $(1)-$(3) ;\
236236
} ;\
237-
ln -sf $(1)-$(3) $(1)
237+
ln -sf $$(realpath $(1)-$(3)) $(1)
238238
endef

testdata/project-v4-with-plugins/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ $(GOLANGCI_LINT): $(LOCALBIN)
226226
# $2 - package url which can be installed
227227
# $3 - specific version of package
228228
define go-install-tool
229-
@[ -f "$(1)-$(3)" ] || { \
229+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
230230
set -e; \
231231
package=$(2)@$(3) ;\
232232
echo "Downloading $${package}" ;\
233-
rm -f $(1) || true ;\
233+
rm -f $(1) ;\
234234
GOBIN=$(LOCALBIN) go install $${package} ;\
235235
mv $(1) $(1)-$(3) ;\
236236
} ;\
237-
ln -sf $(1)-$(3) $(1)
237+
ln -sf $$(realpath $(1)-$(3)) $(1)
238238
endef

testdata/project-v4/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ $(GOLANGCI_LINT): $(LOCALBIN)
226226
# $2 - package url which can be installed
227227
# $3 - specific version of package
228228
define go-install-tool
229-
@[ -f "$(1)-$(3)" ] || { \
229+
@[ -f "$(1)-$(3)" ] && [ "$$(readlink -- "$(1)" 2>/dev/null)" = "$(1)-$(3)" ] || { \
230230
set -e; \
231231
package=$(2)@$(3) ;\
232232
echo "Downloading $${package}" ;\
233-
rm -f $(1) || true ;\
233+
rm -f $(1) ;\
234234
GOBIN=$(LOCALBIN) go install $${package} ;\
235235
mv $(1) $(1)-$(3) ;\
236236
} ;\
237-
ln -sf $(1)-$(3) $(1)
237+
ln -sf $$(realpath $(1)-$(3)) $(1)
238238
endef

0 commit comments

Comments
 (0)