Sheldon Hull

Sheldon Hull

  • _________________________________
  • < Welcome! Thanks for stopping by >
  •  ---------------------------------
  •  \
  •   \
  •      __
  •     /  \
  •     |  |
  •     @  @
  •     |  |
  •     || |/
  •     || ||
  •     |\_/|
  •     \___/

Here you’ll find mostly tech talk and musings, with other topics periodically. If you want to stay in touch, look at the bottom for the curated newsletter I send out.

Cheers! ๐Ÿ™๐Ÿป

Go R1 Day 35

progress Worked with Taskflow a bit more. Need to identify better error handling pattern on when to resolve vs handle internal to a function, as it feels like I’m doing needless error checking. Wrote func to run terraform init, plan, and apply. This takes dynamical inputs for vars and backend file. Also dynamically switches terraform versions by running tfswitch. Definitely more verbose code than powershell, but it’s a good way to get used to Go while achieving some useful automation tasks I need to do.

Go R1 Day 34

progress figured out how to import util/logger.go as a package after much confusion due to logger, log, *zerolog.Logger and more variables all deviously similar in name… how to pass around the initialized package logger that I configure. learned that global scope and package scoped loggers being initialized at run is concerned an anti-pattern properly wrapping to avoid the log initialization on import with type Logger struct { logger: *zerolog.Logger; } as an example avoids the same behavior as: var Log *zerolog.

Go R1 Day 33

progress successfully created logging package using zerolog learned about scoping with packages linked to a private internal repository and how to leverage the module replace operator to temporarily alter path import from url to local override. middleware is a newer concept, so I need to learn more on this later so I can understand how to use to inject special log handling for http requests and other actions. Thoughts for today are that the pressure of jumping into an existing codebase is resulting in me moving faster than I probably should.

Go R1 Day 31

progress Learned a bit about idiomatic patterns wtih error handling. Learned about inline block intiailization of variables using if err := method(); err != nil {...} approach. Considered a bit more idiomatic patterns when I noticed excessibe nested if blocks. 1 2 3 4 5 6 tfdir := tf.Params().String("tfdir") if tfdir != "" { tf.Logf("tfdir set to: [%s]", tfdir) } else { tf.Errorf("๐Ÿงช failed to get tfdir parameter: [%v]", tfdir) } This would probably be more in alignment with Go standards by writing as:

Go R1 Day 30

progress Built some go functions for build tasks work with terraform and setup of projects using taskflow. Learned one one to pass in arguments using slices. I’m pretty sure you can use some stringbuilder type functionality to get similar behavior, but this worked fine for my use case. 1 2 3 4 5 6 7 8 9 10 11 cmdParams := []string{} cmdParams = append(cmdParams, "-chdir="+tfdir) cmdParams = append(cmdParams, "init") cmdParams = append(cmdParams, "-input=false") cmdParams = append(cmdParams, "-backend=true") cmdParams = append(cmdParams, "-backend-config="+tfconfig) terraformCmd := tf.