# golang


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) ⬇️
Copy code
_, err := apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
should be
Copy code
_, err = apigatewayv2.NewApi(ctx, "example", &apigatewayv2.ApiArgs{
without the colon before the equals sign because the first variable is not defined •
Copy code
_, 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.


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!


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