$ ❯ CrowderSoup

A website about programming, technology, and life.

go

Day 10: Dependency Injection

by Aaron Crowder on in Programming

What is it? Dependency Injection is a design pattern whereby an object/module’s dependencies are provided to it. It is one of several techniques for implementing Inversion of Control. So rather than: func NewClient() *Client { return &Client{ Service: service.NewService(), } } You would have: func NewClient(service *service.Service) *Client { return &Client{ Service: service, } } Why tho?? If you wanted to write a test for the Client first example above, you wouldn’t be able to mock it’s Service.

Read more...

Moving to Hugo

by Aaron Crowder on in Site Updates

Last night I got the wild hare to migrate my personal site from Pelican to Hugo. I’ve been meaning to do it for a while now, so to give myself the push I needed to get it done I deleted my old personal site from Github. Differences Front Matter Honestly the biggest different for content is “front matter”. Both Hugo and Pelican, as static site generators, use front matter to describe pieces of content.

Read more...