I want to second what Ozan has said, use *sftp.Client not sftp.Client, but
I want to throw out a couple of words about that.
First, the documentation specifically warns against copying Mutex. So you
need to be fairly certain that no mutexes are used in a struct before
using value semantics. Anything that mentions it is using concurrency or is
safe to use under concurrency is likely to be using mutexes, so probably
needs pointer semantics.
Second, I want to recommend that in looking at the documentation, you pay
particular attention to the method signatures, and especially the receiver.
If in the documentation of a struct all the methods have a pointer
receiver; i.e. they look like:
func (c *Client) Close() error
^^^
having the * in front of the class name, this is a good indication that you
need to pass it around yourself in that way. If they all look like:
func (c Client) Close() error
without the *, then you are pretty safe to pass it around as a value, since
all the method calls are going to be doing that anyway.
Finally, if the documentation includes a New{Struct} function, pay
attention to the return type - if it returns a pointer, pass it around as a
pointer. If it returns a value, then you can probably leave it as a value.
Good luck!
Howard
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/d90b8913-49c3-4f9d-8277-25dff1b0eed5n%40googlegroups.com.