• Russ Cox's avatar
    reflect: support for struct tag use by multiple packages · 25733a94
    Russ Cox authored
    Each package using struct field tags assumes that
    it is the only package storing data in the tag.
    This CL adds support in package reflect for sharing
    tags between multiple packages.  In this scheme, the
    tags must be of the form
    
            key:"value" key2:"value2"
    
    (raw strings help when writing that tag in Go source).
    
    reflect.StructField's Tag field now has type StructTag
    (a string type), which has method Get(key string) string
    that returns the associated value.
    
    Clients of json and xml will need to be updated.
    Code that says
    
            type T struct {
                    X int "name"
            }
    
    should become
    
            type T struct {
                    X int `json:"name"`  // or `xml:"name"`
            }
    
    Use govet to identify struct tags that need to be changed
    to use the new syntax.
    
    R=r, r, dsymonds, bradfitz, kevlar, fvbommel, n13m3y3r
    CC=golang-dev
    https://golang.org/cl/4645069
    25733a94
codewalk.go 10.5 KB