Re: [go-nuts] Tracking which connection is used to make an HTTP request

2022-10-30 Thread Christian Worm Mortensen
Hi Konstantin Thanks for the reply - this is exactly what I needed! It even seems like tls.Conn has a function NetConn that allows me to get my net.Conn back again. So for anyone stumbling on this in the future, I think this is the way to solve it: * Make the customer TLS dialer dial a TCP connec

[go-nuts] Tracking which connection is used to make an HTTP request

2022-10-12 Thread Christian Worm Mortensen
I have created an http.Client with a custom TLS dialer. The custom TLS dialer creates a *tls.Conn and while doing this, it logs out a lot of information such as which server is used. Now, when I make an HTTP request, I want to log out which dial produced the *tls.Conn the HTTP request ended up

[go-nuts] Finding a small memory leak

2021-07-05 Thread Christian Worm Mortensen
I want to hear if anybody has an idea on how I can find a very small memory leak in a Go program? The program is a service running for days and weeks. I am not even 100% sure there is a memory leak, but when I look at the memory usage graphs based on data from runtime.ReadMemStats it looks l

Re: [go-nuts] Re: Virtual time for testing

2021-02-02 Thread Christian Worm Mortensen
://github.com/golang/go/issues/44026 Thanks, Christian On Mon, Feb 1, 2021 at 11:54 AM roger peppe wrote: > > On Sat, 30 Jan 2021 at 20:12, Christian Worm Mortensen > wrote: > >> Hi Mike, >> >> Thank you for your consideration. I think you exactly got the essence of &g

Re: [go-nuts] Re: Virtual time for testing

2021-01-31 Thread Christian Worm Mortensen
I ended up creating an issue on this: https://github.com/golang/go/issues/44026 On Sat, Jan 30, 2021 at 9:12 PM Christian Worm Mortensen wrote: > Hi Mike, > > Thank you for your consideration. I think you exactly got the essence of > my question: How do I wait on all go routines t

Re: [go-nuts] Re: Virtual time for testing

2021-01-30 Thread Christian Worm Mortensen
rg/src/net/http/cookiejar/jar.go#L159 >> So while technically Jar.Cookies is never tested the >> risk is basically nil. >> >> V. >> On Thursday, 28 January 2021 at 22:15:50 UTC+1 Christian Worm Mortensen >> wrote: >> >>> Hi! >>> >

Re: [go-nuts] Re: Virtual time for testing

2021-01-28 Thread Christian Worm Mortensen
ote: > Try something like > github.com/facebookgo/clock > > > On Thursday, 28 January 2021 at 21:15:50 UTC Christian Worm Mortensen > wrote: > >> Hi! >> >> Suppose I want to unit test this function: >> >> func generator() <-chan in

[go-nuts] Virtual time for testing

2021-01-28 Thread Christian Worm Mortensen
Hi! Suppose I want to unit test this function: func generator() <-chan int { ret := make(chan int) go func() { for i := 0; i < 10; i++ { ret <- i time.Sleep(time.Second) } }() return ret } What is a good way to do that? One way is to do it is like this: func testGenerator() { start := time.Now(