Closed andyleap closed 6 years ago
Thanks for pointing these (indeed egregious) errors out. I've now put in code that I've verified actually compiles.
It does now compile, but it still does not work, as the client and the server are using different ports, and you only print the response if the rpc returns an error....
Sheesh! This will be a lot better to keep up with when we have docs in a place that can get contributions from the outside world. Sorry for the runaround, but thank you for being diligent.
There are several code issues on the https://github.com/twitchtv/twirp/wiki page. While nothing is advertising those snippets as 100% perfect, it'd be nice to have the egregious errors fixed. Notably:
Server snippet:
the return values mix named and unnamed returns, which is unallowed. Consider removing the "hat" name.
Client snippet
The client created is targeting port 8000, where the server was put on port 8080.
The client is also doing reversed logic err check:
which should only print anything if an error was returned, which is almost assuredly the wrong thing to be doing here.
In addition, I'd consider changing
resp, err = client.Hello(
toresp, err := client.Hello(
, as there's nothing in this snippet creating resp or err, so it would seem cleaner this way