It is possible and easy to create named functions and launch them.

a := func(stuff){morestuff}

go a(args)

On Thu, Nov 22, 2018 at 7:38 PM Russtopia <rma...@gmail.com> wrote:

> Perhaps this is actually supported in Go v1 and I'm just missing something
> simple, but it appears one can do
>
> func A() {
>   go func() {
>       ...
>   }()
> }
>
> but not
>
> func A() {
>   go func B() {
>     ...
>   }()
> }
>
> or even
>
> func A() {
>   func B() {
>     ..
>   }
>
>   go B()
> }
>
> Does the syntax just not allow naming a goroutine, or nested funcs that
> are *not* goroutines, at all?
>
> I think this would be a nice feature for two reasons:
>
> 1. It is, of course, possible to just move the goroutine out into an
> outside, named function, but then one must manually identify, declare and
> pass all the parameters the goroutine might otherwise automatically capture
> from its parent scope(s) when refactoring it. One loses the nice
> closure-ish syntax of goroutines;
>
> 2. It would allow tools such as graphviz to more easily generate diagrams
> that can name goroutines something meaningful other than "func$1" for a
> goroutine launched within "func".
>
> -Russ
>
> --
> 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.
>
-- 

*Michael T. jonesmichael.jo...@gmail.com <michael.jo...@gmail.com>*

-- 
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.

Reply via email to