Search Results

7 results

Go: Improving Example Visibility in pkgsite (pkg.go.dev) | matttproud.com (blog)

09 Sep 2025

https://matttproud.com/blog/posts/go-pkgsite-examples.html

Today, a small UI improvement I made to Go’s pkgsite tool was deployed to production. pkgsite is the tool that can be run locally to serve documentation, and it’s also the binary that serves http://pkg.go.dev. The Change This change may seem a bit mundane at first, but ultimately it is part of a larger narrative in building user empathy — empathy toward your fellow developers. So, without further ado, let’s introduce the change.

Go: Package-Centric Organization | matttproud.com (blog)

18 Aug 2025

https://matttproud.com/blog/posts/go-package-centricity.html

Organizing source code is a critical skill in software mastery, and this remains true in Go. Unfortunately the skill of idiomatic organization in one language does not necessarily translate to another. What makes this trickier is that code organization happens at several levels: the build system the packaging system in code in the file system To understand why, consider this Unified Modeling Language (UML) diagram of these levels and their relationships when using Go:

Golden File Testing | matttproud.com (blog)

28 May 2025

https://matttproud.com/blog/posts/golden-file-testing.html

Today, driven by annoyance, I refactor-extracted a small set of test helper code found in various private personal projects around the topic of golden file management into a dedicated Go module: github.com/matttproud/goldentest (API documentation). I’m happy to finally have a canonical solution that I am happy with. I’ll freely admit it: I use change detector tests1 for some things, as a slew of these personal projects use reference data defined in the testdata directory as canonical want values...

Elegant Configuration APIs and Command Line Flags | matttproud.com (blog)

27 Apr 2025

https://matttproud.com/blog/posts/flags-and-structs.html

I’d like to share a design pattern with Go that I really find particularly elegant. It orients itself around hermetic, testable configuration using command line flags. But before I do, I need to put three questions to you since they determine if you need to do some pre-reading in advance. If you are familiar with package flag, are you aware of the Var-suffixed flag creation API variants (e.g., flag.BoolVar to complement flag.Bool)? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // https://cs.opensource.google...

Go: Debugging Individual Table Tests | matttproud.com (blog)

04 Apr 2025

https://matttproud.com/blog/posts/debugging-go-table-tests.html

Suppose one day you receive a bug report about your code (func Encode) and want to build a test to verify the fix or recreate the problem. You might have defined your code’s tests in a table-driven format, similar to below: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 import ( "testing" "github.com/google/go-cmp/cmp" ) func TestEncode(t *testing.T) { for _, test := range []struct { name string input string output string err error }{ // 33 { ... } rows omitted ...

Go: How the Testing Harness Works | matttproud.com (blog)

15 Aug 2024

https://matttproud.com/blog/posts/go-testing-harness.html

This is a smaller piece that I broke off from a larger article. It’s in the space of Go minutiae, but it’s worth considering if you plan on developing full mastery of the language ecosystem. So let’s start out with a question: what happens when you run go test? Very specifically in the time between when the go tool starts running and before your tests start running? If you’re like most people, I’ll wager you haven’t given it much thought; but it turns out there is a lot going on!

Plain Old Data in Go: POGS | matttproud.com (blog)

17 Jan 2024

https://matttproud.com/blog/posts/plain-old-data-in-go-pogs.html

I’ve found myself reaching for a set of terms with increasing frequency in recent years when writing technical documentation and providing design feedback. The problem revolves around this: what is Plain Old Data (POD) in Go, and what do you call it in the Go context? A Quick Dive into PODs To answer this, let’s consider what a POD typically is: It’s a collection of data. That collection can be thought of as a record. The data in that record is typically immutable (set once). Whether the type th...

Filters
Category
Domain
In web feed
Language