I’ve heard it’s never too late to learn a new language.  For spoken languages I’m not sure I agree, but for programming languages – of course!  The Go programming language started at Google in 2009, so I figured it’s about time I dug in with the Gopher.  Go is “almost” systems level, but it does have garbage collection, so language purists may dismiss it as a systems level language just based on that.  But with today’s processors, there’s a strong argument that Go can be a very successful all-purpose language.  I guess I was feeling retrospective after meeting Charles Petzold recently and thinking about how much C programming I did in the 90s.  His seminal, Programming Windows, was my daily bible study.  So, I thought, well I’m not going back to C after over a decade with C#, but let’s give Go a try!
I checked out the documentation, took an online course, and I was go for Go. One of my colleagues, Darren Warner, had a recent devops task to connect to BitBucket’s API, iterate through the repos, and return status and information on any open Pull Requests. He wrote it Python – and it was a perfect porting candidate for diving into Go.
I broke out Visual Studio Code (AKA Visual Studio Ultralight), and coded away. My goal was for it to be as pure-native Go as possible, so I only used built-in Go standard library packages – no 3rd party add-ons. I found the HTTP package to be great, works as it should – light, nice and async. The JSON handling via maps are a bit verbose, and I’m sure I could re-factor some of that using any of the 3rd party JSON marshalling packages available, but again, I wanted to keep it as native and fast as possible. I used proper error handling and create new err on every possible fail condition.
To run, simply:
> go run pullrequests.go --ownername="bitbucket-repo-owner-username" --username="my-bitbucket-username" --password="my-bitbucket-password"
Check out the complete code on GitHub or BitBucket!
Brett Morrison – Official Site
Links
- Brett @ Facebook
 - Brett @ Flickr
 - Brett @ Github
 - Brett @ IMDB
 - Brett @ Keybase
 - Brett @ LinkedIn
 - Brett @ Nostr
 - Brett @ X
 - Brett via Google
 
Archives
- November 2022 (1)
 - December 2020 (1)
 - August 2020 (1)
 - March 2020 (1)
 - August 2018 (1)
 - March 2018 (1)
 - May 2016 (1)
 - July 2015 (1)
 - June 2015 (1)
 - March 2014 (1)
 - August 2013 (1)
 - February 2013 (1)
 - November 2012 (1)
 - September 2012 (1)
 - July 2012 (1)
 - October 2011 (1)
 - March 2011 (1)
 - January 2011 (2)
 - December 2010 (1)
 - April 2010 (1)
 

				
		
		
		