Using Reflection in Go to assign a Value to a Property of a Struct Contained in a Map

Clock tower reflecting on the water; St. Michaelis, Hamburg, Germany

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 …

Adding Delegation to PHP

Rube Goldberg Machine

In summary I am proposing the PHP leverage the use statement like the PHP trait does, but with a class modifier to allow for automatic delegation of method calls to contained instances.

Also I am proposing we leverage the disambiguation syntax that is already available for traits, and extend it in a few ways that traits do not address such as:

  1. Use as to allow for renaming from the property names for delegate classes,
  2. Add include or exclude to allow including or excluding specific methods, and
  3. Add use method to allow for including specific methods.

How to explicitly declare that a struct implements an interface in Go

rules to follow

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 …

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.

GoLang Strict Typing and Interface Slices


Photo by Louise Lyshøj on Unsplash This is a GoLang Experience Report. …but you cannot define the rows parameter as type []RowInserter because []interface{} won’t match it, even though RowInserter is itself an interface. Background I am relatively new to programming Go, but I have been developing software professionally in a variety of programming languages …