英文:
How to simulate errors against DynamoDB in Go?
问题
如何使用Go模拟对DynamoDB的错误?这篇博文只讲了Java的方法... https://aws.amazon.com/blogs/developer/injecting-failures-and-latency-using-the-aws-sdk-for-java/
英文:
How does one simulate errors against DynamoDB using Go? This blog post only talks about Java... https://aws.amazon.com/blogs/developer/injecting-failures-and-latency-using-the-aws-sdk-for-java/
答案1
得分: 3
import (
errors "golang.org/x/xerrors"
)
client := dynamodb.New(sess)
client.Handlers.Validate.AfterEachFn = func(item request.HandlerListRunItem) bool {
item.Request.Error = errors.New("模拟错误")
return false
}
英文:
import (
errors "golang.org/x/xerrors"
)
client := dynamodb.New(sess)
client.Handlers.Validate.AfterEachFn = func(item request.HandlerListRunItem) bool {
item.Request.Error = errors.New("simulated error")
return false
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论