Skip to content

Revise codelab for Go module management with Puku#3437

Merged
Birkalo merged 3 commits intomasterfrom
update-codelab-puku
Feb 18, 2026
Merged

Revise codelab for Go module management with Puku#3437
Birkalo merged 3 commits intomasterfrom
update-codelab-puku

Conversation

@scyyx5
Copy link
Contributor

@scyyx5 scyyx5 commented Oct 25, 2025

Updated the codelab to reflect changes in dependency management with Puku, including renaming and clarifying instructions for adding, updating, and removing Go third-party dependencies.

Updated the codelab to reflect changes in dependency management with Puku, including renaming and clarifying instructions for adding, updating, and removing Go third-party dependencies.
Copy link
Contributor

@Birkalo Birkalo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to get to the rest of this today unfortunately, but there's some comments here

Comment on lines +309 to +353
### Steps to remove a module

1. **Verify no dependencies exist:**

```bash
plz query revdeps //third_party/go:module_name --level=-1 | grep -v //third_party/go
```

If this returns no results, the module is safe to remove.

2. **Remove the `go_repo()` target from `third_party/go/BUILD`:**

Open `third_party/go/BUILD` and delete the corresponding `go_repo()` rule.

3. **Remove from `go.mod` and `go.sum`:**

```bash
go mod edit -droprequire github.com/example/module
go mod tidy
```

4. **Sync the changes:**

```bash
plz puku sync -w
```

And update our `:grpc` rule to add `:genproto_rpc` as a dependency:
**Note:** Puku does not currently automate module removal, so this process is manual.

### Example

Let's say we want to remove an unused module:

```bash
# Check for dependencies
plz query revdeps //third_party/go:unused_module --level=-1 | grep -v //third_party/go

# If safe, remove from go.mod
go mod edit -droprequire github.com/unused/module
go mod tidy

# Manually delete the go_repo() rule from third_party/go/BUILD
# Then sync
plz puku sync -w
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section repeats itself, probably worth consolidating it

Comment on lines +31 to +33
- Installed locally (if the first doesn't work, try the second):
- `go install github.com/please-build/puku/cmd/puku@latest`
- `go get github.com/please-build/puku/cmd/puku`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Installed locally (if the first doesn't work, try the second):
- `go install github.com/please-build/puku/cmd/puku@latest`
- `go get github.com/please-build/puku/cmd/puku`
- Installed locally with either:
- `go install github.com/please-build/puku/cmd/puku@latest`
or
- `go get github.com/please-build/puku/cmd/puku`

Comment on lines +35 to +41
### What you’ll learn
- Add and upgrade dependencies with `go get`
- Sync `go.mod` into `third_party/go/BUILD` with `plz puku sync`
- Let `plz puku fmt` add third-party deps to your BUILD targets
- Diagnose missing imports and missing subrepos
- Pin or exclude dependency versions with `go mod edit`
- Remove third-party modules safely
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not the same as the ### Goals section above? I'd combine the two into a single section


## Initialising your project
Duration: 2
## Initialising your project and running puku with please
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Initialising your project and running puku with please
## Initialising your project and running Puku with Please

@Birkalo Birkalo merged commit 454f079 into master Feb 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants