Re: [go-nuts] Closing a closed channel

2017-08-03 Thread Andrey Tcherepanov
Ian, Sorry to revive this old thread. Would it be possible to add your answer (and a solution with sync.Once suggested on this thread) to a FAQ and/or Effective Go document? Yes, I stepped on it too trying to use close() as a signal that work is done, and then doing close() in a cleanup

[go-nuts] Re: Error when using go tool trace

2017-08-03 Thread evan . explodes
I ran into this same problem, and found this post! It looks like you're making the same simple mistake I was: # erroneous: defer f.Close() defer trace.Stop() You must stop the trace *before* closing the output file. # corrected: defer func() { trace.Stop() panic(f.Close()) # Be sure to

[go-nuts] Re: Problems buildding go from source, tests "hangs"

2017-08-03 Thread SauliusGurklys
$(go env CC) --version gcc (GCC) 7.1.1 20170630 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. I want to add that I think that original issue

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread Lucio De Re
Walter Bright, indeed. Thank you for the correction. I hope it was clear enough in context and my slip-up did not offend anyone. Lucio. On 8/3/17, Russel Winder wrote: > On Thu, 2017-08-03 at 03:50 -0700, Lucio wrote: >> > […] >> PS: I think David Bright is a genius. I

[go-nuts] Re: Generics are overrated.

