I am trying to send a simple file to Firehose in Go and keep getting:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4015b7]
goroutine 1 [running]:
panic(0x8b9260, 0xc82000a0e0)
/usr/lib/go-1.6/src/runtime/panic.go:481 +0x3e6
main.main()
/home/ubuntu/go/src/github.com/user/proj/txtParser.go:68 +0x5b7
exit status 2
below is the small script
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/service/firehose"
"github.com/aws/aws-sdk-go/aws/session"
"io/ioutil"
"log"
)
func main() {
sess := session.Must(session.NewSession())
svc := firehose.New(sess)
firehoseData, err := ioutil.ReadFile("/tmp/adsDat1")
if err != nil {
log.Fatal(err)
}
var rec *firehose.Record
var recInput *firehose.PutRecordInput
rec.SetData(firehoseData)
recInput.SetDeliveryStreamName("test-ads-txt")
recInput.SetRecord(rec)
res, err1 := svc.PutRecord(recInput)
if err1 != nil {
log.Fatal(err1)
}
fmt.Println(res)
}
Any ideas on what is going on I am sure it is something quite simple but I have been staring at this for too long and can't seem to figure it out.