74,456 questions
Score of -2
0 answers
81 views
Go net.Conn.Close() hangs forever in poll.(*FD).Close (semacquire) with no goroutine using the socket
Why would a TCP connection's Close() never return when nothing is reading from or writing to that socket? We've seen this three times in production, and only a restart fixes it.
Environment: Go 1.26 , ...
Score of -6
0 answers
91 views
Best practice to implement goleak for large codebase [closed]
I have a really large codebase and i want to implement uber/goleak into it. The problem is that i have multiple go packages in my project and now adding a new goleak_test.go file into each package ...
Score of 3
1 answer
151 views
How do I constrain a generic type to allow struct types that embed a given type?
I have a base struct like this:
type State struct {
Alerts []string
}
And two structs that embed it, like this:
type StateA struct {
State
A string
}
type StateB struct {
State
B ...
Score of -2
1 answer
111 views
Trying to Improve performance (throughput+latency) on my redis clusters clone written in Go [closed]
I recently built a key-value store (redis compatible, for the most part) in Golang. It uses Docker containers to simulate redis clusters / cluster nodes. I benchmarked it and used the pprof package to ...
Score of 0
1 answer
104 views
K6 - Split dataset among VUs without overlap
I am using the K6 tool to perform some load test on some of my services. I have a dataset of captured requests that I'd like to replay that is quite big and thus I'd like to use the sharedArray ...
Score of 0
2 answers
260 views
How to judge which context timed out
Studying Go now, not my 1st language. I think I faced a subtle conflict between idioms. Say I did this:
//Returns context.DeadlineExceeded as error if failed because ctx timed out.
func ...
Score of -3
0 answers
175 views
go 1.27 might modify go.work.sum on start?
I have a project using go.work, I upgraded to go 1.27 recently, and seems when start go application, it might change go.work.sum automatically sometimes, this has happened a few times in last 10 days.
...
Score of 1
1 answer
103 views
How to properly trigger DTO validation in Fuego
I am using the Fuego in GIN for my project. I have defined DTO structs with validation tags. Here is my struct:
type GetAllUserQuery struct {
Limit int `query:"limit" validate:"...
Score of 1
1 answer
223 views
How should a JSON parser represent JSON numbers in Go?
I'm implementing a JSON parser. According to JSON rules, a number can be an integer, a negative number, a decimal, or use exponent notation, like
42, -42, 3.14, 0.5, 1e10, 2.5e-3
I currently have a ...
Score of 2
0 answers
181 views
Are there any performance implications of Pub/Sub message ordering on the publisher only?
I am maintaining an internal Go library, which has a pubsub package. Currently, it doesn't support message ordering, but I would like to enable it. I want to make it as simple as possible by using ...
Score of 2
1 answer
160 views
How to change the color of window caption in Gio UI on Wayland
I'm looking at golang library https://gioui.org/
When I run a hello world example:
package main
import (
"image/color"
"log"
"os"
"gioui.org/app&...
Score of 1
1 answer
170 views
How can I generate human-friendly numeric scale values between two float64 values in Go?
I need to generate a set of evenly spaced numeric values covering a given range. This is mainly intended for things such as chart axes, scales, thresholds, and similar UI representations.
Simply ...
Score of 2
1 answer
142 views
How to triage json.SemanticError when using encoding/json/v2?
When using the new encoding/json/v2 package, and unmarshaling some JSON, it will potentially return a json.SemanticError error.
As far as I can see, json.SemanticError is returned when the JSON is ...
Score of 1
2 answers
158 views
How to call Go WASM from a TypeScript React frontend?
I am working on a web app with the following architecture:
The frontend is a React app written in TypeScript.
The "backend" is written in Go, and compiled to WASM for distribution with the ...
Score of -1
1 answer
595 views
How to redirect a runtime fatal error to a logger?
In a Go program I got this error message:
fatal error: concurrent map writes
The message is shown in the terminal window of VS Code. But in my log there is nothing, which make sense because log....