Re: [go-nuts] Detecting race conditions

2023-06-03 Thread 'Axel Wagner' via golang-nuts
Yes, logging changes behavior so that races might get exposed, both by slowing down the program and by introducing implicit synchronization points (the writes to the output happen under a mutex, AFAIK). But it does not introduce false positives. It exposes true positives. The race are still there,

Re: [go-nuts] Equivalence of types declared with equals

2023-06-03 Thread 'Axel Wagner' via golang-nuts
And FWIW the reason for that part of the spec is to disallow doing something like this: https://go.dev/play/p/fS1kIC-SE7z On Sun, Jun 4, 2023 at 7:35 AM Axel Wagner wrote: > That's a type alias, though. Not a type definition. > > The real issue is this part of the spec >

Re: [go-nuts] Equivalence of types declared with equals

2023-06-03 Thread 'Axel Wagner' via golang-nuts
That's a type alias, though. Not a type definition. The real issue is this part of the spec : > Two struct types are identical if they have the same sequence of fields, > and if corresponding fields have the same names, and identical types, and > identical t

Re: [go-nuts] Equivalence of types declared with equals

2023-06-03 Thread Kurtis Rader
See https://go.dev/ref/spec#Type_definitions and https://go.dev/ref/spec#Type_identity. In particular this statement: "The new type is called a *defined type*. It is different from any other type, including the type it is created from." On Sat, Jun 3, 2023 a

[go-nuts] Equivalence of types declared with equals

2023-06-03 Thread Duncan Harris
Why does this not work? https://go.dev/play/p/dodUj441xJS Produces the rather strange error message: ./prog.go:7:6: cannot use []t{…} (value of type []struct{f string}) as []struct{f string} value in argument to m.F -- You received this message because you are subscribed to the Google Groups

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-06-03 Thread 'Sean Liao' via golang-nuts
It is not a typo https://go.dev/issue/24451 - sean On Sat, Jun 3, 2023 at 10:05 PM peterGo wrote: > It's a simple typo. Send in a fix. > > peter > > On Saturday, June 3, 2023 at 4:07:15 PM UTC-4 Kamil Ziemian wrote: > >> As burak serdar said, 9 = 3 * 3 is not a prime number, all other element

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-06-03 Thread peterGo
It's a simple typo. Send in a fix. peter On Saturday, June 3, 2023 at 4:07:15 PM UTC-4 Kamil Ziemian wrote: > As burak serdar said, 9 = 3 * 3 is not a prime number, all other elements > in the slice are prime numbers. It looks like authors of Go Spec want to > make a joke or check how well peo

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-06-03 Thread Kamil Ziemian
As burak serdar said, 9 = 3 * 3 is not a prime number, all other elements in the slice are prime numbers. It looks like authors of Go Spec want to make a joke or check how well people read examples in it. Best regards, Kamil sobota, 3 czerwca 2023 o 21:52:37 UTC+2 burak serdar napisał(a): > On

[go-nuts] Detecting race conditions

2023-06-03 Thread Levi Durfee
Hello, While I was looking into a rarely occurring panic I used delve to debug the application. I set some log points in the Go standard library. I put one long point in src/net/lookup.go on line 298 so I could see that lookups were happening. I passed "-race" to the delve "build-flags" option

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-06-03 Thread burak serdar
On Sat, Jun 3, 2023 at 1:40 PM peterGo wrote: > > Kamil Ziemian, > > // list of prime numbers > primes := []int{2, 3, 5, 7, 9, 2147483647} > > The variable prime is a list of some prime numbers starting with the > lowest and ending with the highest prime numbers that can safely be > represented a

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-06-03 Thread peterGo
Kamil Ziemian, // list of prime numbers primes := []int{2, 3, 5, 7, 9, 2147483647} The variable prime is a list of some prime numbers starting with the lowest and ending with the highest prime numbers that can safely be represented an int. An int may either 32 or 64 bits. Please explain the

Re: [go-nuts] Re: Amateur's questions about "Go lang spec"

2023-06-03 Thread Kamil Ziemian
Is this example found in the "Composite literals" section of Go Spec a joke? // list of prime numbers primes := []int{2, 3, 5, 7, 9, 2147483647} I checked on the internet and 2147483647 is a prime number (https://en.wikipedia.org/wiki/2,147,483,647), so this element is fine. Best regards Kamil

Re: [go-nuts] If a pointer type implements a method in an interface, then its value type variable cannot be assigned to the corresponding interface. But it works the other way around!

2023-06-03 Thread Ian Lance Taylor
On Sat, Jun 3, 2023 at 10:05 AM 王谦铭 wrote: > > If a pointer type implements a method in an interface, then its value type > variable cannot be assigned to the corresponding interface. Conversely, if a > value type implements a method in an interface, its pointer type variable can > be assigned

Re: [go-nuts] Can we further optimize the scheduling order of goroutines in sync.Mutex?

2023-06-03 Thread Ian Lance Taylor
On Sat, Jun 3, 2023 at 12:35 AM fliter wrote: > > > In sync/mutex.go, there is a comment like the following: > > ```go > // Mutex fairness. > // > // Mutex can be in 2 modes of operations: normal and starvation. > // In normal mode waiters are queued in FIFO order, but a woken up waiter > // does

[go-nuts] If a pointer type implements a method in an interface, then its value type variable cannot be assigned to the corresponding interface. But it works the other way around!

2023-06-03 Thread 王谦铭
If a pointer type implements a method in an interface, then its value type variable cannot be assigned to the corresponding interface. Conversely, if a value type implements a method in an interface, its pointer type variable can be assigned to the corresponding interface. I want know why that

[go-nuts] Can we further optimize the scheduling order of goroutines in sync.Mutex?

2023-06-03 Thread fliter
In sync/mutex.go, there is a comment like the following: ```go // Mutex fairness. // // Mutex can be in 2 modes of operations: normal and starvation. // In normal mode waiters are queued in FIFO order, but a woken up waiter // does not own the mutex and competes with new arriving goroutines over