Re: [go-nuts] Re: Reasoning behind behavior of range, when index is maintained

2017-07-27 Thread Konstantin Khomoutov
On Wed, Jul 26, 2017 at 08:44:46AM -0700, Christoph Berger wrote: > > someone shared [this question]( > > https://www.reddit.com/r/golang/comments/6paqc0/bug_that_caught_me_with_range/) > > > > on reddit. I must say, that I'm surprised by the behavior myself. I would > > have expected > > for i

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread ecstatic . coder
I don't know if you have read this post above : "BTW, I've just released Genesis, an open source generic preprocessor which automatically converts Allman style code into K&R and allows genericity by parametric instantiation. https://github.com/senselogic/GENESIS Better late than never... ;)"

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Ecstatic Coder
Btw please don't take it personally. What I'm saying is that indeed some people (including me as you see) WILL NEVER agree to be forced to change their coding style because Google engineers have decided so, but that doesn't mean we should stay away from go just because of our mental incapacity to a

[go-nuts] Re: no.something seem like impossible,but it happens!!!!【 string 】causes the crash !!!!!!!!!!!!!!

2017-07-27 Thread 370265036
o yea,thanks.it's a good way to improve the performance of my program.but will it solve the problem,crashing? 在 2017年7月27日星期四 UTC+8上午12:26:36,JuciÊ Andrade写道: > > I mean bytes.Buffer. > > On Wednesday, July 26, 2017 at 8:08:13 AM UTC-3, JuciÊ Andrade wrote: >> >> Dear friend 3702, while you are a

Re: [go-nuts] Reasoning behind behavior of range, when index is maintained

2017-07-27 Thread Christoph Berger
That’s actually what I meant to indicate in the last paragraph (emphasis added by me): > The code in the Reddit post takes advantage of the fact that the last > increment of the C-style loop can be observed outside the loop, But thanks for providing a clarification. I see now it has not been cl

[go-nuts] Re: no.something seem like impossible,but it happens!!!!【 string 】causes the crash !!!!!!!!!!!!!!

2017-07-27 Thread ojucie
3702, I think you need to learn some fundamental concepts to better understand the problem at hand. Processors have more than one core. That means we have several threads running simultaneously. To let more than one thread access the same memory region is a bad idea. If your program simply c

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Rob Pike
Very few, though. Very few. As the proverb says: Gofmt's style is no one's favorite, yet gofmt is everyone's favorite. -rob On Thu, Jul 27, 2017 at 6:49 PM, Ecstatic Coder wrote: > Btw please don't take it personally. What I'm saying is t

[go-nuts] Re: 10x latency spikes during GC alloc assist phase

2017-07-27 Thread m.kevac via golang-nuts
Hi. We have made a simple one line patch to Go that turns off GC assist. Unfortunately, it was the only way. I feel your pain. $ git diff diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index 8850659748..a2c8697bf5 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -602,

Re: [go-nuts] Alternative to reflect.DeepEqual that considers "shape" of cycles?

2017-07-27 Thread howardcshaw
https://golang.org/pkg/reflect/#DeepEqual "Pointer values are deeply equal if they are equal using Go's == operator or if they point to deeply equal values." By the rules described here, the fact that both pointers have the same value means it does not even NEED to check what they point to, so

Re: [go-nuts] 10x latency spikes during GC alloc assist phase

2017-07-27 Thread Bakul Shah
You're storing millions of slices. A slice is implemented as (ptr, length, capacity). If your maps are mostly static, may be you can use one giant array for each value type and just store (offset, length) or (base, limit) in your maps and in effect do your own slicing? Now to access a slice, you

Re: [go-nuts] 10x latency spikes during GC alloc assist phase

2017-07-27 Thread Joe Taber
Bakul, You wouldn't even need to change the slicing semantics like that. Just concatenate all slices in the map into one master slice, then take capacity-slices[1] of it with the right offsets to rebuild the whole map. This wouldn't change the semantics of accessing or changing the map at all:

Re: [go-nuts] Alternative to reflect.DeepEqual that considers "shape" of cycles?

2017-07-27 Thread Julian Andres Klode
On Thu, Jul 27, 2017 at 09:36:31AM -0700, howardcs...@gmail.com wrote: > https://golang.org/pkg/reflect/#DeepEqual > > "Pointer values are deeply equal if they are equal using Go's == operator > or if they point to deeply equal values." > > By the rules described here, the fact that both pointer

Re: [go-nuts] 10x latency spikes during GC alloc assist phase

2017-07-27 Thread Bakul Shah
It would still need to examine all those 50 million slices even if they are all pointing to the same array. > On Jul 27, 2017, at 10:20 AM, Joe Taber wrote: > > Bakul, > > You wouldn't even need to change the slicing semantics like that. > > Just concatenate all slices in the map into one mas

Re: [go-nuts] 10x latency spikes during GC alloc assist phase

2017-07-27 Thread Joe Taber
True. With my suggestion the mark phase would still scan the whole map, but the sweep phase would become trivial. It seems there has been some discussion in the past about this specific issue (storing millions of slice-like objects in maps). These are old threads (2014-15) so the conclusions mi

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Michael Jones
Ecstatic, based on what you said here (*"some people will never be forced to change"* and *"because Google engineers have decided"*), I believe there are a few ideas you may profitably consider about the formatting topic--ideas that you probably have not yet considered and which may ease your conce

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Jan Mercl
On Thu, Jul 27, 2017 at 10:39 PM Michael Jones wrote: > Ecstatic, ... Excellent post! Isn't it strange, that we, programmers, well used to model the problem once in term of CPU registers and raw memory, then in a pure functional style and then again in some imperative PL, to name just a few cas

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread ojucie
Ecstatic Coder, I won't take it personally, of course. Feel free to say anything you want to. Michael, great post, as always. The driver illustration is perfect. On Thursday, July 27, 2017 at 5:50:05 AM UTC-3, Ecstatic Coder wrote: > > Btw please don't take it personally. > -- You received th

[go-nuts] gopacket, libpcap timestamp precison

2017-07-27 Thread Chun Zhang
Hi, All, I am trying to write a small program to sniff packets off the wire. These packets are most TCP flows, so I'd expect SYN arrives earlier than SYN-ACK, ACK etc. I used gopacket and basically followed the official guide to get the packet and then read its metadata for timing. But to my

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread me
On Thursday, July 27, 2017 at 3:08:08 PM UTC-6, Jan Mercl wrote: > > > Isn't it strange, that we, programmers, well used to model the problem > once in term of CPU registers and raw memory, then in a pure functional > style > I don't know that purely functional actually exists: I have been try

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Matt Harden
"me": regarding purely functional programs, they can exist, but they can't actually "do" anything, since by definition, "doing" means altering some state in the outside world. But reasoning as much as possible in a functional way, and expressing your programs in this way (again as much as possible)

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Hrobjartur Thorsteinsson
but, I have to say, wow, I never realized that curly bracket placement was that important and solved so many of the problems for Google! Do you realize that the Go lang devs themselves are not actually in agreement about the original motivations for constraining the language in this way. Some quot

Re: [go-nuts] No Allman-Style, No go!

2017-07-27 Thread Bakul Shah
I have to disagree somewhat with me(!). Programming is much more an engineering discipline than a creative process. A case in point: the earlier thread today about 10x latency spike. If the latency spikes don't meet user expectation (or a formal requirement), the program is not "done". Replacing

RE: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread John Souvestre
Ø Btw here are the result of a small internet poll on indentation styles : - Allman : 7450 votes - K&R style : 5514 votes Ø … I have to wonder if a person’s choice of style might depend on which language they are using. For example, I might prefer Allman while working in C but K&R while

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Hrobjartur Thorsteinsson
That's true, so it would be more useful in C than in Go. However, please everybody stop calling it K&R style, because it is not. On Fri, Jul 28, 2017 at 1:54 AM, John Souvestre wrote: > Ø Btw here are the result of a small internet poll on indentation styles > : > > - Allman : 7450 votes > - K&

RE: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread John Souvestre
Cognitive dissonance J John John Souvestre - New Orleans LA From: golang-nuts@googlegroups.com [mailto:golang-nuts@googlegroups.com] On Behalf Of Michael Jones Sent: 2017 July 27, Thu 15:38 To: Rob Pike Cc: Ecstatic Coder; golang-nuts Subject: Re: [go-nuts] Re: No Allman-Style, No go

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Hrobjartur Thorsteinsson
This suggestion the funniest I have seen in any language: /*--*/ if x < 0 { { return sqrt(-x) + "i" }} /*-*/ Credit is "Neutrino" posted in 2014 on Stackoverflow. This is what I was looking for! Thank you Neutrino, both Go-style and Allman style fetished devs

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Dan Kortschak
Lovely post, Michael, as usual. http://photobucket.com/gallery/user/Clayskater/media/bWVkaWFJZDoxNzA1MjQzMDM=/ I ran out of pop-corn for this thread some years ago. Does anyone know where I can get some more? It must be butter soaked, cooked over coals and served in a silver tureen, otherwise I w

Re: [go-nuts] Is there some way to set value for unexported nil ptr field of a struct using reflect?

2017-07-27 Thread Matt Harden
Just to be clear, when using unsafe it's possible to do pretty much anything; reflect by itself doesn't give you this ability. That's by design AIUI. On Wed, Jul 26, 2017 at 6:53 PM feilengcui008 wrote: > Thanks for your answer :), even though the original question has been > deleted. > > I've u

Re: [go-nuts] Is there some way to set value for unexported nil ptr field of a struct using reflect?

2017-07-27 Thread feilengcui008
Ok, I got that, thanks for the clarification! 在 2017年7月28日星期五 UTC+8上午10:36:20,Matt Harden写道: > > Just to be clear, when using unsafe it's possible to do pretty much > anything; reflect by itself doesn't give you this ability. That's by design > AIUI. > > On Wed, Jul 26, 2017 at 6:53 PM feilengcu

Re: [go-nuts] Re: No Allman-Style, No go!

2017-07-27 Thread Ian Lance Taylor
On Thu, Jul 27, 2017 at 6:35 PM, Hrobjartur Thorsteinsson wrote: > > Do you realize that the Go lang devs themselves are not actually in > agreement about the original motivations for constraining the language in > this way. Some quote some one true K&R style, while it is in fact this is > not K&R

[go-nuts] Re: gopacket, libpcap timestamp precison

2017-07-27 Thread feilengcui008
Not sure whether understand your need, but if your need is the reassembly of TCP packets, you can use the tcpassembly packet in gopacket, I recently used it in my traffic replay project tcplayer , it seems working just fine. 在 2017年7月28日星期五 UTC+8上午5:20