Re: [go-nuts] How to vary cgo lib path by os?

2021-11-28 Thread Ian Lance Taylor
On Sat, Nov 27, 2021 at 3:53 PM David Karr wrote: > > On Saturday, November 27, 2021 at 1:13:12 PM UTC-8 David Karr wrote: >> >> On Sat, Nov 27, 2021 at 11:57 AM Ian Lance Taylor wrote: >>> >>> On Sat, Nov 27, 2021 at 11:01 AM David Karr wrote: >>> > >>> > I'm aware of the "build constraints"

Re: [go-nuts] Re: Does Location of Variable Declarations Matter?

2021-11-28 Thread Ian Lance Taylor
On Sun, Nov 28, 2021 at 3:09 PM Amnon wrote: > > In K C back in the 1970s, you had to declare your local variables at the > beginning of a function, before any statements. > I think this is the source of the habit of declaring your variables first. > > Readability is key here. So it makes sense

[go-nuts] Re: Does Location of Variable Declarations Matter?

2021-11-28 Thread Amnon
In K C back in the 1970s, you had to declare your local variables at the beginning of a function, before any statements. I think this is the source of the habit of declaring your variables first. Readability is key here. So it makes sense to declare a statement close to where it is first used,

[go-nuts] gob: decoding into local type []float64, received remote type []float

2021-11-28 Thread cpu...@gmail.com
I'm trying to transfer arbitrary structs over gRPC. To achieve this I've trying to use gob for encoding the interface{} part of the structs. The code looks somewhat like https://go.dev/play/p/4Q5CQE4Wcy2 but not entirely. Two things strike me strange: - I receive "gob: decoding into local type

[go-nuts] Does Location of Variable Declarations Matter?

2021-11-28 Thread jlfo...@berkeley.edu
Some people put all their variable declarations at the beginning of a function. Others put them at various places in a function, where the variables are used. I've always wondered if a variable declaration results in any runtime overhead. One obvious concern is what happens if a variable

Re: [go-nuts] Goroutines and mutex

2021-11-28 Thread Levieux Michel
The problem here is you are sending a copy of counter to the anonymous function. You need to either not pass it and use the outer-scope counter directly in the function, or pass a reference to the counter to the function. Hope this helps. Le dim. 28 nov. 2021 à 16:19, Денис Мухортов a écrit :

Re: [go-nuts] Goroutines and mutex

2021-11-28 Thread 'Axel Wagner' via golang-nuts
On Sun, Nov 28, 2021 at 4:19 PM Денис Мухортов wrote: > Why are the values not incremented when declaring a structure with mutex > in goroutines? > https://go.dev/play/p/bPc1bg0AvJ4 > You have multiple problems: 1. You are passing `counter` to the goroutine as a value, making a copy 2. You have

[go-nuts] Goroutines and mutex

2021-11-28 Thread Денис Мухортов
Why are the values not incremented when declaring a structure with mutex in goroutines? https://go.dev/play/p/bPc1bg0AvJ4 And what is the actual point in declaring something in anonymous functions, if in my experience it always works without it? -- You received this message because you are