Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active February 11, 2021 07:56
Show Gist options
  • Save percybolmer/a7c5090f56c319c036c43500dba3dcfc to your computer and use it in GitHub Desktop.
Save percybolmer/a7c5090f56c319c036c43500dba3dcfc to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
// aws-lambda package has to be imported
"github.com/aws/aws-lambda-go/lambda"
)
// User is a simple struct to accept as input
type User struct {
Name string `json:"name"`
LastName string `json:"lastname"`
}
// Greetings is the response to a user entering
type Greetings struct {
Greet string `json:"greet"`
}
// String implements the stringer interface for user
func (u User) String() string {
return fmt.Sprintf("Welcome %s %s", u.Name, u.LastName)
}
// GreetVisitor is a lambda function that will greet a visitor
func GreetVisitor(event User) (Greetings, error) {
return Greetings{Greet: event.String()}, nil
}
func main() {
// Lambda start is used to handle the function
lambda.Start(GreetVisitor)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment