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