Hi, I was having a look at the Golang Component ex...
# golang
l
Hi, I was having a look at the Golang Component example and noticed that besides registering resource outputs with
.RegisterResourceOutputs
these values are also assigned to the struct (lines 93-94) https://github.com/pulumi/examples/blob/master/aws-go-s3-folder-component/s3folder.go#L93-L99 I don't fully understand why that is done.. The docs were also not that helpful in this case.
t
I'm far from an authority but I'm working on a theory
https://go.dev/doc/faq#stack_or_heap Perhaps there is a data dependency where these values must be kept alive
so they need to be stored somewhere so they are not considered stack local
but I'm not sure why a copy wouldn't solve that issue. While you have it running locally what happens if you remove those?
l
I was thinking in the same direction. I'm going to do some testing
It is just a bit confusing at the moment
t
I think it actually might just be the author of the example had a habit of returning things bundled (as if instead of a componenet this were a function to be called, and then the exports are done from the main.go)
and in fact if that were true then this component could be used as a regular import or a component in the manifest
so thats what I'm guessing
l
could be indeed. thanks for your reply!
t
But its worth nothing that I dont think that is clean (or works) because it still registers as a component resource and whatnot (but just because that is a useless operation doesn't mean it breaks things)
👍 1