What is the idomatic way to write a function signature of a function
that I want to have made available for remote access via the RPC
package (http://weekly.golang.org/pkg/net/rpc/) that has no input
and/or no output? There is no void, so I have been writing:
func (_ *Receiver) DoNothing (_ bool, _ *bool) error {
}
I picked bool because it has the least information of any primitive
type, but I don't think this is a particularly good reason. Would an
empty structure be more idiomatic? Is there something more like C's
void?
Thanks,
-Jeremy
I realize that I can write a function that simply takes no arguments.
My problem is that such a function would definitely not be available
for remote access through the rpc package
(http://weekly.golang.org/pkg/net/rpc/). It's looking for a fairly
specific function signature.
Kyle, thanks.. I think I will use:
func (_ *Receiver) DoNothing (_ *struct{}, _ *struct{}) error {
}
Strangely, I can get rid of both _'s, but if I need one argument to be
named and want the other to be unnamed, and omit the _, I get "mixed
named and unnamed function parameters". Perhaps there's some
ambiguous corner case that this rule avoids.
Thanks!
-Jeremy
Kyle, thanks.. I think I will use:
func (_ *Receiver) DoNothing (_ *struct{}, _ *struct{}) error {
}
Strangely, I can get rid of both _'s, but if I need one argument to be
named and want the other to be unnamed, and omit the _, I get "mixed
named and unnamed function parameters". Perhaps there's some
ambiguous corner case that this rule avoids.
-rob
func (*Receiver) DoNothing(_, _ *struct{}), error
Should the client code look like this?
h.Call("Receiver.DoNothing", struct{}{}, nil)
-Jeremy