🐹 Published my first Go Package - xjoin
Due to a requirement to share one of my Python scripts with a coworker, I've been trying to teach myself some basics with the Go programming language so that I could easily share an executable file without dragging them through installing Python and virtual environments. I've got a draft in the works to summarize what that experience has been like for that first project. One of the things that seems to be way easier in Go is packaging! In a few hours split between last evening and this morning, I was able to learn about a bunch of new data types, tests, and package publishing with Go.
After I finished that first project, I was hooked on this shiny new-to-me language and immediately came up with a second project idea. One of the first requirements of this project is to perform a Cartesian product on a few lists of items. Python gives you this out of the box with itertools.product(). With Go... not so much. I saw some packages out there that looked promising, but I didn't immediately understand their source code. That and wanting to have at least a little something published to show for my time with Go was a good enough excuse for me to write my own package.
So here it is, my Go Cartesian product function, "xjoin"1 published on go.pkg.dev.
A few things I learned:
- "Pick the right tool for the job" - Python is way better for data manipulation. Python's dynamic types and list comprehension syntax makes looping through data much easier.
- My Go implementation is much more explicit, it feels more granular than the equivalent function in Python. Excluding comments, my Go function has a little over 20 lines of code whereas the Python docs example is only 7.
- I'm much, MUCH faster developing things in Python than Go.
- Go packaging appears to be much more approachable than Python's.
-
"xjoin" was my 5 minute attempt to come up with something more Go-like than "CartesianProduct". It is an abbreviation for "cross join" which is a SQL command and synonym for Cartesian products. ↩