globusdigital / deep-copy

Deep copy generator
BSD 3-Clause "New" or "Revised" License
150 stars 34 forks source link

Struct fields with []T types are not generated #3

Closed fatih closed 4 years ago

fatih commented 4 years ago

Below is a reproducible case:

# example file
$ cat foo.go
package foo

type T struct {
        a []A
        b string
}

type A struct {
        foo string
        bar int
}

# generate file
$ deep-copy -pointer-receiver -type=T -o deepycopy.go .

# generated file
$ cat deepycopy.go
// generated by deep-copy -pointer-receiver -type=T -o deepycopy.go . !DO NOT EDIT!

package foo

// DeepCopy generates a deep copy of *T
func (o *T) DeepCopy() *T {
        var cp T
        cp = *o
        if o.a != nil {
                cp.a = make([]A, len(o.a))
                for i := range o.a {
                }
        }
        return &cp
}

# build fails
$ go build
./deepycopy.go:11:7: i declared but not used