Skip to content

Instantly share code, notes, and snippets.

@tnolet tnolet/numbers.go
Created Jan 17, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.