[go-nuts] Re: Stop HTTP Server with Context cancel

2017-04-04 Thread Johnny Luo
func listenAndServe(ctx context.Context, srv *http.Server, errCh chan<- error) { err := srv.ListenAndServe() select { case errCh <- err: case <-ctx.Done(): } } ListenAndServe is blocking function, so the select will not happen until ListenAndServe return. and errCh become no use On Wednes

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-04 Thread Dan Kortschak
On Tue, 2017-04-04 at 18:41 -0700, utyughj...@mail.com wrote: > case in point: https://play.golang.org/p/p7WtbMZj3O Why would you return a newly allocated [c]byte pointer in fooSTUPID instead of nil? That is *not* doing what is suggested, but rather returning a more likely valid and usable value.

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-04 Thread utyughjgut
https://www.reddit.com/r/golang/comments/62cupa/is_it_idiomatic_to_return_a_badly_structured/ the example given by the OP is faulty. here is a play illustrating the possible misunderstanding of the OP or typos by the OP: https://play.golang.org/p/rt31qb9EiH but even so, the argument given by Ax

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-04 Thread Dan Kortschak
There are cases in the standard library that explicitly intentionally return, or leave, invalid values in cases when they should not be used. This being the generalised case of this question. One of the clearest examples (others don't necessarily have comments) of this is inĀ go/types/initorder.go

[go-nuts] [ANN] "Cartographer" points you at loops over maps - go forth and fix non-determinism bugs!

2017-04-04 Thread Peter Waller
Cartographer is a simple tool, it just prints out source locations of the specified packages which loop over maps. So you can audit them, and find some non-determinism bugs. https://github.com/pwaller/cartographer For anyone interested about how you might do this, the whole program is less than 6

[go-nuts] usability question

2017-04-04 Thread Vasiliy Tolstov
Hi. I'm writing libvirt binding (without cgo) based on digitalocean libvirt binding. And now we stuck at api design. What is the preffered api design for go package/binding Please read https://github.com/digitalocean/go-libvirt/issues/32 all comments and say, what api is preferred in case of user P

[go-nuts] Re: Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread Uli Kunitz
Hi Mukund, Please recognize that the Source object returned by rand.NewSource is not safe for concurrent use by multiple goroutines. Look at the documentation of NewSource in package math/rand. You are defining r as a global variable and probably call pickENI() from multiple goroutines, which i

[go-nuts] Re: Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread Dave Cheney
I think the sample program you provided is not the one which is causing the panic. For example there is no mention of Kenisis provider in the sample code you provided, but it is part of the stack trace you showed. 1. Can you reproduce the crash with the sample code you provided? 2. Can you prov

[go-nuts] Stop HTTP Server with Context cancel

2017-04-04 Thread Pierre Durand
Hello I wrote a small helper to stop an HTTP Server when a Context is canceled. https://play.golang.org/p/Gl8APynVdh What do you think ? Is it OK to use context cancellation for stopping long running functions ? -- You received this message because you are subscribed to the Google Groups "gola

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-04 Thread 'Axel Wagner' via golang-nuts
On Tue, Apr 4, 2017 at 5:18 PM, Joubin Houshyar wrote: > > > On Tuesday, April 4, 2017 at 2:34:29 AM UTC-4, Axel Wagner wrote: >> >> On Tue, Apr 4, 2017 at 12:38 AM, Joubin Houshyar >> wrote: >>> >>> Well, you've got bigger fish to fry here in your example above than >>> worrying about call site

[go-nuts] Re: Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread peterGo
Mukund, If you suspect a bug in the compiler or the standard library, compile annd run the program using the latest version or, even better, tip so that you include all known bug fixes. I couldn't reproduce your error at Go tip: $ go version go version devel +bebfd4b Tue Apr 4 06:26:11 2017 +0

Re: [go-nuts] Is it harmful to always return invalid values on a non-nil-error?

2017-04-04 Thread Joubin Houshyar
On Tuesday, April 4, 2017 at 2:34:29 AM UTC-4, Axel Wagner wrote: > > On Tue, Apr 4, 2017 at 12:38 AM, Joubin Houshyar > wrote: >> >> Well, you've got bigger fish to fry here in your example above than >> worrying about call site snafus: you should be closing that opened file in >> the error c

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Paul Jolly
> > IMO implementing such a compile check would be contrary to the "least > WTF" principle. Imagine something like > > type S struct { > f func() > } > > func (s S) Impl() {} > > func Foo() I { > return S{} > } > > m[Foo()] = true > > The compiler is able to check at compile ti

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Konstantin Khomoutov
On Tue, 4 Apr 2017 07:27:17 -0700 Ian Lance Taylor wrote: > >> When you insert a value keyed by S{}, the compiler creates a value > >> of type I which has S as its dynamic type and S{} as its value. > >> > >> The program as speficied panics with > > > > > > Apologies if it wasn't clear from my or

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Ian Lance Taylor
On Tue, Apr 4, 2017 at 3:41 AM, Paul Jolly wrote: >> When you insert a value keyed by S{}, the compiler creates a value of >> type I which has S as its dynamic type and S{} as its value. >> >> The program as speficied panics with > > > Apologies if it wasn't clear from my original email, but I und

Re: [go-nuts] Re: Go MySql - out parameter

2017-04-04 Thread Daniel Theophanes
mssql driver ( https://github.com/denisenkom/go-mssqldb ) doesn't yet support output variables, though I have support planned for go1.9. You can use rdb (I currently use it in a line of business application), but I would recommend you use https://github.com/denisenkom/go-mssqldb if possible (select

[go-nuts] Re: Use Specific json.Unmarshaler for a dynamic JSON

2017-04-04 Thread dc0d
I do not know what's the JSON! I just know it contains some certain fields, somewhere inside - some date-times, geo info (string formatted) and the like. Now parsing these data needs certain unmarshalers. But I know the name of those fields - not their position (they are not necessarily a direc

[go-nuts] Re: Use Specific json.Unmarshaler for a dynamic JSON

2017-04-04 Thread Egon
On Tuesday, 4 April 2017 15:33:19 UTC+3, Egon wrote: > > On Tuesday, 4 April 2017 13:54:34 UTC+3, dc0d wrote: >> >> Target: Assuming we want to deserialize some JSON dynamically and we want >> to unmarshal some fields using specific unmarshaling code (a >> certain UnmarshalJSON). The problem is

[go-nuts] Re: Use Specific json.Unmarshaler for a dynamic JSON

2017-04-04 Thread Egon
On Tuesday, 4 April 2017 13:54:34 UTC+3, dc0d wrote: > > Target: Assuming we want to deserialize some JSON dynamically and we want > to unmarshal some fields using specific unmarshaling code (a > certain UnmarshalJSON). The problem is using something like > map[string]interface{} there is no way

[go-nuts] Re: Go MySql - out parameter

2017-04-04 Thread dharampalsingh . bangarwa
Hi Kiril, Were you able to get this working , I am also struggling to get the Output parameters working with mssql driver . @Daniel - can i use this http://godoc.org/bitbucket.org/kardianos/rdb Thanks, Dharam On Wednesday, May 7, 2014 at 2:29:48 PM UTC+1, Kiril wrote: > > Hi guys, > Does an

[go-nuts] Re: Use Specific json.Unmarshaler for a dynamic JSON

2017-04-04 Thread Egon
What is the JSON input that you need to parse? + Egon On Tuesday, 4 April 2017 13:54:34 UTC+3, dc0d wrote: > > Target: Assuming we want to deserialize some JSON dynamically and we want > to unmarshal some fields using specific unmarshaling code (a > certain UnmarshalJSON). The problem is using

[go-nuts] Use Specific json.Unmarshaler for a dynamic JSON

2017-04-04 Thread dc0d
Target: Assuming we want to deserialize some JSON dynamically and we want to unmarshal some fields using specific unmarshaling code (a certain UnmarshalJSON). The problem is using something like map[string]interface{} there is no way to specify that. Thought Experiment: I like to have something

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Paul Jolly
> > When you insert a value keyed by S{}, the compiler creates a value of > type I which has S as its dynamic type and S{} as its value. > > The program as speficied panics with > Apologies if it wasn't clear from my original email, but I understand why this panics; I further acknowledge the behav

Re: [go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Konstantin Khomoutov
On Tue, 4 Apr 2017 02:40:31 -0700 (PDT) Paul Jolly wrote: > *I couldn't find anything previously on the question below, but as > ever would appreciate any pointers to prior questions/issues etc.* > > Consider the following (playground > ): > > > packag

[go-nuts] Interface-keyed maps and non-comparable dynamic key values

2017-04-04 Thread Paul Jolly
*I couldn't find anything previously on the question below, but as ever would appreciate any pointers to prior questions/issues etc.* Consider the following (playground ): package main import ( "fmt" ) type S struct { f func() } func

[go-nuts] Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread Dave Cheney
Have you built your program with the -race flag and confirmed there are no data races in your program? -- 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 golang-nut

Re: [go-nuts] Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread Ian Davis
What version of Go are you using. I ran your code a few times and could not reproduce on my version which is a few commits off of tip. On Tue, 4 Apr 2017, at 09:37 AM, Mukund 8kmiles wrote: > Hi, > > It is a basic index out of range but inside *math.Rand() *and not in > objects that I creat

[go-nuts] Random Number Genaration - Golang -- Error/Bug

2017-04-04 Thread Mukund 8kmiles
Hi, It is a basic index out of range but inside *math.Rand() *and not in objects that I create. Could that be a bug ? I have given my source, below. Any help or pointers is appreciated panic: runtime error: index out of range goroutine 32 [running]: panic(0x7d5780, 0xc420010140) /opt/go/src/runt