DEV Community

Discussion on: Golang Patterns - Part 2

tcarrio profile image

I'm a major novice (and not in the better way of interpretation) in Go, but to clarify:

func WalkInWordGrams(walker WordgramWalker) error {
Enter fullscreen mode Exit fullscreen mode

in your first code block, you had not set up the WordgramWalker type, so you couldn't use this could you? You would have had to had the func defined as:

func WalkInWordGrams(walker func(wordgram *wordgrams.WordGram) error) error {
Enter fullscreen mode Exit fullscreen mode

Or something along these lines?

Really interesting read, I just wanted to make sure I understood :D

napicella profile image
Nicola Apicella Author

You are right, nice catch.
The example would fail to compile, because WordgramWalker is not defined.
The Ctr+C && Ctr+V pattern failed me XD

Thanks for reading and letting me know about the mistake!
I have updated the example with the correction :)