74,469 questions
1
vote
0
answers
90
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.
...
Advice
0
votes
3
replies
164
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 ...
Tooling
0
votes
0
replies
85
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 ...
1
vote
1
answer
124
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: ...
-1
votes
1
answer
95
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 ...
2
votes
1
answer
84
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,
...
-3
votes
1
answer
130
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 ...
Advice
0
votes
6
replies
134
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) > ...
2
votes
0
answers
81
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 ...
Advice
0
votes
2
replies
62
views
golang implementation of phpserialize in grahamgreen contains a bug
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 ...
Advice
0
votes
1
replies
115
views
I want to sell/forward unused inventory/request from the publisher for a admanager
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. ...
1
vote
0
answers
93
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 ...
Tooling
0
votes
0
replies
130
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 ...
1
vote
1
answer
171
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 ...
Best practices
0
votes
2
replies
179
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 ...