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

Question about userdata interface{} argument to callback function #55

Open
ikandaswamy opened this issue Mar 8, 2017 · 1 comment
Open

Comments

@ikandaswamy
Copy link

Firstly, thank you very much for the go-curl package!
I have a question :
In my implementation, when I print out the user data field from the callback function that gets passed to WRITEFUNCTION, i get
{[] 0 [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 0}

What is it supposed to contain ?

The following is the code I use
// Callback function to save data instead of redirecting it into stdout.
	writeToBufferFunc := func(buf []byte, userdata interface{}) bool {
		if silent == false {
			b.Write([]byte(buf))
		}
		logging.Infof("\n\n %v \n\n ", userdata)
		return true
	}

	this.myCurl.Setopt(curl.OPT_WRITEFUNCTION, writeToBufferFunc)

	this.myCurl.Setopt(curl.OPT_WRITEDATA, b)

	if err := this.myCurl.Perform(); err != nil {
		if show_error == true {
			return nil, err
		} else {
			return nil, nil
		}
	}
@andelf
Copy link
Owner

andelf commented Mar 21, 2017

use (userdata).([]byte) ?

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

2 participants