The type seems unnecessary. It doesn't actually do anything different than a regular func(). Does it just exist to give a place for common documentation for each of the methods that use it?
IMO, the With* functions would be more clear if they didn't use a named type for func(), because now when I look at WithDeadline, I have to then look at CancelFunc to know what it's returning. func WithDeadline(parent Context <https://golang.org/pkg/context/#Context>, deadline time <https://golang.org/pkg/time/>.Time <https://golang.org/pkg/time/#Time>) (Context <https://golang.org/pkg/context/#Context>, CancelFunc <https://golang.org/pkg/context/#CancelFunc>) vs func WithDeadline(parent Context <https://golang.org/pkg/context/#Context>, deadline time <https://golang.org/pkg/time/>.Time <https://golang.org/pkg/time/#Time>) (ctx Context <https://golang.org/pkg/context/#Context>, cancelFunc f <https://golang.org/pkg/context/#CancelFunc>unc()) IMO, the latter is more clear. Also, how come WithCancel has named return values but WithDeadline and WithTimeout don't? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.