Revise codelab for Go module management with Puku#3437
Revise codelab for Go module management with Puku#3437
Conversation
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.
Birkalo
left a comment
There was a problem hiding this comment.
I'm not going to get to the rest of this today unfortunately, but there's some comments here
docs/codelabs/go_module.md
Outdated
| summary: Third-party dependencies with go_module() | ||
| description: Set up gRPC and learn how to manage third party dependencies with Please | ||
| summary: Third-party dependencies with Puku | ||
| description: Add, update, pin, and remove Go third-party dependencies using go get and plz puku (no go_module()) |
There was a problem hiding this comment.
| description: Add, update, pin, and remove Go third-party dependencies using go get and plz puku (no go_module()) | |
| description: Add, update, pin, and remove Go third-party dependencies using go get and plz puku |
docs/codelabs/go_module.md
Outdated
| description: Set up gRPC and learn how to manage third party dependencies with Please | ||
| summary: Third-party dependencies with Puku | ||
| description: Add, update, pin, and remove Go third-party dependencies using go get and plz puku (no go_module()) | ||
| id: go_module |
docs/codelabs/go_module.md
Outdated
| Now add the dependency with `go get`: | ||
|
|
||
| ```bash | ||
| GOTOOLCHAIN=local go get github.com/google/uuid |
There was a problem hiding this comment.
Do we need GOTOOLCHAIN=local at the start of this? I didn't during my test, and if they've set it up properly in the steps above it might not be necessary
docs/codelabs/go_module.md
Outdated
|
|
||
| ### Example scenario | ||
|
|
||
| Let's say a new version of `uuid` has a breaking change. Pin it to a working version: |
There was a problem hiding this comment.
| Let's say a new version of `uuid` has a breaking change. Pin it to a working version: | |
| Let's say a new version of `uuid` has introduced a breaking change. Pin it to a working version: |
nitpick
docs/codelabs/go_module.md
Outdated
| ### 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 | ||
| ``` |
There was a problem hiding this comment.
This section repeats itself, probably worth consolidating it
docs/codelabs/go_module.md
Outdated
| - Please installed and configured: https://please.build/quickstart.html | ||
| - Go 1.20+ installed and on PATH | ||
| - Puku available in one of the following ways: | ||
| - Via Please alias: add an alias to `.plzconfig` (see below), or |
There was a problem hiding this comment.
below
The steps aren't below, they're on the next page.
docs/codelabs/go_module.md
Outdated
| - Please installed and configured: https://please.build/quickstart.html | ||
| - Go 1.20+ installed and on PATH | ||
| - Puku available in one of the following ways: | ||
| - Via Please alias: add an alias to `.plzconfig` (see below), or |
There was a problem hiding this comment.
| - Via Please alias: add an alias to `.plzconfig` (see below), or | |
| - Via a Please alias (guide in next step) |
docs/codelabs/go_module.md
Outdated
| - 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` |
There was a problem hiding this comment.
| - 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` |
docs/codelabs/go_module.md
Outdated
| ### 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 |
There was a problem hiding this comment.
Is this not the same as the ### Goals section above? I'd combine the two into a single section
docs/codelabs/go_module.md
Outdated
|
|
||
| ## Initialising your project | ||
| Duration: 2 | ||
| ## Initialising your project and running puku with please |
There was a problem hiding this comment.
| ## Initialising your project and running puku with please | |
| ## Initialising your project and running Puku with Please |
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.