在执行lambda函数时获取error fork/exec /var/task/main: no such file or directory。
我正在使用windows平台运行并在Go中构建代码。
我已经完成了部署go aws处理程序的步骤:
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.goAWS控制台中的详细错误
{
"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发布于 2019-09-27 12:58:29
在命令提示符中运行以下命令
set GOOS=linux
set GOARCH=amd64
set CGO_ENABLED=0之后,构建项目并将zip文件上载到aws控制台lambda。
像这样
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o main main.go
发布于 2020-07-08 18:00:15
在我的例子中,问题是将默认的处理程序设置为'hello‘函数。
需要通过AWS视图面板将其更改为“main”,-> Basic Settings ->编辑。

发布于 2020-01-09 20:10:50
有两个原因可以发生:
https://stackoverflow.com/questions/58133166
复制相似问题