[go-nuts] panic in CBCDecrypter

2017-09-14 Thread Johnny Luo
Hello Gophers, I have wrote some encryption and decryption code recently and find out in cbcDecrypter , and cbcEncrypter provided by runtime, it panic instead of return error, thus I need to used defer to recover from the panic , if it ever happens The question is why it is implement in t

[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

[go-nuts] Re: Unexpected behavior with panic/defer/recover

2017-03-28 Thread Johnny Luo
That's kind of expected behavior , "*1. A deferred function's arguments are evaluated when the defer statement is evaluated." * refer to https://blog.golang.org/defer-panic-and-recover On Wednesday, March 29, 2017 at 9:48:52 AM UTC+11, Stefan Engstrom wrote: > > Playing with recovery from a panic

[go-nuts] Re: Max age for TCP connection

2016-09-13 Thread Johnny Luo
Hi David, I saw similar solutions using DNS to add / remove node from cluster, the client side spin up a go routine keep resolving the DNS in an interval, if it find new ip appears in DNS record, add it to the pool , when ip address disappear from the DNS, it removes from the pool.