From 259a67197d6caa668d240fcd13b846f12906d609 Mon Sep 17 00:00:00 2001 From: "Karrick S. McDermott" Date: Tue, 27 Jun 2017 18:02:50 -0400 Subject: [PATCH] no longer panics with the following file ``` package main //go:generate msgp import ( "bytes" "fmt" "os" "github.com/tinylib/msgp/msgp" ) type Feedback map[string]interface{} func main() { deepMap := make(map[string]map[string]string) feedback := Feedback{"general": deepMap} bb := new(bytes.Buffer) if err := msgp.Encode(bb, feedback); err != nil { fmt.Fprintf(os.Stderr, "%s\n", err) os.Exit(1) } fmt.Printf("%#v\n", bb.Bytes()) } // 1. Type `go generate main.go`. // 2. Type `go run main.go main_gen.go`. ``` --- msgp/write.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/msgp/write.go b/msgp/write.go index 0245c1bd..da9099c2 100644 --- a/msgp/write.go +++ b/msgp/write.go @@ -689,7 +689,7 @@ func (mw *Writer) WriteIntf(v interface{}) error { } func (mw *Writer) writeMap(v reflect.Value) (err error) { - if v.Elem().Kind() != reflect.String { + if v.Type().Key().Kind() != reflect.String { return errors.New("msgp: map keys must be strings") } ks := v.MapKeys()