Declaring multiple 'func' in the function signature

What does it mean when we declare func() func(…) like in the example below?
So the are thee(!) func keywords in the function declaration.

func sss() func() func(string) string {
	start := time.Now()
	return func() func(string) string {
		fmt.Printf("Time from start %v", time.Since(start))
		return getTime
	}
}

And why should we return func() func(string) string instead of func(string) string?

1 Like

sss is a function (the func on the left hand side) that returns a func that takes no arguments but returns a func that takes a string.

3 Likes

and returning string. wow

2 Likes

You can find more details here in official documentation in go syntax section.

I hope it’s going to help.

Cheers

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.