Skip to content

docs(go): add a conceptual overview of inputs and outputs in Go#18856

Open
joeduffy wants to merge 4 commits into
masterfrom
fix_issue_11762_go_inputs_outputs_overview
Open

docs(go): add a conceptual overview of inputs and outputs in Go#18856
joeduffy wants to merge 4 commits into
masterfrom
fix_issue_11762_go_inputs_outputs_overview

Conversation

@joeduffy
Copy link
Copy Markdown
Member

@joeduffy joeduffy commented May 8, 2026

Summary

This PR adds a new Go-specific documentation page explaining how Pulumi's input and output type system works in Go. The existing language-neutral Inputs & outputs page includes Go code examples, but does not address the aspects of the Go SDK that are unique to the language—the typed wrapper hierarchy, the ApplyT function, output lifting, and the ToXxxOutput() conversion pattern. Issue #11762 (filed by @lukehoban) and a follow-on community comment called these areas out as gaps.

What's new

New page: content/docs/iac/languages-sdks/go/go-inputs-outputs.md

Appears in the navigation as "Inputs & outputs" under the Go language SDK section. Covers:

  • Input helper constructors (pulumi.String, pulumi.Int, pulumi.StringPtr, etc.)
  • Collection input types (pulumi.StringArray, pulumi.StringMap, etc.)
  • Typed output wrappers (pulumi.StringOutput, pulumi.IntOutput, etc.) and why Go uses concrete types rather than a generic Output<T>
  • Transforming outputs with ApplyT and ApplyTWithContext, including the required type assertion pattern
  • Combining multiple outputs with pulumi.All
  • Converting Input to Output with ToXxxOutput() (essential for component constructors)
  • Output lifting with generated Index()/accessor methods on structured output types
  • String formatting with pulumi.Sprintf
  • Exporting stack outputs with ctx.Export
  • Common pitfalls section addressing the issues raised in the community comment

Updated page: content/docs/iac/languages-sdks/go/_index.md

The existing paragraph referencing the general Inputs & outputs page now also links to the new Go-specific page.

Navigation

The page is wired into the iac menu under iac-languages-go at weight 3, so it appears as the first sub-page under the Go language SDK entry.

Fixes #11762


🧠 This PR was created by workprentice on behalf of @joeduffy.

Add a new Go-specific page that explains the Pulumi Go SDK's input/output
type system in depth. The language-neutral inputs-outputs concepts page
includes multi-language examples for Go, but it does not cover Go-specific
details like the typed wrapper output hierarchy, the ApplyT function, output
lifting, and the ToXxxOutput() conversion pattern.

This page covers:
- Input helper constructors (pulumi.String, pulumi.Int, etc.) and Ptr variants
- Collection input types (pulumi.StringArray, pulumi.StringMap, etc.)
- Typed output wrappers (pulumi.StringOutput, pulumi.IntOutput, etc.)
- Transforming outputs with ApplyT and ApplyTWithContext
- Combining multiple outputs with pulumi.All
- The ToXxxOutput() conversion for Input-to-Output in component constructors
- Output lifting with generated Index/accessor methods
- String formatting with pulumi.Sprintf
- Exporting stack outputs with ctx.Export
- Common pitfalls (missing type assertions, creating resources in ApplyT, etc.)

Also updates the Go language SDK index page to link to this new page.

Fixes #11762
@joeduffy joeduffy added the impact/no-changelog-required This issue doesn't require a CHANGELOG update label May 8, 2026
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 8, 2026

Docs review

Solid, well-structured page that fills a real gap in the Go SDK docs. A few things to address before merging.

Style — heading and menu casing

Per AGENTS.md, H1 = Title Case, H2+ = Sentence case. The frontmatter mixes the two:

content/docs/iac/languages-sdks/go/go-inputs-outputs.md

  • Line 2: title_tag: \"Inputs & Outputs in Go | Languages & SDKs\" ✅ Title Case
  • Line 4: title: Inputs & outputs in Go — should be Title Case
  • Line 5: h1: Inputs & outputs in Go — should be Title Case
  • Line 9: name: Inputs & outputs — the existing concept-level menu entry is name: Inputs & Outputs (see content/docs/iac/concepts/inputs-outputs/_index.md:9), so the nav will display two different capitalizations of the same term

