Skip to content

Instantly share code, notes, and snippets.

@tnolet
Created January 17, 2018 15:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tnolet/0dd7a4f7a32026ae3d6f5f07f70c8277 to your computer and use it in GitHub Desktop.
Save tnolet/0dd7a4f7a32026ae3d6f5f07f70c8277 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func Handler() (events.APIGatewayProxyResponse, error) {
f := fibonacci()
for i := 0; i < 30; i++ {
fmt.Println(f())
}
return events.APIGatewayProxyResponse{
Body: "done",
StatusCode: 200,
}, nil
}
func main() {
lambda.Start(Handler)
}
func fibonacci() func() int {
x, y := 0, 1
return func() int {
x, y = y, x+y
return x
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment