Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Michael Jones
true. not roust that way. also, it uses "Go array bounds checking" as the implicit test for crazy out of range values. just a 5 min stream of consciousness hack to defend the honor of the Go atomic primitives. ;-) It was typed one handed while the the other propped up my macbook here in bed.

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Robert Engels
Sorry, I hadn’t looked at the code, but after reviewing doesn’t your code not detect the case where a value was skipped ? (... not that it could happen - but for completeness of the robust test) > On Dec 1, 2019, at 10:44 PM, Michael Jones wrote: > > not necessary as the testing and updating

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Michael Jones
"Oh you've allocated a bit array for every value in the test range, then checked for gaps in it?" Yes. What I should have said. (Though the test looks not for gaps but for two pigeons in one hole, but the same idea.) On Sun, Dec 1, 2019 at 8:44 PM Michael Jones wrote: > not necessary as the

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Michael Jones
not necessary as the testing and updating is only done in one place by one the main goroutine. On Sun, Dec 1, 2019 at 7:46 PM Robert Engels wrote: > The updating of the bit array if shared needs to atomic as well, probably > with a read and cas. > > On Dec 1, 2019, at 9:19 PM, Liam wrote: > >

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Robert Engels
The updating of the bit array if shared needs to atomic as well, probably with a read and cas. > On Dec 1, 2019, at 9:19 PM, Liam wrote: > >  > Oh you've allocated a bit array for every value in the test range, then > checked for gaps in it? > >> On Sunday, December 1, 2019 at 2:21:55 PM

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Liam
Oh you've allocated a bit array for every value in the test range, then checked for gaps in it? On Sunday, December 1, 2019 at 2:21:55 PM UTC-8, Michael Jones wrote: > > Oh! That's just a bit per integer in the test range 0..total-1. Since Go > (and everything else) lacks a bit type, I just

[go-nuts] Download server data in the web browser

2019-12-01 Thread 洪嘉鴻
Hello everyone: The version of the golang which I am using is 1.12.9 with WIn10. Now I'm trying to write a web browser. I've found some examples about web applications. Here is the code about the server. I want to download the data (which is the

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Dan Kortschak
What do you mean by i+k >= cap(a)? k+(any non-negative number) may not be greater than cap(a). The key to safely appending when you are unsure of the backing array's state is to append to the slice length and capped to the same size. On Sun, 2019-12-01 at 14:55 -0800, Bakul Shah wrote: >

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Michael Jones
agree, makes sense. also if you trust the compiler, change to use the mod function, etc. On Sun, Dec 1, 2019 at 2:31 PM robert engels wrote: > I’d prefer v / 8 over v >> 3 - provides more context in my opinion. The > compiler will change to right shift if more efficient anyway. > > On Dec 1,

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Bakul Shah
On Dec 1, 2019, at 1:06 PM, Harald Weidner wrote: > > Hello, > >> I'm not sure if that is a good idea  >> https://play.golang.org/p/Mj77pgsaVsB > > This is why three-index slices were added in Go 1.2. > > https://play.golang.org/p/_sJ9OKWsvMz > > https://golang.org/doc/go1.2#three_index

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread robert engels
I’d prefer v / 8 over v >> 3 - provides more context in my opinion. The compiler will change to right shift if more efficient anyway. > On Dec 1, 2019, at 4:21 PM, Michael Jones wrote: > > Oh! That's just a bit per integer in the test range 0..total-1. Since Go (and > everything else) lacks a

Re: [go-nuts] atomic.Add*() doesn't produce unique values

2019-12-01 Thread Michael Jones
Oh! That's just a bit per integer in the test range 0..total-1. Since Go (and everything else) lacks a bit type, I just type such code automatically. Bytes hold 8 bits. Array size must be rounded up, so a := make([]byte, (total+8-1)/8) array index for test integer n is n/8, so "n>>3" bit index

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Harald Weidner
Hello, > I'm not sure if that is a good idea  > https://play.golang.org/p/Mj77pgsaVsB This is why three-index slices were added in Go 1.2. https://play.golang.org/p/_sJ9OKWsvMz https://golang.org/doc/go1.2#three_index Regards, Harald -- You received this message because you are subscribed

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Marcin Romaszewicz
Well, in that case: https://play.golang.org/p/DhSC_xF0jPW :) On Sun, Dec 1, 2019 at 12:34 PM Daniela Petruzalek < daniela.petruza...@gmail.com> wrote: > I'm not sure if that is a good idea  > > https://play.golang.org/p/Mj77pgsaVsB > > Daniela Petruzalek > Software Engineer >

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Daniela Petruzalek
I'm not sure if that is a good idea  https://play.golang.org/p/Mj77pgsaVsB Daniela Petruzalek Software Engineer github.com/danicat twitter.com/danicat83 Em dom., 1 de dez. de 2019 às 17:07, Marcin Romaszewicz escreveu: > It's very simple to do that: > https://play.golang.org/p/1i7pI2OXmej >

Re: [go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Marcin Romaszewicz
It's very simple to do that: https://play.golang.org/p/1i7pI2OXmej On Sun, Dec 1, 2019 at 8:22 AM Vital Nabokov wrote: > Разбить массив чисел на два массива? > Split an array of numbers into two arrays? > > -- > You received this message because you are subscribed to the Google Groups >

[go-nuts] Разбить массив чисел на два массива

2019-12-01 Thread Vital Nabokov
Разбить массив чисел на два массива? Split an array of numbers into two arrays? -- 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

Re: [go-nuts] C variadic macro equivalent in Golang?

2019-12-01 Thread minforth
That did it: // --- variad.go -- variadic function test package main import("fmt";"os") // flags var df,ef int = 1,1 // variadic function thru empty interface func PR(f string, a ...interface{}) { if df!=0 { fmt.Printf(f, a...) if ef!=0 { fmt.Fprintf(os.Stderr,f, a...) } } }

[go-nuts] Re: ? How restrict usage of packages ?

2019-12-01 Thread Daniel Norte Moraes
Em segunda-feira, 25 de novembro de 2019 21:39:30 UTC-3, Scott Pakin escreveu: > > On Monday, November 25, 2019 at 9:55:55 AM UTC-7, Daniel Norte Moraes > wrote: >> >>I Want create and permite my users to create go lang programs mostly >> with full capabilities from >> golang itself, but

[go-nuts] Re: ? How restrict usage of packages ?

2019-12-01 Thread Daniel Norte Moraes
Good Point! Really Thanks! :-) Em segunda-feira, 25 de novembro de 2019 14:44:10 UTC-3, JuciÊ Andrade escreveu: > > Add a script to your users continuous integration tool or even to their > source control management. > Whenever software is compiled or commited your script will search for >

Re: [go-nuts] Where is the middle of Brazil?

2019-12-01 Thread Dan Kortschak
This looks like a job for geocrypt :) https://godoc.org/github.com/kortschak/geocrypt On Sun, 2019-12-01 at 06:37 -0300, JuciÊ Andrade wrote: > Andrew, the solution doesn't involve cracking the digest at all. As I > said above, maybe I should have been clearer in my question. That > digest is

Re: [go-nuts] Where is the middle of Brazil?

2019-12-01 Thread JuciÊ Andrade
Michael, let me tell you I feel very much honored because you answered my question right away. Thank you very much. To be honest, that was not exactly the position I was after. Maybe my question should have been more clear. To be effectively in the middle of our territory, the position would