How to do it...

These steps cover writing and running your application:

  1. From your terminal/console application, create and navigate to the chapter3/tags directory .
  2. 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.
  3. 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 ...

Get Go Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.