You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
main.go.tmpl calls rootCmd.ExecuteContext(ctx) directly instead of azdext.Run(...), missing the SDK's signal handling, reserved-flag validation, and process token wiring.
Net effect: every newly-scaffolded Go extension reproduces the same problems #7950 / #7796 are eliminating, and #7925 was filed against this directly.
internal/cmd/listen.go.tmpl, metadata.go.tmpl, version.go.tmpl, prompt.go.tmpl, context.go.tmpl — review for any pattern updates (e.g., RunE signatures, accepting *azdext.ExtensionContext)
go.sum — regenerate alongside go.mod bump
README.md, CHANGELOG.md — note SDK requirements
Required changes
go.mod.tmpl
go 1.26
require (
// ... existing azure-sdk-for-go entries ...
github.com/azure/azure-dev/cli/azd v<current released minor>
// ...
)
Pick a real released minor version (e.g., v1.24.x once that's tagged) instead of a pseudo-version, so the scaffold doesn't keep silently aging. Decide on a refresh policy: bump on every azd CLI release, or on every SDK feature that scaffolded extensions should adopt by default.
main.go.tmpl
package main
import (
"{{.Metadata.Id}}/internal/cmd""github.com/azure/azure-dev/cli/azd/pkg/azdext"
)
funcmain() {
azdext.Run(cmd.NewRootCommand())
}
The FORCE_COLORinit() block becomes unnecessary — azdext.Run handles process setup.
Drop the --debug registration. Thread extCtx only into subcommands that demonstrably benefit (e.g., context.go.tmpl if it shows env/output usage); leave listen, version, metadata alone.
Subcommand templates
context.go.tmpl is the natural place to demonstrate reading from extCtx (e.g., print extCtx.Environment, extCtx.OutputFormat). Update the example to show idiomatic usage.
prompt.go.tmpl — adjust if it currently demonstrates --no-prompt handling via the legacy rootFlags pattern.
Test coverage
Add an integration test (or document a manual smoke step in microsoft.azd.extensions/README.md):
mkdir -p /tmp/scaffold-test &&cd /tmp/scaffold-test
azd x init --language go --namespace foo --id foo.bar
cd foo.bar
go build ./...
go test ./...
A CI smoke test would catch template drift early; if too expensive, at minimum a go build + golangci-lint run against the generated tree on PRs that touch internal/resources/languages/go/.
Validation
cd cli/azd/extensions/microsoft.azd.extensions
go build ./... && go test ./...
azd x build
# Then run the scaffold-test snippet above.
Sub-issue of #7951 (Part 2 — Go subset). Closes #7925.
Problem
azd x init --language gogenerates Go extensions that are stale on day one:go.mod.tmplpinsgithub.com/azure/azure-dev/cli/azd v0.0.0-20260116183934-428498d0f124(pseudo-version from January 2026 — months out of date).go.mod.tmpldeclaresgo 1.25; the rest of the repo is ongo 1.26.root.go.tmplemits the legacycobra.Command{}+ manual--debugpattern that the umbrella migration (1P extensions: migrate toazdext.NewExtensionRootCommandand remove reserved flag conflicts #7950) is removing across the 1P fleet.main.go.tmplcallsrootCmd.ExecuteContext(ctx)directly instead ofazdext.Run(...), missing the SDK's signal handling, reserved-flag validation, and process token wiring.Net effect: every newly-scaffolded Go extension reproduces the same problems #7950 / #7796 are eliminating, and #7925 was filed against this directly.
Files
cli/azd/extensions/microsoft.azd.extensions/internal/resources/languages/go/go.mod.tmplmain.go.tmplinternal/cmd/root.go.tmplinternal/cmd/listen.go.tmpl,metadata.go.tmpl,version.go.tmpl,prompt.go.tmpl,context.go.tmpl— review for any pattern updates (e.g., RunE signatures, accepting*azdext.ExtensionContext)go.sum— regenerate alongsidego.modbumpREADME.md,CHANGELOG.md— note SDK requirementsRequired changes
go.mod.tmplPick a real released minor version (e.g.,
v1.24.xonce that's tagged) instead of a pseudo-version, so the scaffold doesn't keep silently aging. Decide on a refresh policy: bump on every azd CLI release, or on every SDK feature that scaffolded extensions should adopt by default.main.go.tmplThe
FORCE_COLORinit()block becomes unnecessary —azdext.Runhandles process setup.internal/cmd/root.go.tmplDrop the
--debugregistration. ThreadextCtxonly into subcommands that demonstrably benefit (e.g.,context.go.tmplif it shows env/output usage); leavelisten,version,metadataalone.Subcommand templates
context.go.tmplis the natural place to demonstrate reading fromextCtx(e.g., printextCtx.Environment,extCtx.OutputFormat). Update the example to show idiomatic usage.prompt.go.tmpl— adjust if it currently demonstrates--no-prompthandling via the legacyrootFlagspattern.Test coverage
Add an integration test (or document a manual smoke step in
microsoft.azd.extensions/README.md):A CI smoke test would catch template drift early; if too expensive, at minimum a
go build+golangci-lint runagainst the generated tree on PRs that touchinternal/resources/languages/go/.Validation
Out of scope
microsoft.azd.extensionsitself — see microsoft.azd.extensions: migrate root command toNewExtensionRootCommand#7952.azdext.NewExtensionRootCommandand remove reserved flag conflicts #7950.Related
NewExtensionRootCommandand refresh scaffolding templates #7951 — parentazd x initgenerates Go extension with old reference togithub.com/azure/azure-dev/cli/azd#7925 — original customer report (closed by this)azure.ai.agentsmigration (real-world reference for the new patterns)RegisterFlagOptionsfor per-subcommand flag config #7826 —RegisterFlagOptionsNewExtensionRootCommand