github - GO script runtime error for Amazon AWS S3 -
i'm attempting run following golang build first time on amazon linux distro:
https://github.com/adammck/s3-graphite
readme here:
go github.com/adammck/s3-graphite cd $gopath/adammck/s3-graphite go build
after this, set variables in .bashrc file below:
# aws keys read access bucket export aws_access_key_id=xxxxxxxxxx export aws_secret_access_key=yyyyyyyyyy export aws_region=us-east-1 # bucket watch export s3_bucket=my-bucket export s3_prefix=dir/subdir # server send metrics export graphite_address=metrics.example.com export graphite_prefix=s3-count.my-bucket.dir.subdir
i set gopath following:
export gopath="$home/work/"
i cd dir run go build works should, when go run following after go build:
./s3-graphite
i following error:
info[0000] starting s3-graphite... panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x20 pc=0x4e3256] goroutine 1 [running]: github.com/aws/aws-sdk-go/service/s3.new(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f) /home/ec2-user/work/src/github.com/aws/aws-sdk-go/service/s3/service.go:41 +0x76 main.news3(0x7ffc202bef6e, 0x1b, 0x7ffc202be684, 0x9, 0x1, 0x0, 0x0) /home/ec2-user/work/src/github.com/adammck/s3-graphite/s3.go:20 +0x66 main.main() /home/ec2-user/work/src/github.com/adammck/s3-graphite/main.go:19 +0x21c goroutine 2 [runnable]: runtime.forcegchelper() /usr/lib/golang/src/runtime/proc.go:90 runtime.goexit() /usr/lib/golang/src/runtime/asm_amd64.s:2232 +0x1 goroutine 3 [runnable]: runtime.bgsweep() /usr/lib/golang/src/runtime/mgc0.go:82 runtime.goexit() /usr/lib/golang/src/runtime/asm_amd64.s:2232 +0x1 goroutine 4 [runnable]: runtime.runfinq() /usr/lib/golang/src/runtime/malloc.go:712 runtime.goexit() /usr/lib/golang/src/runtime/asm_amd64.s:2232 +0x1
here gopath:
$gopath -bash: /home/ec2-user/work/: directory
here dir execute s3-graphite:
/home/ec2-user/work/src/github.com/adammck/s3-graphite
edit (updated items answer:
[ec2-user@s3-graphite]$ go version go version go1.6.3 linux/amd64 [ec2-user@ s3-graphite]$ $gopath -bash: /home/ec2-user/work: directory [ec2-user@ s3-graphite]$ pwd /home/ec2-user/work/src/github.com/adammck/s3-graphite [ec2-user@ s3-graphite]$ ./s3-graphite info[0000] starting s3-graphite... panic: runtime error: invalid memory address or nil pointer dereference [signal 0xb code=0x1 addr=0x20 pc=0x512aa2] goroutine 1 [running]: panic(0x873120, 0xc82000a0e0) /usr/local/go/src/runtime/panic.go:481 +0x3e6 github.com/aws/aws-sdk-go/service/s3.new(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f) /home/ec2-user/work/src/github.com/aws/aws-sdk-go/service/s3/service.go:41 +0x72 main.news3(0xc82001603a, 0x1b, 0xc82000e06a, 0x9, 0x1, 0x0, 0x0) /home/ec2-user/work/src/github.com/adammck/s3-graphite/s3.go:20 +0x4a main.main() /home/ec2-user/work/src/github.com/adammck/s3-graphite/main.go:19 +0x229 [ec2-user@ s3-graphite]$
there seem few things going on here. 1 thing check sourcing .bashrc file after set environment variables in there. should able run env
command , see aws keys, s3 configuration, , graphite settings in current shell.
the second problem see library using hasn't been updated since last year. far know aws sdk go has changed lot in past year. "panic:" line in application's output gives hint @ problem.
panic: runtime error: invalid memory address or nil pointer dereference
it seems nil
being passed somewhere not supposed be. further down panic output can see stacktrace goroutine 1 says:
github.com/aws/aws-sdk-go/service/s3.new(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f) /home/ec2-user/work/src/github.com/aws/aws-sdk-go/service/s3/service.go:41 +0x76 main.news3(0x7ffc202bef6e, 0x1b, 0x7ffc202be684, 0x9, 0x1, 0x0, 0x0) /home/ec2-user/work/src/github.com/adammck/s3-graphite/s3.go:20 +0x66
from can see news3 method being called on line 20 of s3.go file in s3-graphite library. goes aws-sdk-go library , tries create new s3 client. following arguments:
s3.new(0x0, 0x0, 0x0, 0x0, 0x0, 0x3f)
my best guy configuration not exported environment running executable in, or s3-graphite library needs updated work latest aws-sdk-go version.
Comments
Post a Comment