Use package name more reliably. (#343)

The previous logic would act incorrectly when this package was vendored into
other packages.
This commit is contained in:
Jacob Hoffman-Andrews 2016-04-14 00:48:01 -07:00 committed by Miek Gieben
parent dd83d5cbcf
commit 031fad65fe
1 changed files with 4 additions and 1 deletions

View File

@ -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)