forked from benbpyle/go-parquet-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
55 lines (47 loc) · 1.13 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"context"
"os"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
log "github.com/sirupsen/logrus"
)
var sess *session.Session
var bucket string
var key string
func init() {
sess, _ = session.NewSession(&aws.Config{
Region: aws.String("us-west-2"),
Credentials: credentials.NewSharedCredentials("", os.Getenv("AWS_PROFILE")),
})
log.SetFormatter(&log.JSONFormatter{PrettyPrint: true})
log.SetLevel(log.DebugLevel)
bucket = os.Getenv("SAMPLE_BUCKET")
key = os.Getenv("SAMPLE_KEY")
}
func main() {
file, err := DownloadFile(context.TODO(), sess, bucket, key)
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Error("error downloading the file")
}
contents, err := ParseFile(file)
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Error("error parsing the file")
}
err = DeleteFile(file)
if err != nil {
log.WithFields(log.Fields{
"err": err,
}).Error("error deleting the file")
}
for _, c := range contents {
log.WithFields(log.Fields{
"record": c,
}).Debug("printing the record")
}
}