[go-nuts] Easily viewing cross-compiled asm output?

2022-10-02 Thread Eli Lindsey
I’m on arm64 Darwin and wanted to view the asm output for amd64 Darwin. Using a simple hello world example, this worked and output arm asm: $ go tool compile -S hello.go This worked and built a full x86 binary: $ GOARCH=amd64 go build hello.go But this failed: $ GOARCH=amd64 go tool compile -

Re: [go-nuts] There is a passage in book that is difficult to understand, can anyone help explain it?

2022-11-02 Thread Eli Lindsey
Reentrant locks make any given critical section harder to understand because you must also understand the calling pattern that led there to know which invariants have been upheld and which may have been violated due to a still-in-progress critical section higher up the call chain. For example,

Re: [go-nuts] There is a passage in book that is difficult to understand, can anyone help explain it?

2022-11-02 Thread Eli Lindsey
doesn’t encourage as much as other languages/APIs).-eliOn Nov 2, 2022, at 7:49 AM, Eli Lindsey wrote:Reentrant locks make any given critical section harder to understand because you must also understand the calling pattern that led there to know which invariants have been upheld and which may have

Re: [go-nuts] how to handle push in http2 client?

2023-01-26 Thread Eli Lindsey
The x/net/http2 client doesn’t currently support receiving push promises - https://github.com/golang/net/blob/master/http2/transport.go#L2955 The tracking task is https://github.com/golang/go/issues/18594 -eli > On Jan 26, 2023, at 11:29 AM, cheng dong wrote: > > says we do a server-push from

Re: [go-nuts] [net/http] How to capture raw client TLS handshake data?

2023-03-06 Thread Eli Lindsey
It’s not currently possible. Some of us run with patches exposing the TLS extensions to support this use case. The relevant GitHub issue is https://github.com/golang/go/issues/32936-eli On Mar 6, 2023, at 2:14 PM, Aurora wrote:Is it possible to capture the whole TLS handshake data coming from a H

Re: [go-nuts] what's the most popular kafka library to use

2023-03-13 Thread Eli Lindsey
> Is there an obvious choice here? what are people using now days (March 2023) I don’t think there’s an obvious choice, there’s three or four main libs, any of which may be good for different uses. Some color on confluent-kafka-go - it's a wrapper around librdkafka. librdkafka is the main Kafka

Re: [go-nuts] About source folder organization - Part II

2023-03-21 Thread Eli Lindsey
There are a number of different options and no right or wrong answer. This was a recent blog that I thought did an excellent job of summarizing some of the more common layouts and trade offs https://appliedgo.com/blog/go-project-layout-eli On Mar 21, 2023, at 10:28 AM, Victor Giordano wrote:Hell

Re: [go-nuts] Is there a golang download for latest patch release like 1.20.x?

2023-03-30 Thread Eli Lindsey
I’m not aware of a stable URL that always points to the latest patch release like you described (maybe there is one and someone else will chime in), but did want to mention that the json output from https://go.dev/dl/?mode=json is very useful if running in an environment where you can sprinkle i

Re: [go-nuts] ¿ Where is the source code of atomic.AddInt32?

2023-04-23 Thread Eli Lindsey
Hi Victor, This shows that the code you linked is a shim over runtime/internal/atomic: https://cs.opensource.google/go/go/+/refs/tags/go1.20.3:src/sync/atomic/asm.s;l=40 In runtime/internal/atomic you’ll find asm implementations specific to the various supported architectures. For example, here

Re: [go-nuts] [net/http] How to capture raw client TLS handshake data?

2023-07-17 Thread Eli Lindsey
It can work, but ends up requiring reimplementing a chunk of the TLS protocol parser and doing the same parsing twice per connection. I’d generally favor a three line out of tree stdlib patch over that. Skimming your linked code, you’ll also want to make sure you have proper handling of the TLS

Re: [go-nuts] simplistic web based chat solution

2023-07-22 Thread Eli Lindsey
I’m taking a stab at answering, but I didn’t quite follow your intent and may have misunderstood your question. Please let me know if that’s the case. :) > I'm having a hard time putting it into my code. Specifically, how to handle > incoming new chats message and push to all web base clients. W

Re: [go-nuts] simplistic web based chat solution

2023-07-23 Thread Eli Lindsey
> - spinning up a new chatting client goroutine (mainly the quoted code > in OP) when a new user logs in, then there will be a new net.Conn for > the client > - since I'm only doing server side programming and one server needs to > serve different clients, the only way I can think of is to store

Re: [go-nuts] Is there a pure Go packet capture and analysis tool?

