hexdigest / gowrap

GoWrap is a command line tool for generating decorators for Go interfaces
MIT License
1.06k stars 82 forks source link

.Interface.Methods no longer contains nested methods #65

Open Dafaque opened 1 year ago

Dafaque commented 1 year ago

proofOfBug.tpl:

{{range $method := .Interface.Methods}}
func {{$method.Declaration}}{}
{{end}}

proofOfBug.go:

//go:generate gowrap gen -g  -v DecoratorName=POC -i Base -t proofOfBug.tpl -o proofOfBug.gen.go
type Base interface {
    A()
    Nested
}

type Nested interface {
    B()
}

version 1.2.7 did not ignore nesteds

NoGambiNoBugs commented 1 year ago

@hexdigest I'm sorry for answering so late, the problem was very simple, when we mapping the types of files we also check if the type is the target, if is then we save in selectedType, but this func has two purpose, first is mapping the types and second is return the target type. The fix was just change a return to continue, but if you prefer can be removed because there are nothing after this condition.

@Dafaque your example it wasn't working because the nested struct was declared after the target struct, but already is working with this PR https://github.com/hexdigest/gowrap/pull/68. Here is an example:

Dafaque commented 1 year ago

Thanx a lot!