74,461 questions
Score of 0
0 answers
128 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
0 answers
72 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 2
1 answer
173 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
115 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
127 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 0
0 answers
98 views
My login handler is being called every time I call another endpoint [closed]
I created a simple method for the app data struct in Go:
func (a *app) route(s *store.Storage) *chi.Mux {
tokenAuth := jwtauth.New("HS256", []byte(s.JWTSecret), nil)
mux := chi....
Score of 1
1 answer
139 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
115 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
0 answers
144 views
The return value is ignored without warnings by staticcheck (SA4017)
This error puzzles me, and I believe a more in-depth analysis could help clarify the issue: I cannot say for certain whether the behavior described below is legitimate or an actual error in ...
Score of 1
2 answers
135 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
481 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....
Score of 2
2 answers
360 views
How can I implement Java-like enums in Go?
Unlike Go's iota-based enums, Java enums are singleton objects. Each enum constant is a unique instance that can carry additional state and behavior, while also providing name(), ordinal(), values(), ...
Score of 1
1 answer
248 views
Supabase Go: invalid character 'B' looking for beginning of value
I am working on a web crawler using Go and Supabase. This section of code throws an error when the length of the newLinks slice is above a certain number -- I haven't been able to determine what that ...
Score of 4
0 answers
283 views
I have an fs.FS, and use WalkDir. How can I get the "real" full path to an entry it finds?
In the past I've used the version of WalkDir that is not based on fs.FS, but I recently tried changing to the fs.FS-based one so that I could more cleanly do unit testing. But now I feel like I'm not ...
Score of 0
4 answers
363 views
How can I check whether a string contains only digits in Go? [duplicate]
In Python, I can use the str.isdigit() method to check whether a string contains only numeric characters.
For example:
"12345".isdigit() # True
"123a".isdigit() # False
&...
Score of 1
0 answers
124 views
Chromedp initialization fails on warmup with "chrome failed to start" in Windows
package browser
import (
"context"
"log"
"os"
"os/exec"
"time"
"sync"
"path/filepath"
"...
Score of 2
1 answer
173 views
How to convert to a different type depending on architecture?
I am trying to fix the compilation of file overlay/tun_freebsd.go in module github.com/slackhq/nebula on armv7 FreeBSD. This file uses the syscall.Iovec structure, which is defined as
type Iovec ...
Score of 1
1 answer
195 views
Goroutines leaking after context cancellation in fan-out/fan-in worker pool
I have a fan-out/fan-in worker pool that's supposed to stop all workers when the context is cancelled, but under heavy load with short timeouts, the goroutine count keeps climbing and never recovers.
...
Score of 0
1 answer
232 views
httpclient and (decorating) middleware in golang
I am trying to grasp (and sofar failing) to exactly grasp how the following code example works. It wraps (decorates) a standard http.client with 2 middleware functions (Logger and BasicAuth) that are ...
Score of 0
0 answers
132 views
How to watch files in Go with debouncing and glob pattern support?
When using fsnotify directly in Go, saving a single file triggers 4 to 5 raw events per save. For example saving a file in VSCode produces WRITE, CHMOD, WRITE, RENAME and CREATE events all from one ...
Score of 1
1 answer
205 views
Error when running a .exe Go program if I add a line break in the import
I'm running into a strange error when running the .exe that I built from a simple Go script I'm making, when I try to run the .exe it gives the following error and deletes the .exe file:
Translation: ...
Score of -1
1 answer
107 views
Compile code from executed command in code
I'm developing a hacking system that involves compiling hacking scripts to be injected in a CTF server. My goal is to compile each script from executing go build from Go code because the CTF server ...
Score of 2
1 answer
103 views
Gotk4 NewMessageDialog doesn't take the message_format argument
I use github.com/diamondburned/gotk4/pkg/gtk/v4. I'd like to create a modal dialog, like this:
dialog := gtk.NewMessageDialog(
&window.Window,
gtk.DialogModal|gtk.DialogDestroyWithParent,
...
Score of -3
1 answer
151 views
The correct way to save the first error of multiple goroutines using a mutex
I'm writing a function that gets student grades in parallel goroutines and returns their arithmetic mean at the end. If at least one student has an error, the function should return the first error ...
Score of 0
3 answers
196 views
golang error handling code example clarification
I am reading up about wrapping and unwrapping errors when doing a chain of calls. On this topic I came up the following snippet of code.
err := controller()
stack := []error{err}
for len(stack) > ...
Score of 2
0 answers
102 views
JSONPath to target root based on conditional
My goal is to apply an Overlay to an Openapi Document.
The Overlay Specification exemplifies the usage of "traits".
E.g.: given the following document:
openapi: 3.1.0
info:
title: API with ...
Score of -1
0 answers
69 views
golang implementation of phpserialize in grahamgreen contains a bug [closed]
The following test fails on golang , because the library
"github.com/grahamgreen/phpserialize"
wrongly escapes single quote characters.
The working library which does not produce an error ...
Score of -1
0 answers
120 views
I want to sell/forward unused inventory/request from the publisher for a admanager [closed]
Can anyone give me any idea how to implement this system inside a adnetwork !
I have the implementation for DSP with open RTB 2.5.
But now I want to redirect my unused inventory/request to other SSPs. ...
Score of 1
0 answers
117 views
How to access a Go library (Pdfcpu) in Elixir using Wasmex?
I have an Elixir module in which I am trying to call out to Pdfcpu to modify existing PDFs. Pdfcpu is written in Go and has a CLI and an API, and I am trying to use the API. I am using Wasmex to run ...
Score of 0
1 answer
175 views
Key-Value to store different types of values
So, I am implementing a Block Storage Engine in Go and go stuck at the Database part to store Manifest (file) information and an Index Table (a map to store each block information). I was thinking of ...
Score of 1
1 answer
193 views
How to make generics work with interfaces and pointer receivers
I'm trying to use a generic function to make a value, conforming to a specified interface. It won't compile because one of the methods takes a pointer receiver.
Code:
package main
// implyType is one ...
Score of 0
1 answer
207 views
What is the best way to the sync.Once.Do() in Go?
I am coding a server in GoLang that allows multiple clients to connect to it and each time a client sends a message to the server that message is propagated to all of the other clients. I came up with ...
Score of 0
0 answers
100 views
Golang x509.VerifyOptions CertificatePolicies are not validated during certificate verification?
In Go 1.24.0 there is an additional parameter in x509.VerifyOptions to be included when verifying X.509 certificate. The problem is that if my X.509 ceritificate doesn't contain any policies or ...
Score of 0
2 answers
103 views
Go generics where value is comparable and pointer-to-value has methods
I have a generic struct that requires passing a generic type that fulfills the constraints where the value is comparable so I can use it in a map index, and the value implements Scanner, ie. type ...
Score of 0
1 answer
164 views
How do I delete a slice element
I'm in the process of learning Golang, and I'm currently trying to create a Todo project.
My knowledge is limited to the GO base.
Please take a look at my code and tell me how I can delete a task.
The ...
Score of 0
4 answers
283 views
Programmer owns the architecture, AI implements crate-level modules in Rust — how does this compare to other languages?
After working on several Rust projects with AI assistance, I want to share a division of responsibility that has worked well in practice, and ask whether others have found the same — or a better ...
Score of 3
0 answers
177 views
go/ast, insertion in file.Decls produces invalid code because of comment
I want to create a new struct embedding original struct. But if original struct has comment, it gets placed in the middle of embed struct declaration.
Example code:
https://go.dev/play/p/8xqxpmNy2Qj
...
Score of 1
1 answer
114 views
How do I order documentation for package declarations in go
Given a package layout as follows:
.
└── pkg
└── pkg1
├── a.go
├── b.go
└── pkg1.go
It's possible to write documentation for the package declaration that appears in the ...
Score of 2
1 answer
173 views
Why does adding fmt.Printf change the equality result of two interface variables holding empty structs in Go? [duplicate]
I'm observing a strange behavior in Go where the presence of a fmt.Printf statement affects the boolean result of an interface comparison.
Env:
go version go1.25.6 darwin/amd64
package main
import &...
Score of 0
2 answers
179 views
Forcing Go to not use the gold linker
I'm trying to build a Go package in Flathub's CI for an aarch64 Linux architecture. The build is failing while compiling a C dependency:
# github.com/rclone/rclone
/usr/lib/sdk/golang/pkg/tool/...
Score of 1
0 answers
243 views
Delve debug go app in docker container with network_mode host
I want to debug my go code which is mounted into a docker container. Delve is installed inside the container.
I am using goland by jetbrains.
Everything works fine as long as I don't use the container ...
Score of 0
7 answers
472 views
Which programming language is best for learning System Design?
I’m planning to start learning System Design, but I’m a bit confused about which programming language I should focus on for it.
Most of my experience so far is with C++ and JS, but I often see people ...
Score of 0
1 answer
91 views
Is Youtube V3 IfNoneMatch is a no-op?
Considering the following code, I expect the call to return an error when the Etag that is provided is the same as the remote one.
But when testing it does not really matter if it match or not.
func (...
Score of 0
0 answers
125 views
BigQuery Storage Write API: "context deadline exceeded" only on low-frequency table
Problem
I'm using the BigQuery Storage Write API (Go managedwriter package) to upload data to three tables with very different ingestion rates:
Table
Frequency
Record Size
A
~10 records/sec
Several KB
...
Score of 1
1 answer
100 views
Debug Golang dockerized project tests
I have a Golang project, a single page application in React, where golang works as static files server and API. The application can be run using docker compose up and npm run in the web folder.
Here ...
Score of 0
3 answers
161 views
Project or features suggestion to add to my project to impress company or CEO
I see everyone is doing the same project ecom or some learning platform, streaming platform or social media. can anyone suggest me a unique one. I am a fresh go-lang developer (has done ecom as my ...
Score of 0
1 answer
129 views
Accessing the individual words of the content a file
I am working on a project whereby I want to access the individual words in a file and not the individual character eg. "Welcome to my world" should be equal to "Welcome" "to&...
Score of 0
4 answers
176 views
How can I safely implement a progress bar in a concurrent Go port scanner?
I wrote an open port scanner in Go. For local adresses scans are instant. However, when I scan an external address it takes a bit longer, and I want to see the progress. I tried to implement a ...
Score of 2
0 answers
110 views
Go RPC streaming send not working properly when optional values not provided
I am developing an RPC streaming endpoint in Go with RPC code generated through thrift. I am having an issue where clients aren't receiving my send calls when optional values aren't provided in my ...
Score of 0
0 answers
147 views
selenium/Edge driver fills up memory in golang application
We have a golang web application which is using msedgedriver.exe to convert HTML to PDF. For each user session we create a new Edge Webdriver and Quit when the session terminates.
Our problem is, that ...