<!doctype html><metacharset=utf-8><metaname=viewportcontent="width=device-width,initial-scale=1"><linkrel=preconnecthref=https://fonts.googleapis.com><linkrel=preconnecthref=https://fonts.gstatic.comcrossorigin><linkhref="https://fonts.googleapis.com/css2?family=Recursive:wght,CASL,MONO@300..800,0..1,0..1&display=swap"rel=stylesheet><linkhref=https://haunt98.github.io/iosevka_webfont/iosevka-term-ss08/iosevka-term-ss08.cssrel=stylesheet><linkrel=stylesheethref=styles.css><ahref=index>Index</a><h1>Experiment Go</h1><p>There come a time when you need to experiment new things, new style, new approach.<br>So this post serves as it is named.<h1>Design API by trimming down the interface/struct or whatever</h1><p>Instead of:<pre><codeclass=language-go>type Client interface {
</code></pre><p>The difference is <code>c.GetUser()</code> -> <code>c.User.Get()</code>.<p>For example we have client which connect to bank.<br>There are many functions like <code>GetUser</code>, <code>GetTransaction</code>, <code>VerifyAccount</code>, ...<br>So split big client to many children, each child handle single aspect, like user or transaction.<p>My concert is we replace an interface with a struct which contains multiple interfaces aka children.<br>I don't know if this is the right call.<p>This pattern is used by <ahref=https://github.com/google/go-github>google/go-github</a>.<h2>Find alternative to <ahref=https://github.com/grpc/grpc-go>grpc/grpc-go</a></h2><p>Why?<br><ahref="https://github.com/grpc/grpc-go/issues?q=is%3Aissue+compatibility+is%3Aclosed">See for yourself</a><p>Currently there are 2:<ul><li><ahref=https://github.com/bufbuild/connect-go>bufbuild/connect-go</a>. Comming from buf, trust worthy but need time to make it match feature parity with grpc-go.<li><ahref=https://github.com/twitchtv/twirp>twitchtv/twirp</a></ul><h1>Thanks</h1><ul><li><ahref=https://blog.gopheracademy.com/advent-2019/api-clients-humans/>API Clients for Humans</a></ul><ahref=mailto:hauvipapro+posts@gmail.com>Feel free to ask me via email</a>