pulumi/sdk/go
Joe Duffy fc26844856 Go generics proof of concept
This is a basic proof of concept for using Go generics in our Go
SDK. There were a number of "on the fly" design decisions made:

* Replace Input altogether.

* Keep Output[T], but it needs to be a struct largely due to the
  lack of generics support in the Go reflection library.

* Introduce AnyOutput as a base interface that all Output[*]s
  implement, which lets us treat any "outputtish" things uniformly.

This is enough to get the basic hello, world working:

  package main

  import (
      "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
  )

  func main() {
      pulumi.Run(func(ctx *pulumi.Context) error {
          var bucket Bucket
          if err := ctx.RegisterResource("aws:s3/bucket:Bucket", "myBucket", pulumi.Map{}, &bucket); err != nil {
              return err
          }

          ctx.Export("bucketName", bucket.Bucket)

          nameLength := pulumi.Apply(bucket.Bucket, func(name string) int {
              return len(name)
          })
          ctx.Export("bucketNameLength", nameLength)

          return nil
      })
  }

There are plenty of embarassing hacks needed to get this to work,
and some blatent omissions too. For instance, I doubt Any works, and
obviously the tests won't run clean. Nevertheless, I wanted to save/
archive/share this work in the event that it's helpful to someone.
2021-12-16 17:48:01 -08:00
..
auto .NET & python SDKs parity for bad pulumi versions (#8297) 2021-10-27 20:54:23 -07:00
common Go generics proof of concept 2021-12-16 17:48:01 -08:00
pulumi Go generics proof of concept 2021-12-16 17:48:01 -08:00
pulumi-language-go [codegen/go] Emit `pulumiplugin.json` as part of codegen (#8530) 2021-12-06 13:10:30 -08:00
Makefile [automation-api] Exclude tests from test_fast. (#7986) 2021-09-16 17:33:33 -07:00
README.md `pulumi update` => `pulumi up` (#2702) 2019-05-06 14:00:18 -07:00

README.md

Pulumi Golang SDK

This directory contains support for writing Pulumi programs in the Go language. There are two aspects to this:

  • pulumi/ contains the client language bindings Pulumi program's code directly against;
  • pulumi-language-go/ contains the language host plugin that the Pulumi engine uses to orchestrate updates.

To author a Pulumi program in Go, simply say so in your Pulumi.yaml

name: <my-project>
runtime: go

and ensure you have pulumi-language-go on your path (it is distributed in the Pulumi download automatically).

By default, the language plugin will use your project's name, <my-project>, as the executable that it loads. This too must be on your path for the language provider to load it when you run pulumi preview or pulumi up.