Search
×
press ESC to close

Day 14 of 100

progress

  • Migrated my new aws lambda logger from zap to zerolog. Zap gave me some problems initially so zerolog is my favorite structured logger right now, much simpler.
  • Constructed go-task runner file for launching go test and go build/run.
  • Structured logging required a little bit of refactor but worked.

Here’s an example of providing back a logged string (don’t log secrets normally, but I’m in testing phase) with structure.

	log.Debug().
		Str("decodedBinarySecret", decodedBinarySecret).
		Str("secretString", secretString).
		Msg("Depending on whether the secret is a string or binary, one of these fields will be populated.")

Based on my improved understanding of conversions vs type assertions, the need to convert using a “cast” (Go calls these conversions, and yes it makes a copy in memory for this):

log.Info().Str("requestDump", string(requestDump)).Msg("request information")

Type assertions are done when working with an interface. I’m still working on my understanding of interfaces as they are their own beast in Go. Unlike most other languages, a Go type implements an interface when all the required methods are matched. This provides a great deal of the flexibility in Go interfaces.

The scoping of the interfaces is important, and while I listened to a lecture on this, I didn’t yet work through the interface design principles to ensure the best resusability/narrowness of scope concepts. I think that’s going to take more “getting my hands dirty” for it to click.

tech development 100-days-of-code 100DaysOfCode golang