These steps cover writing and running your application:
- From your terminal/console application, create and navigate to the chapter3/tags directory .
- Copy tests from https://github.com/agtorre/go-cookbook/tree/master/chapter3/tags or use this as an exercise to write some of your own code.
- Create a file called serialize.go with the following contents:
package tags import "reflect" // SerializeStructStrings converts a struct // to our custom serialization format // it honors serialize struct tags for string types func SerializeStructStrings(s interface{}) (string, error) { result := "" // reflect the interface into // a type r := reflect.TypeOf(s) value := reflect.ValueOf(s) // if a pointer to a struct is passed // in, handle ...