Skip to content

Commit

Permalink
examples: move go.work creation to root (#378)
Browse files Browse the repository at this point in the history
We only need a single go.work file in the reposotory, and `go work use -r .`
can recursively add all sub-modules to it, without requiring bash iteration.

Moves the creation of go.work into the root Makefile
go.work is still in .gitignore so it won't be committed

Fixes #375
  • Loading branch information
eliben authored Nov 30, 2023
1 parent ace6dd6 commit 80874c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ clean-lint-cache:
build-examples:
for example in $(shell find ./examples -mindepth 1 -maxdepth 1 -type d); do \
(cd $$example; echo Build $$example; go mod tidy; go build -o /dev/null) || exit 1; done

.PHONY: add-go-work
add-go-work:
go work init .
go work use -r .
8 changes: 0 additions & 8 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ SYNC_REF?=main
sync: ## Sync all go.mod files
@sh .update-all-to-latest.sh ${SYNC_REF}

.PHONY: add-go-work-files
add-go-work-files: ## Add go work files to all examples
find . -name go.mod -execdir sh -c 'go work init && go work use . && go work use ../..' \;

.PHONY: rm-go-work-files
rm-go-work-files: ## Add go work files to all examples
rm -f ./*/go.work*

.PHONY: install-all
install-all: ## Add go work files to all examples
@find . -name go.mod -execdir go install \;

0 comments on commit 80874c4

Please sign in to comment.