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:
parent
dd83d5cbcf
commit
031fad65fe
|
@ -229,7 +229,10 @@ func main() {
|
||||||
if sl, ok := st.Field(i).Type().(*types.Slice); ok {
|
if sl, ok := st.Field(i).Type().(*types.Slice); ok {
|
||||||
t := sl.Underlying().String()
|
t := sl.Underlying().String()
|
||||||
t = strings.TrimPrefix(t, "[]")
|
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",
|
fmt.Fprintf(b, "%s := make([]%s, len(rr.%s)); copy(%s, rr.%s)\n",
|
||||||
f, t, f, f, f)
|
f, t, f, f, f)
|
||||||
fields = append(fields, f)
|
fields = append(fields, f)
|
||||||
|
|
Loading…
Reference in New Issue