【发布时间】:2020-01-27 16:45:54
【问题描述】:
在执行 lambda 函数时获取error fork/exec /var/task/main: no such file or directory。
我正在使用 Windows 平台在 Go 中运行和构建代码。
我已完成以下步骤来部署 go aws-lambda 处理程序:
- 在windows平台用VSCode用go语言编写代码
- 使用以下命令构建项目:go build main.go
- 将 main.exe 转换为 main.zip
- 使用 aws 控制台帐户上传了带有处理程序名称 main aws-lambda 函数的 main.zip
- 创建了测试事件来测试 lambda 函数
- 出现错误“fork/exec /var/task/main: no such file or directory while execution lambda function”
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
// Request represents the requested object
type Request struct {
ID int `json:"ID"`
Value string `json:"Value"`
}
// Response represents the Response object
type Response struct {
Message string `json:"Message"`
Ok bool `json:"Ok"`
}
// Handler represents the Handler of lambda
func Handler(request Request) (Response, error) {
return Response{
Message: fmt.Sprint("Process Request Id %f", request.ID),
Ok: true,
}, nil
}
func main() {
lambda.Start(Handler)
}
构建命令
go build main.go
AWS 控制台中的详细错误
{
"errorMessage": "fork/exec /var/task/main: no such file or directory",
"errorType": "PathError"
}
AWS 控制台中的日志输出
START RequestId: 9ef206ed-5538-407a-acf0-06673bacf2d7 Version: $LATEST
fork/exec /var/task/main: no such file or directory: PathError
null
END RequestId: 9ef206ed-5538-407a-acf0-06673bacf2d7
REPORT RequestId: 9ef206ed-5538-407a-acf0-06673bacf2d7 Duration: 0.64 ms Billed Duration: 100 ms Memory Size: 512 MB Max Memory Used: 31 MB Init Duration: 1.49 ms
【问题讨论】:
标签: go amazon-s3 aws-lambda handler