Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling api.SetDelay() as mentioned in readme panics #168

Open
ahmetb opened this issue Dec 14, 2016 · 2 comments
Open

Calling api.SetDelay() as mentioned in readme panics #168

ahmetb opened this issue Dec 14, 2016 · 2 comments

Comments

@ahmetb
Copy link

ahmetb commented Dec 14, 2016

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.

@migreva
Copy link

migreva commented Jan 10, 2017

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)

@alexellis
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants