2018-03-15 14:53
浏览 50


I have a function which returns an io.Reader:

func getData(bucket string, key string) (io.Reader, error) {
  svc := s3.New(cfg)

  req := svc.GetObjectRequest(&s3.GetObjectInput{
    Bucket: aws.String(bucket),
    Key:    aws.String(key),

  res, err := req.Send()
  if err != nil {
    // How to return a empty io.Reader here?
    return bytes.NewReader([]byte), err
  return res.Body, nil

And I would like to know, how to return a empty io.Reader from the err block.

Thank you.

1条回答 默认 最新

相关推荐 更多相似问题