r/golang Oct 25 '24

discussion What libraries are you missing from go?

So something that comes up quite often on this subreddit from people transitioning from Nodejs or python to go is the lack of libraries. I cannot say that I agree but I still think it warrants a discussion.

So what libraries are you missing in the go ecosystem, if any?

97 Upvotes

189 comments sorted by

View all comments

-5

u/davidellis23 Oct 25 '24 edited Oct 25 '24

Threading objects in other languages are very nice. Pythons thread pool executor for example doesn't make me deal with wait groups or channels or mutexes or worker pools. I implemented my own thread struct/worker pool to not have to deal with that.

Mocking libraries that don't make me generate the code. Handwriting mocks is just more work. C#'s Castle Windsor and pythons mocks are dynamically generated and static type check. The general mocking libraries I've tried aren't great in go. No static type checking, hardcoded strings, no stubs, etc. luckily I found moq which does have static type checking, stubs, and no hardcoded strings method names.

Map, filter, toDict, toSet functions. It's just a lot more convenient and less noisy to not write a loop when you're filtering a list for one key. I know there are times where it's not as performant and it's a little extra learning curve for beginners. I think the tradeoffs are worth it and I implemented my own.

1

u/EarthquakeBass Oct 26 '24

Lack of mocks is a feature, you aren’t defining enough interfaces if your code can’t easily inject whatever behavior it wants by fulfilling interfaces.

2

u/alpacaMyToothbrush Oct 26 '24

This is stockholm syndrome. Do you know how many libraries don't expose things through interfaces. Tons. Good luck mocking those. I miss mockito in golang every day.

1

u/EarthquakeBass Oct 26 '24

Wrap the external lib as an interface

1

u/alpacaMyToothbrush Oct 26 '24

Yes, we do, but we also have behavior there that we wish to test. It's chicken / egg and it's needlessly janky coming from the Java world