https://pulumi.com logo
Title
p

plain-parrot-21984

03/24/2023, 10:30 AM
The API doc examples seem to have some recurring errors. I'm not 100% sure about this, since I'm very new to GoLang, programming in general and Pulumi, but I've discovered the following (see thread) ⬇️
https://www.pulumi.com/registry/packages/aws/api-docs/apigatewayv2/api/
_, err := apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
should be
_, err = apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
without the colon before the equals sign because the first variable is not defined • https://www.pulumi.com/registry/packages/aws/api-docs/apigatewayv2/route/
_, err = apigatewayv2.NewRoute(ctx, "exampleRoute", &apigatewayv2.RouteArgs{
here it seems correct This type of error, where
_
is used as a placeholder (?) and the definition uses
:=
seems to be very common.
s

salmon-account-74572

03/24/2023, 8:33 PM
This may just be a Golang thing (I don’t know enough about your code). But if you create a couple of resources where you are “throwing away” one of the values (like
_, err := blah
and then later
_, err := otherblah
, it will flag the second one as incorrect (because you aren’t defining any new variables. That’s why you have to use
_, err = otherblah
. I probably didn’t do a great job of explaining this, but hopefully it helps a little!
e

echoing-dinner-19531

03/25/2023, 3:37 PM
_, err = ...
is a compile error if the
err
variable hasn't been declared elsewhere.
_ err := ...
is a compile error if the
err
variable is declared elsewhere. So our code generator has to change which one it uses based on if any other uses of
err
have happened before.