Solution 2: Telling a UNIX System What to Do
Let’s solve the challenge set in the previous lesson.
We'll cover the following...
Solution
Here’s the code for JSONstreams.go
, which accepts user data or data from a file.
[ { "key": "ABCD", "value": 10 }, { "key": "EFGH", "value": 20 }, { "key": "IJKL", "value": 30 }]
JSONstreams.go
Code explanation
Lines 11–14: This line declares a
Data
struct type with two fields:Key
andVal
. Thejson
struct tag specifies the mapping between ...