74,487 questions
1
vote
0
answers
30
views
golang issue when parsing data to bson for mongodb
I am having a strange (to me) an issue with golang mongodb connector. The current problem is that I have a db retrieval function that actually returns no errors, but the struct expected is just not ...
0
votes
0
answers
37
views
Go code using WMI returns inconsistent USB port count; how to reliably get fixed physical USB ports?
I'm trying to get the number of physical USB ports on a Windows machine using Go and WMI. I wrote the following code using ole and oleutil:
func GetUSBCount() (int, error) {
runtime.LockOSThread()
...
6
votes
1
answer
441
views
Invalid settings: setting option "vulncheck": invalid option "Prompt" for enum
the default option of go.diagnostic.vulncheck
it's warning "Invalid settings: setting option "vulncheck": invalid option "Prompt" for enum".
haven't find any other ...
3
votes
1
answer
83
views
How to chunk code at semantic boundaries when a single AST node exceeds the chunk size limit?
I'm building a code indexing tool for LLMs using tree-sitter in Go. The goal is to split source files into chunks (~600 lines) that respect function/class boundaries for better LLM context.
When a ...
1
vote
1
answer
105
views
go exec.Command is not finding "source" command in my $PATH variable
I am beginner in go and i want to make a virtual environment for python using it.the .venv folder creates with no error but it can't be activated.Here is my code
package main
import (
"fmt&...
Tooling
1
vote
7
replies
125
views
What is the idiomatic way to organize shared helper functions in Go projects?
In JavaScript projects it's common to keep shared helpers in `helpers/`, `utils/` or `common/` (logging, filesystem helpers, string helpers, etc.). In Go I’ve noticed different conventions.
What is ...
Best practices
0
votes
2
replies
70
views
How to verify webhook signatures from multiple providers (Stripe, GitHub, Shopify, etc.) in Go?
I'm building a webhook handler that needs to accept webhooks from multiple providers (Stripe, GitHub, Shopify, Twilio, etc.). Each provider uses different signature verification methods:
- Stripe: ...
-1
votes
0
answers
98
views
Implementing pagination for API results [closed]
I am building a web application in Go (using the standard net/http library) that fetches a list of popular films from the TMDB API. Currently, I fetch and display all films at once, but I want to ...
1
vote
1
answer
60
views
How to partially override decoding behavior using Mongo Golang Driver v2
The timeCodec in the Mongo driver throws an error when decoding doubles into time.Time fields. I'm dealing with legacy data that stores time as a double and it's impractical for me to migrate ...
1
vote
0
answers
77
views
How to organize message compression before publishing and decompression when reading on the consumer in the NATS message broker
colleagues!
- I use the "nats" message broker in my Golang project.
- Currently, when using "NATS," large messages aren't compressed at all, causing the producer to crash with an ...
0
votes
1
answer
95
views
How to detect applications that are not visible in screen capture from a Chrome Native Messaging host?
I’m building a Native Messaging Host in Go (Windows/macOS) for an online proctoring app. The Chrome side records the screen, and the native host should detect if apps are running but not visible in ...
Tooling
2
votes
2
replies
70
views
Go server and godot P2P connection with out port forwarding
This days me and my friend made a multiplayer game in godot. The server is written in go using protobaf. To test the multiplayer, i used ngrok. I know we can use port forwarding but i thought ngrok is ...
1
vote
0
answers
105
views
go telnet send string
I need to send commands by telnet to a matrix switcher from Atlona (though, I suppose, it's not a problem with a device, but anyway).
One of commands is x4AVx5.
When I send it from terminal, it works. ...
Tooling
0
votes
3
replies
51
views
lazyvim, golang with goimports: is it possible to use a local config for goimports?
I am working on a module called automat.
When I save my go file, it's being reformatted from:
package cmd
import (
"context"
"fmt"
"os"
"strings"
&...
Best practices
2
votes
4
replies
82
views
Formatting time based on system locale in Go
I want to show the user a timestamp based on their preference, i.e. the system locale. I want to format the time depending on if they're using a time locale that normally shows a 12-hour time, or 24-...