Golang Closures For Configuration

August 25, 2019

One common code smell is creating functions with a long list of parameters. Adding a new function usually starts out optimistically with a few inputs or known state that is needed. Over time you start adding more state and extending functionality of existing code and quickly it turns into something that is no longer maintainable or causes issues of other places in the codebase needed a larger list of dependencies and state to call these codepaths. Let’s look at one approach you can take with golang. ... Read more

Serverless Events with Existing S3 Bucket

August 12, 2019

Serverless helps you with functions as a service across multiple providers. Using serverless with AWS allows you to tie these functions into your AWS infrastructure, or tie it into existing resources. Previously you couldn’t use existing S3 buckets for serverless lambda events. Today I learned that you can now use existing buckets. ... Read more

Golang Debug Bytes

August 2, 2019

When working with raw bytes in Golang it can be a little difficult to debug. If you are new to the language or just want to quickly check some data as a human readable text blob it is useful to have a technique for doing this. ... Read more

Terraform CI/CD

July 29, 2019

Terraform helps in creating cross-cloud immutable infrastructure with code. As with most code there is an ideal of having your codebase automated with tests and deploys. How can this work with terraform? Does it work in a sensible way to give you confidence in your changes and how they ultimately get applied? Trying to answer these questions led to the following approach that I’ve used to attempt to try having a CI/CD solution for a terrorm codebase. ... Read more

Golang Printing Tabstopped Text into Aligned Columns

May 5, 2019

One of the strengths of Golang as a language is it has a pretty strong standard library of packages out of the box. Things like the httptest package and even the http package is strong enough that there are countless http servers open sourced built on top of it. One of the hidden convenient packages I’ve used is the tabwriter to help print out tabstopped text into aligned text. ... Read more

Bash Say Command In CI

April 8, 2019

Sometimes you just need to say it from a bash script and some times your CI provider won’t be OK with that. Today I learned of one such provider, CircleCI who didn’t want to play nicely with using say ... Read more

Golang Testing time.Now

April 1, 2019

Testing time objects can be a pain. Some languages offer some helpful libraries that can help like VCR in Ruby. Other tools to help are mocking libraries to where you can mock and stub out the time calls to what you want. In golang there is another way to help and that is using dependency injection to help make testing easier. ... Read more

Momentjs Date Mutation

March 14, 2019

If you’ve ever had to work with a lot of date logic in javascript you’ve likely used or at least seen Momentjs. It can be convenient for moving dates to other timezones or date math. I ran into another today I learned moment trying to write some tests in Jest while using moment to handle dates in test setup and fixtures. ... Read more

Ruby 2.6 Endless Range

March 8, 2019

For a today I learned moment I ran into the new endless range feature in ruby 2.6 by coming across some code that triggered this error message: RangeError (cannot get the last element of endless range) The code that was updated to the latest ruby 2.6 release had a dynamic range that was pulling fields from a database and doing something like this: ... Read more

Terraform Conditionals

June 17, 2018

Terraform is a very versatile tool to help automate your infrastructure and codify your infrastructure as code. With a large open source community and tons of providers across multiple cloud platforms it allows developers to create plans for spinning up infrastructure effortlessly. One thing I ran into that needed a little more effort was adding conditional steps to a configuration plan. Due to the complex nature of Terraform and how it attempts to plan out how it will execute your configuration it is a little more involved to get conditionals working. ... Read more

mtchavez All rights reserved.