Suggested fix:

title_tag: \"Inputs & Outputs in Go | Languages & SDKs\"
meta_desc: A comprehensive guide to using the Pulumi Go SDK's input and output types, including helper constructors, ApplyT, All, output lifting, and common patterns.
title: Inputs & Outputs in Go
h1: Inputs & Outputs in Go
meta_image: /images/docs/meta-images/docs-meta.png
menu:
    iac:
        name: Inputs & Outputs

Technical accuracy — pointer helper comments

Lines 39–42:

pulumi.StringPtr(\"optional-value\") // *string
pulumi.IntPtr(8080)                // *int
pulumi.BoolPtr(false)              // *bool
pulumi.Float64Ptr(1.5)             // *float64

pulumi.StringPtr is a defined type (type StringPtr string) implementing StringPtrInput, not a function returning *string. The other Ptr helpers follow the same pattern. The comments are inconsistent with the // pulumi.StringInput-style annotations on lines 30–33 and may mislead readers into thinking these are plain Go pointers.

pulumi.StringPtr(\"optional-value\") // pulumi.StringPtrInput
pulumi.IntPtr(8080)                // pulumi.IntPtrInput
pulumi.BoolPtr(false)              // pulumi.BoolPtrInput
pulumi.Float64Ptr(1.5)             // pulumi.Float64PtrInput

Relatedly, line 45 says "the pointer helpers are typically needed when a resource argument is typed as *string (or similar) rather than pulumi.StringInput." In modern Pulumi Go codegen, optional *Args fields are typed pulumi.StringPtrInput, not *string. Consider rewording to:

The pointer helpers are typically needed when a resource argument is typed as pulumi.StringPtrInput (i.e., the underlying provider schema marks the property as optional).

Technical accuracy — "Nil receivers" pitfall

Line 256:

Nil receivers. ApplyT can be called on a nil output receiver and will return a zero output—it will not panic.

This claim is unusual and worth verifying against the actual SDK behavior before publishing. pulumi.StringOutput is a struct type whose zero value has nil internal channels; depending on how ApplyT is implemented, calling it on the zero value may or may not be safe, and even if it doesn't panic, the resulting output's behavior at apply time isn't obviously "a zero output." If you can't point to a specific SDK guarantee, I'd recommend dropping this bullet entirely — the section is stronger without an uncertain claim.

Minor

  • meta_desc (line 3) is 175 chars; SEO best practice is ≤160. Easy trim: drop "a comprehensive" → "A guide to the Pulumi Go SDK's input and output types: helper constructors, ApplyT, All, output lifting, and common patterns." (143 chars)
  • Line 16 alias /docs/languages-sdks/go/go-inputs-outputs/ is for a path that never existed (this is a new page). Harmless, but unnecessary — only the parent _index.md previously aliased /docs/languages-sdks/go/, and Hugo doesn't propagate that to children.
  • The page leans heavily on em-dashes (~12+ across the body). Not a hard rule for docs (the AI-pattern criteria target blogs), but readability would benefit from converting some to commas, periods, or parentheses.

What's good

  • All cross-references resolve (/docs/iac/concepts/inputs-outputs/{,apply,all,helpers}/ all exist).
  • Menu wiring under iac-languages-go at weight: 3 is correct and consistent with _index.md's identifier: iac-languages-go.
  • Cross-link added in _index.md is a clean improvement; the original sentence had a stray double space before "and" that's also cleaned up.
  • Code examples are syntactically sound and idiomatic (ApplyT(...).(pulumi.StringOutput) pattern, pulumi.All slice asserts, Index/Elem lifting chain are all correct).
  • The pitfalls section addresses the exact gaps called out in Add a conceptual overview of Go Input/Output model to Go language docs #11762.

@claude — let me know if you'd like another pass after edits.

- Title/h1/menu: use Title Case per AGENTS.md
- Ptr helper comments: use pulumi.XxxPtrInput not *string
- Reword pointer helpers explanation
- Remove unverified nil receivers claim
- Trim meta_desc to < 160 chars
- Remove unnecessary alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

impact/no-changelog-required This issue doesn't require a CHANGELOG update

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a conceptual overview of Go Input/Output model to Go language docs

2 participants