This solution had me literally working on-again off-again for a full week. One of the main reasons it took so long was I was trying to write a wrapper to simplify because I find the reflect package in Go so unintuitive and hard-to-work-with. But it turns out that trying to write a wrapper around an …
A better alternative to “return early” – PHP / WordPress edition
Yes, complex conditionals are worse. But there is a third, better way. And no, it does not involve GOTOs. Me This post is about a coding pattern I have never seen used by anyone else for writing guard clauses, especially when those guard clauses are complex. This pattern results in code that is significantly more …
Continue reading “A better alternative to “return early” – PHP / WordPress edition”
Pros and cons of leveraging Go types
UPDATE: Since writing these over 3 years ago I have since learned a lot more about GoLang and its type system. Ironically, I now realize that GoLang has type aliases that are effectively what I was lobbying for. ORIGINAL POST: Go is a great language — probably one of the best — but it is …
On Typing Strings in Go
UPDATE: Since writing these over 3 years ago I have since learned a lot more about GoLang and its type system. As such I now realize that GoLang has type aliases to address the need that I was writing an experience report about. ORIGINAL POST: One of the niftier aspects of programming in Go is …
How to explicitly declare that a struct implements an interface in Go
One of the things I love about Go and find to be a strong supporter of serendipitous interface standardization is Go’s implicitly declared interfaces. However, there are times you really, really want to explicitly declare an interface, such as when you have a larger interface and you want your IDE and/or the compiler to tell …
Continue reading “How to explicitly declare that a struct implements an interface in Go”
How to specify a zeroed UUID in MySQL
Photo by Chris Barbalis on Unsplash Working on a recent project that dealt with data synchronization across disparate systems, I realized I could not use the oh-so-easy INT for primary keys. Instead I chose to use the emerging best practice of employing UUIDs for distributed databases. However, the library functions in Go are not friendly …
PHP delegation vs. GoLang type embedding
PHP implements composition (vs. inheritance) of object class properties and methods to other classes using delegation. Go on the other hand implements composition with type embedding. Read this post to learn about the differences and to appreciate the benefits of Go’s approach compared to that of PHP.