- From your Terminal/console application,createa new directory called~/projects/go-programming-cookbook/chapter4/context and navigate to this directory.
- Run the following command:
This recipe will demonstrate a way to pass log fields between various functions. The Go pkg/context package is an excellent way to pass additional variables and cancellations between functions. This recipe will explore using this functionality to distribute variables between functions for logging purposes.
This style can be adapted to logrus or apex from the previous recipe. We'll use apex for this recipe.
How to do it...
These steps cover the writing and running of your application:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook-Second-Edition/chapter4/context
You should see a file calledgo.modthat contains the following:
module github.com/PacktPublishing...