From d9db52e5540456ae8d18c351cc2749e2b44fdee9 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 31 Jul 2026 16:20:42 +0000 Subject: [PATCH] docs(go): document build_addr relative pkg resolution heph.go.build_addr's pkg argument now accepts a ./ or ../ path relative to the calling BUILD file's package (hephbuild/heph#295). Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_015jVVx4PndzUBvV5MbQLrdh --- .../heph-go/skills/heph-go/references/go-plugin.md | 5 +++++ website/docs/plugins/go.md | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugins/heph-go/skills/heph-go/references/go-plugin.md b/plugins/heph-go/skills/heph-go/references/go-plugin.md index ff8881c..decf15a 100644 --- a/plugins/heph-go/skills/heph-go/references/go-plugin.md +++ b/plugins/heph-go/skills/heph-go/references/go-plugin.md @@ -221,9 +221,14 @@ none match. Library targets have no such shortcut — always give them `@v=NAME` heph.go.build_addr(pkg, variant = "") # heph.go.build_addr("cmd/server", "release") -> "//cmd/server:build@v=release" # heph.go.build_addr("cmd/server") -> "//cmd/server:build" +# heph.go.build_addr("./worker", "release") -> relative to the calling package, e.g. "//cmd/server/worker:build@v=release" +# heph.go.build_addr("../shared") -> "//cmd/shared:build" ``` - `pkg` required; `variant` optional, defaults to `""` (plain address). +- `pkg` is a package path, or, starting with `./` or `../`, resolved relative + to the calling BUILD file's package (same rules as relative addresses). A + path that resolves outside the workspace is an error. - All arguments are type-enforced: wrong type, missing required arg, or unknown keyword → hard error naming the function and the offending argument. - Pure string formatting — resolves and builds nothing, and doesn't check that diff --git a/website/docs/plugins/go.md b/website/docs/plugins/go.md index d1a8ea6..c1cd3cb 100644 --- a/website/docs/plugins/go.md +++ b/website/docs/plugins/go.md @@ -321,7 +321,7 @@ namespace. | Function | Signature | Returns | |----------|-----------|-------| -| `heph.go.build_addr` | `build_addr(pkg: string, variant: string = "") -> string` | The address of `pkg`'s `build` target, optionally pinned to a named [build variant](#build-variants). | +| `heph.go.build_addr` | `build_addr(pkg: string, variant: string = "") -> string` | The address of `pkg`'s `build` target, optionally pinned to a named [build variant](#build-variants). `pkg` accepts a package path or a path relative to the calling BUILD file's package. | The function enforces its argument types: wrong type, missing required argument, or unknown keyword produces a clear error. @@ -406,7 +406,7 @@ heph.go.build_addr(pkg, variant = "") | Argument | Default | Meaning | |-----------|---------|---------| -| `pkg` | required | The target's package, e.g. `"cmd/server"`. | +| `pkg` | required | The target's package, e.g. `"cmd/server"`. Starting with `./` or `../`, it resolves relative to the calling BUILD file's package instead — same rules as [relative addresses](../reference/addresses.md#relative-forms). A path that resolves outside the workspace is an error. | | `variant` | `""` | The variant name. Omit (or pass `""`) for the plain, unparameterized address. | ```python title="cmd/server/BUILD" @@ -423,6 +423,13 @@ The image target now embeds the `release`-variant binary. Calling `build_addr` only formats the address — it does not resolve or build anything, and it does not check that the variant is actually declared. +`pkg` can also be given relative to the calling package: + +```python title="cmd/server/BUILD" +heph.go.build_addr("./worker", "release") # -> //cmd/server/worker:build@v=release +heph.go.build_addr("../shared") # -> //cmd/shared:build +``` + :::note List every provider-exposed BUILD function with `heph inspect functions`. :::