2023-07-26 Thread Eli Lindsey
gopacket’s C bindings are for different ways of initially capturing the packets (libpcap, pfring, and so on). I would recommend seeing if you can create a pure Go PacketDataSource for the platform and API that you care about and reuse the rest of gopacket’s layered decoding support. gopacket doe

Re: [go-nuts] [testing] best practices for the test (client-server)

2023-08-07 Thread Eli Lindsey
net/http/httptest is a great package, either to use if your server is http-based or to emulate if you’re testing other protocols. I’ve also found io.Pipe to frequently be useful for this kind of testing. I’d recommend reading through how net/http and x/net/http2 structures their tests. -eli >

Re: [go-nuts] Question in Converting float64 to uint64

2023-10-25 Thread Eli Lindsey
Float64Bits preserves the underlying representation. The numeric value of the uint64 it returns has little significance. You’d typically use it when serializing floats, when wanting to make manual changes to the float’s representation, and so on. uint64(f) cares about preserving the numeric val

[go-nuts] Question about httptrace synchronization

2023-10-26 Thread Eli Lindsey
Example code (note that it won’t actually execute in the playground since it’s making network calls): https://play.golang.com/p/V9Z-ErjgICW My assumption was that this code is a potential data race and requires additional synchronization on t. net/http/httptrace in particular says: "Functions m

Re: [go-nuts] Go http/2 ClientConn readLoop use more memory than http/1.1

2023-11-16 Thread Eli Lindsey
> Is this an expected result that with http/2, that we will be using more > memory at the cost of multiplexing and streaming? Or am I missing something > here? They’re very different protocols, so it’s often not useful to directly compare. There are aspects of http/2 (eg. hpack state) that will

Re: [go-nuts] http2 client has no cached connections

2023-12-12 Thread Eli Lindsey
The http2 client relies on the http/1.1 client doing the dial and uses its established connections - this error shows up when the http/1.1 client has no pooled TLS connections for the http2 client to use. The issue is that the httptest server is using a self-signed certificate, the client hasn’

Re: [go-nuts] net/http: no Client API to close server connection based on Response #21978

2024-04-02 Thread Eli Lindsey
There isn’t a great way to handle this currently - we maintain out of tree patches to do something similar, though ours are h2 specific. The crux of the problem is that net currently lacks a usable connection pool API (there is some slightly newer discussion here, but it’s similar to the issue y

Re: [go-nuts] net/http: no Client API to close server connection based on Response #21978

2024-04-03 Thread Eli Lindsey
ost. Then when > the 500 is encountered stop using that transport completely and create a new > instance. Probably want to cancel any requests currently in flight. > > The connection pool is per transport. > >> On Apr 2, 2024, at 11:05 PM, Eli Lindsey wrote: >> &

Re: [go-nuts] net/http Http Server - fail with Proxy Protocol header (v1/v2)

2024-04-26 Thread Eli Lindsey
The first few bytes on a new TLS connection will be the record layer bytes denoting a handshake and the TLS version field, so 0x160301 or 0x160303. ASCII-based proxy protocol v1 will start out 0x5052 etc, and binary-based proxy protocol v2 has its own initial 12 byte signature of 0x0D0A0D0A etc.

Re: [go-nuts] mutex in slog/handler.go?

2024-05-24 Thread Eli Lindsey
Git blame may be helpful, and specifically commit 847d40d6998. It looks like code drifted from the comment.-eli On May 24, 2024, at 9:25 AM, Jochen Voss wrote:Hello,In the Go standard library, in the file log/slog/handler.go, I found the following code:func (h *commonHandler) clone() *commonHandl

Re: [go-nuts] http resp.Write & httputil.DumpResponse include extra text with body

2024-09-13 Thread Eli Lindsey
Those are sizes from chunked encoding. -eli On Sep 13, 2024, at 9:10 AM, Peter Galbavy wrote:I am trying to add some low level tracing to a client app to validate the responses coming from a SaaS platform.When I use either http's resp.Write(os.Stderr) or httputil.DumpResponse(resp, true) I see a

Re: [go-nuts] http resp.Write & httputil.DumpResponse include extra text with body

2024-09-13 Thread Eli Lindsey
ter Galbavy wrote: > > Makes sense and good to know, but for diag output is there any way to turn it > off? > > On Friday 13 September 2024 at 14:25:19 UTC+1 Eli Lindsey wrote: >> Those are sizes from chunked encoding. >> >> -eli >> >>>

Re: [go-nuts] atomic variables?

2024-11-08 Thread Eli Lindsey
Relaxed atomics can be significantly easier to misuse than they first appear. If this is something you’ll be working with, I’d highly recommend watching Herb Sutter’s ~3hr workshop on atomics - it will cover many of the things you seem interested in (overhead of atomics vs regular loads/stores on v