anaconda icon indicating copy to clipboard operation
anaconda copied to clipboard

Calling api.SetDelay() as mentioned in readme panics

Open ahmetb opened this issue 8 years ago • 2 comments

If you do this:

image

You get the panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x11cd32]

goroutine 1 [running]:
panic(0x24a620, 0xc42000c0d0)
	/usr/local/Cellar/go/1.7.4/libexec/src/runtime/panic.go:500 +0x1a1
github.com/ahmetalpbalkan/goodbye/vendor/github.com/ChimeraCoder/tokenbucket.(*Bucket).SetRate(0x0, 0x0)
	/Users/alp/workspace/gopath-goodbye/src/github.com/ahmetalpbalkan/goodbye/vendor/github.com/ChimeraCoder/tokenbucket/tokenbucket.go:41 +0x22
github.com/ahmetalpbalkan/goodbye/vendor/github.com/ChimeraCoder/anaconda.(*TwitterApi).SetDelay(0xc420012780, 0x0)
	/Users/alp/workspace/gopath-goodbye/src/github.com/ahmetalpbalkan/goodbye/vendor/github.com/ChimeraCoder/anaconda/twitter.go:156 +0x39
main.mkClient(0xc4200ca9e0, 0x15, 0xc420019020, 0x2b, 0xc420010700, 0x31, 0xc420019050, 0x2a, 0xc420019050, 0x2a, ...)
	/Users/alp/workspace/gopath-goodbye/src/github.com/ahmetalpbalkan/goodbye/main.go:89 +0xe4
main.main()
	/Users/alp/workspace/gopath-goodbye/src/github.com/ahmetalpbalkan/goodbye/main.go:36 +0x3ac

because api.bucket field is nil.

ahmetb avatar Dec 14 '16 03:12 ahmetb

I had a similar issue, but I found a fix

It looks like you have to call api.EnableThrottling() first, then you're able to call api.SetDelay().

The README section on throttling notes that throttling is off by default, but it would be nice to have a nice one-liner that tells the user how to enable Throttling (and explain a little more about the bufferSize argument in the EnableThrottling() function call)

migreva avatar Jan 10 '17 21:01 migreva

+1, four years later I'm getting the same issue.

alexellis avatar Apr 05 '20 17:04 alexellis