From 031fad65fea12748347cbb2a30f190b6257fc844 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Thu, 14 Apr 2016 00:48:01 -0700 Subject: [PATCH] Use package name more reliably. (#343) The previous logic would act incorrectly when this package was vendored into other packages. --- types_generate.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/types_generate.go b/types_generate.go index b8d1cd26..63bfda0e 100644 --- a/types_generate.go +++ b/types_generate.go @@ -229,7 +229,10 @@ func main() { if sl, ok := st.Field(i).Type().(*types.Slice); ok { t := sl.Underlying().String() t = strings.TrimPrefix(t, "[]") - t = strings.TrimPrefix(t, "github.com/miekg/dns.") + if strings.Contains(t, ".") { + splits := strings.Split(t, ".") + t = splits[len(splits)-1] + } fmt.Fprintf(b, "%s := make([]%s, len(rr.%s)); copy(%s, rr.%s)\n", f, t, f, f, f) fields = append(fields, f)