Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support types.Struct as interface args #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tomMoulard
Copy link
Member

This PR adds support for *types.Array.
Usefull when mocking an interface that look like this:

type Foo interface {
	Bar(toto struct{titi string})
}
Current mocktail output
> mocktail
panic: OOPS *types.Struct struct{}

goroutine 1 [running]:
main.getTypeImports({0x1003e7cc8?, 0x140023c9920?})
	/Users/tom.moulard/go/pkg/mod/github.com/traefik/[email protected]/mocktail.go:244 +0x3a0
main.getTypeImports({0x1003e7c50?, 0x140072834c0})
	/Users/tom.moulard/go/pkg/mod/github.com/traefik/[email protected]/mocktail.go:221 +0x184
main.getTupleImports({0x1400e88f6c8, 0x2, 0x14002b6cea0?})
	/Users/tom.moulard/go/pkg/mod/github.com/traefik/[email protected]/mocktail.go:201 +0x130
main.getMethodImports(0x14001553290?, {0x1400024806a, 0x4f})
	/Users/tom.moulard/go/pkg/mod/github.com/traefik/[email protected]/mocktail.go:187 +0x60
main.walk.func1({0x1400021d400, 0x76}, {0x1003ea040, 0x14000220e40}, {0x0?, 0x0?})
	/Users/tom.moulard/go/pkg/mod/github.com/traefik/[email protected]/mocktail.go:161 +0x77c
path/filepath.walkDir({0x1400021d400, 0x76}, {0x1003ea040, 0x14000220e40}, 0x1400e88fdc8)
	/opt/homebrew/Cellar/go/1.23.0/libexec/src/path/filepath/path.go:310 +0x44
path/filepath.walkDir({0x14000205f80, 0x69}, {0x1003ea040, 0x1400020c9c0}, 0x1400e88fdc8)
	/opt/homebrew/Cellar/go/1.23.0/libexec/src/path/filepath/path.go:332 +0x21c
path/filepath.walkDir({0x140002057a0, 0x61}, {0x1003ea040, 0x1400020c5c0}, 0x1400e88fdc8)
	/opt/homebrew/Cellar/go/1.23.0/libexec/src/path/filepath/path.go:332 +0x21c
path/filepath.walkDir({0x1400015d680, 0x59}, {0x1003ea040, 0x14000094500}, 0x1400e88fdc8)
	/opt/homebrew/Cellar/go/1.23.0/libexec/src/path/filepath/path.go:332 +0x21c
path/filepath.walkDir({0x1400001c2d0, 0x4c}, {0x1003ea008, 0x14000028400}, 0x1400e88fdc8)
	/opt/homebrew/Cellar/go/1.23.0/libexec/src/path/filepath/path.go:332 +0x21c
path/filepath.WalkDir({0x1400001c2d0, 0x4c}, 0x140000dbdc8)
	/opt/homebrew/Cellar/go/1.23.0/libexec/src/path/filepath/path.go:400 +0x78
main.walk({0x1400001c2d0, 0x4c}, {0x1400001a240, 0x32})
	/Users/tom.moulard/go/pkg/mod/github.com/traefik/[email protected]/mocktail.go:82 +0xb8
main.main()
	/Users/tom.moulard/go/pkg/mod/github.com/traefik/[email protected]/mocktail.go:61 +0x1b0
exit status 2
make: *** [generate] Error 1

@nmengin nmengin added kind/enhancement a new or improved feature. status/2-needs-review labels Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants