awslambdahandler

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

awslambdahandler

Test Status Go Report Card Apache-2.0 license

awslambdahandler checks whether aws lambda handler signature is valid.

Valid AWS Lambda signatures are as follows

* func ()
* func () error
* func (TIn) error
* func () (TOut, error)
* func (TIn) (TOut, error)
* func (context.Context) error
* func (context.Context, TIn) error
* func (context.Context) (TOut, error)
* func (context.Context, TIn) (TOut, error)

Detection sample

package main

import (
	"context"

	"github.com/aws/aws-lambda-go/lambda"
)

type MyEvent struct {
	Name string `json:"What is your name?"`
	Age  int    `json:"How old are you?"`
}

type MyResponse struct {
	Message string `json:"Answer:"`
}

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

func MyHandle(context.Context, MyEvent) MyResponse {
	return MyResponse{}
}
  • Output
$ go vet -vettool=`which awslambdahandler` main.go
./main.go:19:14: lambda handler of "MyHandle" is invalid lambda signature, see https://pkg.go.dev/github.com/aws/aws-lambda-go/lambda#Start

For more detection samples, please see examples.

Usage

awslambdahandler with go vet

go vet is a Go standard tool for analyzing source code.

  1. Install awslambdahandler.
$ go install github.com/d-tsuji/awslambdahandler/cmd/awslambdahandler@latest
  1. awslambdahandler execute
$ go vet -vettool=`which awslambdahandler` main.go
./main.go:33:14: lambda handler of "MyHandle" is invalid lambda signature, see https://pkg.go.dev/github.com/aws/aws-lambda-go/lambda#Start

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name: "awslambdahandler",
	Doc:  doc,
	Run:  run,
	Requires: []*analysis.Analyzer{
		inspect.Analyzer,
	},
}

Functions

This section is empty.

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL