Re: [go-nuts] Alternative of defer?

2019-02-08 Thread Robert Engels
Sorry, but I disagree, at least in the context of Go, and the difference between errors and panics. Imagine any financial service, if the code is encountering a condition it deems should be impossible, yet is occurring, bad things will happen. Very old adage, garbage in = garbage out. > On

Re: [go-nuts] Alternative of defer?

2019-02-08 Thread Ivan Bertona
Recovering from panics is a common and IMO perfectly acceptable practice... For example in a web server where you do not want a panic that occurs while handling a request to affect other request, especially ones that are in flight. On Fri, Feb 8, 2019 at 10:47 PM Robert Engels wrote: > The way

[go-nuts] Re: Providing more detail after a nil pointer dereference

2019-02-08 Thread 'Keith Randall' via golang-nuts
27605 is more about providing the values that caused the panic, not the source location. It is still the case that even with 27605 multiple indexing operations on the same line are not distinguished (unless knowledge of the application lets you disambiguate using the values). For nil pointer

Re: [go-nuts] Alternative of defer?

2019-02-08 Thread Sam Whited
It's not pretty, but if you absolutely must write this code and can't refactor it, you can always use a closure to scope the defer: lock1.Lock() err = func() error { defer lock1.Unlock() return performOperation1() }() if err != nil { return err } performExpensiveOperation2() On Fri, Feb

Re: [go-nuts] Alternative of defer?

2019-02-08 Thread Ivan Bertona
What's suboptimal with the first one (or the second one) is that if performOperation1() panics the lock will not be released. It may or may not be a problem depending on the situation. Your assessment of defer used with locks is correct - it works well only if the lock doesn't need to be

Re: [go-nuts] HTTP client request rate

2019-02-08 Thread Valentin Vidic
On Fri, Feb 08, 2019 at 10:12:36PM +0100, Valentin Vidic wrote: > Yes, it is quite strange. I don't see it hitting any limits but > the request rate goes down. Seems it could be GC related since turning off GC gives 5x request rate with 20 gorutines: $ ./gb -duration 15s -parallel 5 http://nginx

Re: [go-nuts] HTTP client request rate

2019-02-08 Thread Valentin Vidic
On Fri, Feb 08, 2019 at 02:30:52PM -0600, robert engels wrote: > Could be many things, but a few to think about: Yes, it is quite strange. I don't see it hitting any limits but the request rate goes down. > If you run more Go routines than you have CPUs available, and the task > is CPU bound

Re: [go-nuts] HTTP client request rate

2019-02-08 Thread robert engels
Could be many things, but a few to think about: If you run more Go routines than you have CPUs available, and the task is CPU bound (which may be if the url points to a local resource), then you are going to thrash, causing worse performance. The service you are calling is not properly

[go-nuts] HTTP client request rate

2019-02-08 Thread Valentin Vidic
Hi, Can someone help me figure out why the performance (request rate) of this program goes down when I add more gorutines? $ ./gb -duration 15s -parallel 5 http://nginx Running 5 parallel clients for 15s... Requests: 217998 Rate: 14533.2/s Bytes: 133414776 Code[200]: 217998 $ ./gb -duration 15s

Re: [go-nuts] parse timestamp in Go

2019-02-08 Thread Martin Schnabel
just for future reference, there is no format for 'this' (the format op asked for). because this format does not have a period. i was just as surprised. you can try yourself: https://play.golang.org/p/wv_PDwTmEOk the documentation also states that you do not specify the fraction seconds for

Re: [go-nuts] Alternative of defer?

2019-02-08 Thread Burak Serdar
On Fri, Feb 8, 2019 at 11:28 AM vincent163 wrote: > > I am thinking about how to write programs like this: > lock1.Lock() > err = performOperation1() > if err != nil { > lock1.Unlock() > return err > } > lock1.Unlock() > performExpensiveOperation2() How about this: lock1.Lock() err =

Re: [go-nuts] parse timestamp in Go

2019-02-08 Thread Philippe DESJACQUES
Le 08/02/2019 à 01:10, Burak Serdar a écrit : On Thu, Feb 7, 2019 at 2:28 PM Rajanikanth Jammalamadaka wrote: How can I parse the following timestamp in Go? date +%y%m%d%H%M%S%N 190207202017034235995 for the ymdHMS part, you can use: time.Parse("060102150405",str[:12]) I don't know if

[go-nuts] Alternative of defer?

2019-02-08 Thread vincent163
I am thinking about how to write programs like this: lock1.Lock() err = performOperation1() if err != nil { lock1.Unlock() return err } lock1.Unlock() performExpensiveOperation2() The lock1 must be locked while performing operation1, and I need to use its result to perform operation2. Since

Re: [go-nuts] Re: [ANN] Official Go client for Elasticsearch

2019-02-08 Thread Agniva De Sarker
Much appreciated :) On 2/8/19, Karel Minařík wrote: > It is definitely on the priorities list. The API itself is generated, so > it's a matter of adjusting potential edge cases, and a bit of > administration around branches/tags. > > Karel > > -- > You received this message because you are

[go-nuts] Re: [ANN] Official Go client for Elasticsearch

2019-02-08 Thread Karel Minařík
It is definitely on the priorities list. The API itself is generated, so it's a matter of adjusting potential edge cases, and a bit of administration around branches/tags. Karel -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

Re: [go-nuts] A Measure of Hash Function Collisions

2019-02-08 Thread Michael Jones
clustering: https://www.cs.cornell.edu/courses/cs3110/2014fa/lectures/13/lec13.html careful hash functions often treat short inputs specially. iterated shift-xor alone is weak in expanding the "changed bits(s)" signal, at least by comparison to a) large prime multiply, b) good s-boxes, c)

Re: [go-nuts] Is WASM support planned in go 1.12 ?

2019-02-08 Thread Agniva De Sarker
To add to what Keith has said, Callback has been renamed to Func because the function will get called synchronously instead of being async. This is one of the major changes in 1.12. On Thursday, 7 February 2019 05:11:50 UTC+5:30, Keith Randall wrote: > > To answer the OP, wasm support is in

[go-nuts] Re: [ANN] Official Go client for Elasticsearch

2019-02-08 Thread Agniva De Sarker
Great stuff ! > The client targets Elasticsearch 7.x. Support for 6.x and 5.x APIs will be added later. Would appreciate if this is prioritized. Our ES setup use 5.x version. We would be unable to use this client if it does not support 5.x. On Friday, 8 February 2019 16:03:37 UTC+5:30, Karel

[go-nuts] panic: interface conversion: ... (types from different scopes)

2019-02-08 Thread clementauger888
Hello i was playing with the plugin mode and i met this error *panic: interface conversion: interface {} is func(string, func([]string) error) error, not func(string, func([]string) error) error (types from different scopes)* the code is a regular conversion, without test because i was not

[go-nuts] [ANN] Official Go client for Elasticsearch

2019-02-08 Thread Karel Minařík
Hi all, a new official Go client for Elasticsearch has been published to Github today: —> https://github.com/elastic/go-elasticsearch The client has been in the works for couple of months, and completely replaces the old "WIP" client in the repository. The project comes with extensive

Re: [go-nuts] Re: When would you use single quotes?

2019-02-08 Thread Jamie Caldwell
Volker / Jan / Tamás & Peter -- thank you all for your replies. On Thu, 7 Feb 2019 at 13:16, peterGo wrote: > Jamie, > > This is a question about Unicode: > > The Unicode Consortium: http://unicode.org/ > > The Unicode Standard: http://www.unicode.org/standard/standard.html > > Unicode

Re: [go-nuts] A Measure of Hash Function Collisions

2019-02-08 Thread Serhat Sevki Dincer
8 Şub 2019 Cum 11:57 tarihinde Michael Jones şunu yazdı: > ...says that in one particular test condition (8 character strings, 1M > random strings, all possible shift values) > and under one particular metric of virtue... > > x = x<<15 ^ x>>33 > > ...gives the closest overall approximation to a

Re: [go-nuts] A Measure of Hash Function Collisions

2019-02-08 Thread Michael Jones
one quick result: celeste:spin10 mtj$ spin10 -a 0,63 -b 0,63 -bins 32 -rotate ab -set 0,0,0,0 -samples 10 -trials 10 [0] best 5.683527373827505613e+01 8 0 0 0 [1] best 5.508690460484671547e+01 8 1 0 0 [2] best 5.434519430630660253e+01 8 2 0 0 [4]