2017-08-03 Thread Dorival Pedroso
Agreed! And I was a "heavy" user of templates (see e.g. http://mechsys.nongnu.org/, including extensive use of "expression templates") ~5 years ago before the "wonders of Go". Let's focus on making Go faster instead! Cheers. Dorival On Friday, July 28, 2017 at 10:41:10 PM UTC+10,

[go-nuts] Re: Computations with complex numbers may be slow if care is not taken

2017-08-03 Thread Dorival Pedroso
This is the version of a pure imaginary real number raised to the power of n (integer): // ImagXpowN computes (x⋅i)ⁿ // // (x⋅i)¹ = x¹⋅i (x⋅i)² = -x² (x⋅i)³ = -x³ ⋅i (x⋅i)⁴ = x⁴ // (x⋅i)⁵ = x⁵⋅i (x⋅i)⁶ = -x⁶ (x⋅i)⁷ = -x⁷ ⋅i (x⋅i)⁸ = x⁸ // (x⋅i)⁹ =

Re: [go-nuts] Computations with complex numbers may be slow if care is not taken

2017-08-03 Thread Matt Harden
So it sounds like the special case that would be helpful is when the real part of the complex base is 0. On Thu, Aug 3, 2017, 18:26 Dorival Pedroso wrote: > Thanks for the advice. > > This is the piece of code where I use that function: > // compute hat(Du) > pf :=

Re: [go-nuts] Computations with complex numbers may be slow if care is not taken

2017-08-03 Thread Dorival Pedroso
Thanks for the advice. This is the piece of code where I use that function: // compute hat(Du) pf := float64(p) for j := 0; j < N; j++ { ikp := ImagPowN(p) * complex(math.Pow(K[j], pf), 0) DuHat[j] = ikp * S[j] * A[j] } where p is an integer (unbounded), K[j] is a real number from -Inf to +Inf

Re: [go-nuts] Computations with complex numbers may be slow if care is not taken

2017-08-03 Thread Michael Jones
the complex power function is a difficult (time consuming) general computation. are you saying that you actually have a program that uses boolean gaussian integers and needs to do lots of power operations? if so, i highly recommend that you special case this for your own use. if this is common

[go-nuts] Computations with complex numbers may be slow if care is not taken

2017-08-03 Thread Dorival Pedroso
Hi, This is an interesting benchmark: Given this function: // ImagPowN computes iⁿ = (√-1)ⁿ // // i¹ = i i² = -1 i³ = -i i⁴ = 1 // i⁵ = i i⁶ = -1 i⁷ = -i i⁸ = 1 // i⁹ = i i¹⁰ = -1 i¹¹ = -i i¹² = 1 // func ImagPowN(n int) complex128 { if n

Re: [go-nuts] Re: gobind generated constructor for struct containing []byte sometimes corrupts data

2017-08-03 Thread Antonio Marcedone
Thanks! The only information I could find about this on the gobind documentation is (https://godoc.org/golang.org/x/mobile/cmd/gobind) - Byte slice types. Note that byte slices are passed by reference, and support mutation. However, this version of the code still shows the problem: > String

Re: [go-nuts] Re: Generics are overrated.

2017-08-03 Thread Doğan Kurt
> > it's amazing to see what people were able to accomplish with 2KB RAM, > *one* general-purpose register, no hardware multiply/divide, > Constraints boost creativity and discipline programmer. You may like this .

[go-nuts] When to use custom string type and custom int type

2017-08-03 Thread Kaviraj Kanagaraj
Can someone help me understand whats the main difference two different UserType in below snippet.? More importantly when to use which. ``` type UserType string const ( Undefined UserType = "undefined" Admin UserType = "admin" ) type UserType int const ( Undefined UserType = iota Admin )

Re: [go-nuts] Re: Generics are overrated.

2017-08-03 Thread DV
I think "need" is indeed one of those special words that means different things for different people. Go doesn't "need" generics and you technically don't "need" anything except air, water, food, a sharp spear, and shelter, to survive. I recently started toying with writing quick-n-dirty

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread Russel Winder
On Thu, 2017-08-03 at 03:50 -0700, Lucio wrote: > […] > PS: I think David Bright is a genius. I still have my original copies of  > Zortech C++ (versions 1 and 2) which almost certainly have only antiquarian  > value. But the man who produced that masterpiece deserves to be recognised.  > So if

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread ecstatic . coder
I've already apologized for my misinterpretation. I want to point out that I was 100% sincere in what I was saying. Sorry if some of you have taken this for a bold lie, this wasn't absolutely meant this way. To be completely honest, I still believe what I was saying, even if I admit now

[go-nuts] Go-based Smart Home Hub

2017-08-03 Thread Tim
Not 100% sure if this is the right group to post to, but just want to let everyone know that we've launched AERIFAI, a Go based smart home hub on Indiegogo: https://www.indiegogo.com/projects/aerifai-breathe-easier-with-a-mindful-home-smartphone-energy#/ Our goals is to make this open for

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread Jan Mercl
On Thu, Aug 3, 2017 at 3:52 PM wrote: > Honestly, I didn't know what I was saying was not true. Sincerely. As I said, I'm a developer, not a psychologist. Interpreting people's thought is not my job, I'm just a developer, and I haven't even graduated from university, I

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread ecstatic . coder
Honestly, I didn't know what I was saying was not true. Sincerely. As I said, I'm a developer, not a psychologist. Interpreting people's thought is not my job, I'm just a developer, and I haven't even graduated from university, I just have a bachelor's degree in software development. Sorry for

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread Jan Mercl
On Thu, Aug 3, 2017 at 3:27 PM wrote: > So you mean these 16% thought that Genericity would improve the language, but that it should not be added to the language. True version: I meant precisely only what I wrote. -- -j -- You received this message because you are

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread ecstatic . coder
So you mean these 16% thought that Genericity would improve the language, but that it should not be added to the language. Ok, maybe I've misinterpreted the survey, I'm not a psychologist, I agree... ;) Le jeudi 3 août 2017 14:15:31 UTC+1, Jan Mercl a écrit : > > On Thu, Aug 3, 2017 at 3:04 PM

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread Jan Mercl
On Thu, Aug 3, 2017 at 3:04 PM wrote: > I agree that despite genericity is the #1 feature requested by Go developers in Google's last official survey, ... True version: 16% of the respondents answered "generics" to the question "What changes would improve Go most?" --

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread eric . pelzer
I agree that despite genericity is the #1 feature requested by Go developers in Google's last official survey, there are few chances they change their mind. Idem for polymorphism. So indeed, I've clearly understood that Google and most Go developers don't care at all about having templating,

Re: [go-nuts] look for a example: call a DLL's function on Windows by CGO

2017-08-03 Thread Konstantin Khomoutov
Hi! Unfortunately you forgot to use the "reply to all" or "reply to list" action so the message has only been sent to me, not to the list. Please re-send/re-post correctly. On Thu, Aug 03, 2017 at 07:33:03PM +0800, Fino Meng wrote: >>> yesterday I just found that, the syscall way to use DLL on

Re: [go-nuts] Re: HTTP/2 multiplexing

2017-08-03 Thread Henrik Johansson
Out of curiosity do you do something like this in wireshark? ip.dst_host=="duckduckgo.com" && tcp.flags.syn == 0 My wireshark fu is really weak... tors 3 aug. 2017 kl 11:35 skrev : > Works, thanks a lot!!! > Also found this related discussion: >

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Henrik Johansson
It does help, thank you Konstantin. tors 3 aug. 2017 kl 10:25 skrev Konstantin Khomoutov : > On Thu, Aug 03, 2017 at 07:21:24AM +, Henrik Johansson wrote: > > [...] > > It gets hypothetical pretty quick and usually when this happens I make > sure > > to create a new

Re: [go-nuts] Re: GO Vs D

2017-08-03 Thread Lucio
Maybe, just maybe, you should consider that your opinion of the Go language is a long list of wishful thinking and given that you already have an alternative, you should accept that few Go developers/users are going to take your side. Hoping that Go's vast library should magically materialise

Re: [go-nuts] Re: HTTP/2 multiplexing

2017-08-03 Thread Christian Joergensen
On Thursday, August 3, 2017 at 11:07:50 AM UTC+2, pala.d...@gmail.com wrote: > > Example code with DuckDuckGo as default target: > > https://play.golang.org/p/_iI5-MDJ5t > This looks like a thundering herd race on connection setup. So there is no connection to reuse as none of them has been

Re: [go-nuts] Re: gobind generated constructor for struct containing []byte sometimes corrupts data

2017-08-03 Thread Elias Naur
Yes, byte slices are special and are not reference counted like other objects. You need to copy it on the Go side. - elias Den tor. 3. aug. 2017 03.21 skrev Antonio Marcedone : > My intuition above seems to contrast with > https://godoc.org/golang.org/x/mobile/cmd/gobind:

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Konstantin Khomoutov
On Thu, Aug 03, 2017 at 07:21:24AM +, Henrik Johansson wrote: [...] > It gets hypothetical pretty quick and usually when this happens I make sure > to create a new array/slice/whatever and then atomically swap it before > some other goroutine uses it but I generally avoid indexing assignment

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Henrik Johansson
Excellent, thank you Dave! tors 3 aug. 2017 kl 09:45 skrev Dave Cheney : > > > On Thu, 3 Aug 2017, 17:39 Dave Cheney wrote: > >> Your first program has a data race, well it has two races, the first is a >> data race between the goroutines writing to the slice

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Dave Cheney
On Thu, 3 Aug 2017, 17:39 Dave Cheney wrote: > Your first program has a data race, well it has two races, the first is a > data race between the goroutines writing to the slice and the println which > will read the contents of the slice. That is, if those writing goroutines >

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Dave Cheney
Your first program has a data race, well it has two races, the first is a data race between the goroutines writing to the slice and the println which will read the contents of the slice. That is, if those writing goroutines get a chance to run before main exits. The second program doesn't have a

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Henrik Johansson
But isn't this what is happening in the example? Or is write-only not sharing? On Thu, 3 Aug 2017, 09:23 Dave Cheney, wrote: > IMO you need a lock whenever you are sharing a value between goroutines by > storing it in memory. > > On Thu, 3 Aug 2017, 17:21 Henrik Johansson

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Henrik Johansson
I think I am mostly after a mental pattern to easily recognise when synchronizations are needed. I am decently good at this but I tend to be very conservative and use locks and atomics perhaps when they are not needed. But here we have several goroutines all taking part in the initialisation

Re: [go-nuts] lock for assigning to different elements of an array

2017-08-03 Thread Dave Cheney
IMO you need a lock whenever you are sharing a value between goroutines by storing it in memory. On Thu, 3 Aug 2017, 17:21 Henrik Johansson wrote: > I think I am mostly after a mental pattern to easily recognise when > synchronizations are needed. > > I am decently good at

Re: [go-nuts] look for a example: call a DLL's function on Windows by CGO

2017-08-03 Thread Konstantin Khomoutov
On Wed, Aug 02, 2017 at 08:33:53PM -0700, Fino wrote: > yesterday I just found that, the syscall way to use DLL on Windows cannot > use float32 as parameters, Could you please elaborate on that as I do not beleive this is not possible: IIRC Go's float types follow IEEE 754 semantics and you

Re: [go-nuts] Twitter search go code

2017-08-03 Thread Tyler Compton
I don't believe Shawn was trying to be condescending. He didn't link you to https://lmgtfy.com/ after all ;) You're likely to get better responses if you include info about your use case and the libraries you have looked at so far. On Tue, Aug 1, 2017 at 7:34 PM Tong Sun

Re: [go-nuts] Re: Go one-line installer

2017-08-03 Thread Tyler Compton
> No, most Linux users are used to installing from package managers. I don't know if that's true. Many popular distributions provide undesirably out-of-date versions of common tools and require users to use other means to install them. But both of our assertions are valueless without data, so it