mirror of https://github.com/pulumi/pulumi.git
fc26844856
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. |
||
---|---|---|
.. | ||
apitype | ||
constant | ||
diag | ||
encoding | ||
resource | ||
testing | ||
tokens | ||
tools | ||
util | ||
version | ||
workspace |