docs icon indicating copy to clipboard operation
docs copied to clipboard

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

Open lukehoban opened this issue 3 years ago • 1 comments

While we have the language-neutral content at https://www.pulumi.com/docs/intro/concepts/inputs-outputs/ that includes examples for Go, the way Inputs and Outputs work in Go in particular is unique in a number of ways that are useful to understand outside of just the general notions of Input/Output in Pulumi.

We should include some Go-specific content in the Go language docs at https://www.pulumi.com/docs/intro/languages/go/ that provides more details of the Input/Output type model, and how to apply this in Pulumi Go programs.

lukehoban avatar Mar 11 '21 19:03 lukehoban

Below are a few areas where it would be great to get clarification/guidance on Go programming in Pulumi.

  • Better documentation and examples for All()
  • Not sure how this could be documented better, but dealing with collections is tough to read/follow. Any guidance/documentation here is appreciated.
  • Additional guidance/docs/examples around use cases and why we need to do stuff like myInput.ToMyOutput().ApplyT(...). it's tough to follow/understand.
  • Guidance on creating structured output to accomplish something like the below program. Eg- Output<MyStruct> or use pulumi.StringMap
 var err error
 type SsmLookupArgs struct {
     Name string `json:"name"`
     WithDecryption bool `json:"decryption"`
 }

 untypedStructOutput := jsonInput.ToStringOutput().ApplyT(func(s string) any {
     var result SsmLookupArgs

     err = json.Unmarshal([]byte(s), &result)
     if err != nil {
         log.Fatalf("Failed to unmarshal json input %s", err)
     }
     return result
 })

 param := ssm.LookupParameterOutput(ctx, ssm.LookupParameterOutputArgs{
     Name: untypedStructOutput.ApplyT(func (x any) string { return x.(SsmLookupArgs).Name }).(pulumi.StringOutput),
     WithDecryption: untypedStructOutput.ApplyT(func (x any) bool { return x.(SsmLookupArgs).WithDecryption }).(pulumi.BoolOutput),
 }, nil)
 if err != nil {
     return err
 }
  • One can call ApplyT on a nil receiver. What is the guidance here? What are some use cases we might want to be able to call ApplyT on a nilable object.

phillipedwards avatar Feb 24 '23 19:02 phillipedwards