I don't know of any primitives that would return the current processor the
goroutine is currently running on. Maybe if you explain more precisely what
you are trying to do, we can find a better solution?

@lgodio2 no, as Jan said, the go statement is not an expression, so you
can't assign with it, you need to do either:

func main() {
    var s1 TYPE
    go func () {
        s1 = f1()
    }
    s2 := f2()
}

OR

func main() {
    var s1 TYPE
    var s2 TYPE

    go func () {
        s1 = f1()
    }()

    go func() {
        s2 = f2()
    }()
}

However in the second solution, if you execute that in the main goroutine
or if you need those two assignments to be done before doing something
else, you might want to use synchronisation primitives such as waitgroups.

Le mar. 7 mai 2019 à 07:51, Nitish Saboo <nitish.sabo...@gmail.com> a
écrit :

> Hi Michel,
>
> Yes, this is what I was looking for.Thankyou..:)
>
> Can we also find the processor on which this go routine is running?
>
> Thanks
>
>
> On Mon, 6 May 2019, 17:43 Michel Levieux, <m.levi...@capitaldata.fr>
> wrote:
>
>> Hello,
>>
>> Is:
>>
>> type Y struct {
>>
>> M string
>> N string
>>
>> }
>>
>> func initalize() Y{
>> // I have a func that return an object ob type Y.
>> }
>>
>> var obj1 Y
>> go func() {
>>     obj1 = initalize()
>> }()
>>
>> var obj2 Y
>> go func() {
>>     obj2 = initalize()
>> }()
>>
>> What you are looking for?
>>
>> Le lun. 6 mai 2019 à 13:59, Jan Mercl <0xj...@gmail.com> a écrit :
>>
>>> On Mon, May 6, 2019 at 1:39 PM Nitish Saboo <nitish.sabo...@gmail.com>
>>> wrote:
>>>
>>> > type Y struct {
>>> >
>>> > M string
>>> > N string
>>> >
>>> > }
>>> >
>>> > func initalize() Y{
>>> > // I have a func that return an object ob type Y.
>>> > }
>>> > var obj1 Y  = go  initalize()
>>>
>>> No need to write Y above, the type will be inferred. However, see
>>> https://golang.org/ref/spec#Go_statements The go statement is not an
>>> expression while the `var foo = expr` requires an expression.
>>>
>>> --
>>> 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.
>>>
>>

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANgi334APwcch%2B26XG_6RSqLObarfuyzPVn2-%2BmZPYXwvajbdg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to