-
Homemade CLI Tools
2021-12-13
Go is great! We all know that. I spend most of my coding time on the back-end of the services we build. For many years, before I moved to Go, I used to create my tools as a combinations of various scripting languages - not excluding PHP! Most of it was run by Bash that was executed as a cron job, systemd service or manually as a one-shot executable. I must say, Bash is not as bad as many seem to think.…
-
Embedding Types to Reuse Code with Less Noise
2020-04-30
My previous post was about one of the concurrency patterns that can be achieved with go. I immediately got some feedback on it, and this is where I will address one of them. You have seen the code reimplementing sync.WaitGroup to have a semaphore in it. type WaitGroup interface { Add(delta int) Done() Wait() } type SemaphoredWaitGroup struct { sem chan bool wg sync.WaitGroup } func (s *SemaphoredWaitGroup) Add(delta int) { s.…
-
Semaphored Wait Group
2020-04-29
One of the first things you might like to try when starting your journey with Go are the concurrency patterns. You will probably start using goroutines to run things “in the background”, and you will also get to know channels that allow for safe communication between the sub-processes. When you’ll want to spawn many goroutines, you will surely get to know WaitGroups to wait for them to finish. There will also be the defer statement which helps you to not forget to clean up after a function has finished running (and remember, deferred calls are executed in reverse order).…
-
Automated testing in a build pipeline
2020-04-14
A testing mindset with its' scripts would be incomplete if we did not put them to good use. Ideally, tests should be run every time we intend to share our code with anyone - be it our team or the whole world. It is a tech lead’s wet dream to work in an environment where every dev thoroughly tests their solutions. As this might be impossible, we can have the next best thing.…
-
Multiple tests run in bulk using Bash
2020-03-19
Having briefly explained what a test is we can come to an inevitable conclusion that having only a single test is never enough. We usually write a lot of them and it is useful to group them. Assuming that the tests we are using conform to the contract of returning proper exit statuses, the whole group can technically be treated like a single test. Let’s put them inside a tests.sh script:…
-
What is a test in software development?
2020-03-17
When joining a new project (and maybe even in a previously unknown programming language) we can get overwhelmed by the complexity of the test suites. Sometimes it can even be a nightmare to run them, not to mention understand what is going on. There are lots of levels the tests can be run on. Let’s start with the basics. Anything that checks if a requirement is met is a test. How do we apply this mindset in real life?…