I recent starting using mastodon as my primary means of social media. After researching ActivityPub and looking into other technical aspects i became really interested in the Fediverse and the different types of data available. I wrote a simple GoLang program as an exercise and to check out the state of development for the platform. I’ve previously wrote simple python data harvesters for for twitter but due to its current ownership situation I don’t believe I’ll be doing much work on it any time soon. I also gravitated to mastodon because is open source. This simple program outputs 3 lists, a mastodon account’s Followers, Following, and Mutuals. if you want to learn about some of my pit falls and what i learned you can visit the github repo or keep reading.

Who might uses this short program?
Anyone interested in social media or data. This program outputs an accounts Followers, Following, and Mutuals. These lists are just the tip of available data that can be used for any sort of social media analytics.
What did I learn about mastodon/goLang from writing this short program?
Mastodon and the fediverse are extremely customizable allowing users to fully curate their feeds and experiences. One of the pillars of the federated social space is that the user controls their data. they can delete it or move to a different server. Want a different timeline layout or algorithm? Just download one of many different clients with different styles.
I’ve written a few GoLang programs before but not in the last year or so. I know programming languages change so I was interested to see what’s new. When I first started writing GoLang there was no notion of context
and file directories also had fewer automatically generated support files.
What problem or challenge was I trying to solve?
I wanted to see what was new or different when writing a basic GoLang program. I also wanted to learn more about mastodon and the fediverse. During the development of the program i ran into various issues that required me to read the source code for the go-mastodon repository hosted on github and the mastodon api docs.
What tools, frameworks, or technologies did I use — and why?
I wanted to do a simple review of Mastodon, the go-mastodon (golang client), and the Go Programming Language (go version go1.19.8 linux/amd64). You might find this sample code and write up useful if your using any of these.
What obstacles or unexpected issues came up during the project?
A big gotchas with go-mastodon I ran into was figuring out how to get the full set of lists. where the defaults only return at most 80 and was impossible (to my knowledge) to turn the page via its built in pagination.
What solutions, workarounds, or best practices did I discover?
I figured out that mastodon servers also return json responses. The correct pagination was available in the https request header response. I have no specific go-mastodon tips other then you might need to manually touch the mastodon api sometimes.

If I had to do this project again, what would I do differently?
Maybe next time I’ll work directly with the mastodon json responses? I’m not convinced that i even needed the go-mastodon client in this code. Both my code and the go-mastodon client accesses the mastodon api, Ideally all mastodon related stuff should have went though the go-mastodon client to touch the api.
What did I learn that would help others facing similar projects?
Every software developer will give you the same advice: “docs, read them often and early”. The official docs for mastodon give me my eureka moment this time but whenever I got stuck i reviewed the docs or read the source for go-mastodon. It not only helps you understand the step your taking to debug but it also immerses you in the code to help you understand how the parts work together.
Are there any reusable templates, code snippets, or techniques worth sharing?
This project is a great set of sample code on how-to work with go-mastodon. In the original published version of this code I made minimum effort to be efficient or write super clean code, comments, and appropriate variable names, I just hacked away. I might clean some things up as time goes by, check git. Pay attention to how the following/follower lists are returned.
How does this project fit into broader industry trends or best practices?
The social media landscape is changing. the fediverse will have a ton of new opportunities for collecting meaningful bits of data to help grow your audience or brand. With the old walled gardens of social media coming down knowing how to analyze data on the fediverse (or any other social media network) could be beneficial for things such as pr, business analytics, or customer service. Best practices suggest keeping an eye on any thing that can effect socials.
What resources (articles, videos, libraries) helped me the most?
Here some some of the links and docs I used.
Mastodon Docs
Mastodon Wiki
GoLang Docs
GoLang Wiki
go-mastodon on github
What’s the next step or future plan for this project (or similar ones)?
What’s Next? Working with the go-mastodon package, any number of social media data projects and automation can be done. Auto Unfollow, Add to List, Etc…
I’ll also be updating/improving the code and comments if need, please refer to the git comments to review changes. You can ask questions on this page or on the git repo.
What would you have done differently? Drop your ideas in the comments!