@ -85,7 +85,7 @@ func main() {
continue
}
pkg := typeNameObj . Pkg ( )
gen ( buf , imports , typ eName, typ , pkg )
gen ( buf , imports , typ , pkg )
found = true
}
}
@ -150,7 +150,7 @@ package %s
`
func gen ( buf * bytes . Buffer , imports map [ string ] struct { } , name string , typ * types . Named , thisPkg * types . Package ) {
func gen ( buf * bytes . Buffer , imports map [ string ] struct { } , typ * types . Named , thisPkg * types . Package ) {
pkgQual := func ( pkg * types . Package ) string {
if thisPkg == pkg {
return ""
@ -162,8 +162,11 @@ func gen(buf *bytes.Buffer, imports map[string]struct{}, name string, typ *types
return types . TypeString ( t , pkgQual )
}
switch t := typ . Underlying ( ) . ( type ) {
case * types . Struct :
t , ok := typ . Underlying ( ) . ( * types . Struct )
if ! ok {
return
}
name := typ . Obj ( ) . Name ( )
fmt . Fprintf ( buf , "// Clone makes a deep copy of %s.\n" , name )
fmt . Fprintf ( buf , "// The result aliases no memory with the original.\n" )
@ -245,7 +248,6 @@ func gen(buf *bytes.Buffer, imports map[string]struct{}, name string, typ *types
buf . Write ( codegen . AssertStructUnchanged ( t , name , "Clone" , thisPkg , imports ) )
}
}
func hasBasicUnderlying ( typ types . Type ) bool {
switch typ . Underlying ( ) . ( type ) {