[go-nuts] Re: Can a lambda passed to other functions be inlined by a Go compiler?

2023-10-25 Thread 'drc...@google.com' via golang-nuts
The short answer is yes, but not in this example. In your example the inline doesn't happen because `foo` is (barely) too complex so it is not inlined and the closure remains a parameter: ``` go build -gcflags=-m=2 main.go # command-line-arguments ./main.go:3:6: cannot inline foo: function too co

[go-nuts] Re: What could cause "accept tcp [::]:42796: i/o timeout" on listener.Accept()?

2023-10-25 Thread Taj Khattra
Accept() can return an "i/o timeout" (os.ErrDeadlineExceeded) if your listener has set a deadline via SetDeadline() (e.g. https://pkg.go.dev/net#TCPListener.SetDeadline for a TCP listener) On Wednesday, 25 October 2023 at 10:00:11 UTC-7 whileloop wrote: > Hi community, > > I am quite stumped by

[go-nuts] What could cause "accept tcp [::]:42796: i/o timeout" on listener.Accept()?

2023-10-25 Thread whileloop
Hi community, I am quite stumped by this error that I am getting intermittently on my Go server running on Ubuntu. The following code logs the error: conn, err := listener.Accept() if err != nil { log.Error(err) } Output: accept tcp [::]:42796: i/o timeout I have never seen an i/o timeout on a

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

2023-10-25 Thread j2gg0s
Just my guess: - when use IEE754, 18446744073709551615 will be actual stored as 18446744073709551616 (> 2<<64) - so uint64(float64(18446744073709551615)) is overflow and undefined Code: // true fmt.Println(uint64(float64(18446742974197923840)) == uint64(18446742974197923840)) // cannot convert f

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

Re: [go-nuts] Re: Go called by C: is the goroutine locked to a thread?

2023-10-25 Thread 'Bryan C. Mills' via golang-nuts
On Wed, Oct 25, 2023 at 9:58 AM Domenico Andreoli < domenico.andre...@linux.com> wrote: > On Tue, Oct 24, 2023 at 09:58:22AM -0700, 'Bryan C. Mills' via golang-nuts > wrote: > > If a C thread calls into Go, the goroutine processing that call (and > only > > that goroutine) will run on the C thread

Re: [go-nuts] Re: Go called by C: is the goroutine locked to a thread?

2023-10-25 Thread Domenico Andreoli
On Tue, Oct 24, 2023 at 09:58:22AM -0700, 'Bryan C. Mills' via golang-nuts wrote: > If a C thread calls into Go, the goroutine processing that call (and only > that goroutine) will run on the C thread. The Go runtime will initialize Is this thanks to the `lockOSThread` call in function `cgocall

[go-nuts] Question in Converting float64 to uint64

2023-10-25 Thread Xie Yuchen
Hi Guys, recently, I've been learning the number types conversion. I learned about the ieee 754 round to even when golang converts from uint64 to float64. However, when I want to convert the float64 to uint64 back, there is a different between functions: `math.Float64Bits` and use `uint64(f)`.