73,815
questions
0
votes
0
answers
30
views
How can I marshal a struct into JSON where one string field is streamed from an io.Reader containing raw text?
I have a structure like:
{
Foo int `json:"foo"`
BigString io.Reader `json:"bigString"` // I want this to be encoded as a JSON string
}
And I would like to Marshal this into ...
-2
votes
0
answers
18
views
Visual Studio Code ignores GO ENV when installing tools
I'm working on a fresh install of Go from Homebrew on a M1 Mac. Had some conflicting setups from working with different projects and teams and tried to start over.
It's version 1.22.7 of GO - ...
-1
votes
0
answers
14
views
How to Perform GET/POST Requests to a Server Using Kerberos Authentication in Go? [closed]
I'm working on a project using Go, and I need to make GET and POST requests to a server that requires Kerberos authentication. I've tried looking into libraries and examples, but I'm still unclear on ...
0
votes
0
answers
22
views
net.PacketConn ReadFrom, how to distinguish packets
The documentation for net.PacketConn ReadFrom method states that it reads a packet from the connection.
If my buffer is smaller than a packet how do I know the packet boundaries?
I thought of the case ...
0
votes
0
answers
15
views
Is there a way to apply modifiers inside an array in gjson?
The library tidwall/gjson allows me to parse json string and apply modifiers on it (a custom function on the value) but I dont see a way to apply a modifier on a value inside an array of structs.
...
0
votes
0
answers
22
views
How to handle Ctrl+C when executing a process using Go Docker SDK?
I have a Docker container running indefinitely with a default command tail -f /dev/null that I created and started using Go Docker SDK:
...
config := &container.Config{
Image: "...
-3
votes
0
answers
21
views
Should I use member or non-member functions when breaking constructors in Go? [closed]
Suppose I have a big, complex struct Foo.
type Foo struct {
// a big, complex object...
}
It will be created with the constructor function NewFoo(). Since the object is big and complex, NewFoo() ...
2
votes
0
answers
29
views
How to refresh a token when token expires in a go backend application
In my go backend application I generated a token when my app is initialised.And I want to use this token as a global variable for further authentications.
type Token struct {
Name string
...
1
vote
0
answers
16
views
Firebase FCM push notification is not working on ios for Golang
I'm sending a message like this for Golang to send notifications via all platforms,
for _, receiver := range receivers {
msg := &messaging.Message {
Notification: &messaging....
0
votes
0
answers
15
views
CalcDistance Deprecated: How to Calculate Vector Distance in Milvus SDK?
I encountered an error when trying to calculate the distance between two vectors using the CalcDistance():
service unavailable: CalcDistance deprecated.
I am using milvus-sdk-go version v2.4.1 and ...
-3
votes
0
answers
37
views
How to add a caching mechanism to the Abstract Factory pattern in Golang [closed]
How to add a caching mechanism to the abstract factory pattern in Golang
I have already written a simple abstract factory pattern, with a general factory and general products. The requirement is to ...
0
votes
1
answer
42
views
Go func for running external command, occasionally getting error: file already closed
My function
func RunCommand(cmdPath string, cmdArgs string) (error) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
cmd := exec.CommandContext(...
1
vote
0
answers
41
views
why default attribute must also be computed? [closed]
I'm using the terraform plugin framework.
Here is a simplified schema:
func (t *T) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = return schema....
1
vote
0
answers
28
views
Unable to connect to Postgres StatefulSet in kubernetes cluster from go web server
I have a web server in Golang that connects to Postgres as a StatefulSet. However, I am getting an error with the connection where there is no such host found. The web server was created using ...
-2
votes
0
answers
39
views
Why do I need to run `go mod tidy` when I upgrade to Go 1.22? [duplicate]
I recently upgraded from Go 1.18 to Go 1.22. When I try to build now, I get the error
go: updates to go.mod needed; to update it:
go mod tidy
When I run go mod tidy, it makes changes in my go....