aws s3将文件下载到struct golang中

This question already has an answer here:

I have a json file on AWS s3. I want to download them into a struct, not into a file. is this possible? or a way to delete the file after i put the data into a struct? i dont want extra files generated in my application.

I see the go example AWS s3 provides here

and reading the go aws s3 docs on the download func it writes to io.WriterAt is "io.writerAt" only can be a file type?

my problem is when i read S3 json files, and load my data into a struct, but it also ends up creating files in the application due to what i think io.writerAt must be a file type.

heres my code that reads in the AWS s3 json file, creates a file(which i dont want), and loads it into struct to pass along the rest of the code.

sess, _ := session.NewSession(&aws.Config{
    Region: aws.String(c.AwsLocation),
})
downloader := s3manager.NewDownloader(sess)

doc := "myfile.json" 

file, err := os.Create(doc) //PROBLEM creates file.
//todo err
defer file.Close()

numBytes, err := downloader.Download(file,
    &s3.GetObjectInput{
        Bucket: aws.String(c.AwsBucket),
        Key:    aws.String(doc),
    })
//todo err
fmt.Println("Downloaded", file.Name(), numBytes, "bytes")

//take data, and put in struct
byteValue, _ := ioutil.ReadAll(file)
var output myStruct
json.Unmarshal(byteValue, &output)
return output
</div>

It looks like golang does have a pickle equivalent so to speak, https://golang.org/pkg/encoding/gob/.

But I'd use JSON to do this if at all possible. You can unmarshal the json into your struct pretty easily (https://gist.github.com/dmikalova/5693142 for example). More importantly, by choosing a more generic storage format, you'll be able to read the files from any language and your data will be distinct from your in-application model, which is a very friendly approach for cloud or micro- services.