0

I'm just trying to pick up Golang in the AWS Lambda flavor. I feel like the answer here is super simple, but I can't put my finger on it, nor could I find a post similar to this problem just yet.

//Lambda Function Go Code
package main
import "github.com/aws/aws-sdk-go"
import "github.com/aws/aws-lambda-go/lambda"
import "github.com/aws/aws-lambda-go/events"
import "errors"

func main() {
    lambda.Start(HandleRequest)
}

func HandleRequest(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
    if request.HTTPMethod == "POST" {
        var stringResponse string = "Success :)"
        APIResponse := events.APIGatewayProxyResponse{Body: stringResponse, StatusCode: 200}
        return APIResponse, nil
    }
    else {
        err := errors.New("Method Not Allowed")
        APIResponse := events.APIGatewayProxyResponse{Body: "Method Not OK", StatusCode: 502}
        return APIResponse, err
    }
}

When I try saving and compiling this code, I get the following:

VSCode Go Windows 10

Can anyone tell me what exactly I'm doing run? I was writing in VSCode in Windows 10, but I feel this silly thing is not connected to that.

1 Answer 1

2

Your else needs to be inline with the } closing the if.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much! I knew it was something simple I overlooked. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.