Category "go"

Unmarshalling Dynamic JSON Data With Overlapping Fields in Golang

Sorry If i'm posting a question that has already been answered, but I can't seem to find any similar situations on here. I have a websocket client that receives

Extract tags from Go struct as a reflect.Value

I'm trying to extract tags from a certain Value which is a struct. I am able to get the fields of the struct but unable to extract the tags. What am I doing wro

Extract tags from Go struct as a reflect.Value

I'm trying to extract tags from a certain Value which is a struct. I am able to get the fields of the struct but unable to extract the tags. What am I doing wro

kubernetes go sdk simple demo

the demo source code package main import ( "fmt" "time" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/informers" "k8s.io/client-go

Go boltDB query using bolthold

I am trying to create a query for boltDB using Go. I have to have a query that checks for the roles and the tenantID. Basically the item has to always contain t

How to redirect os.Stdout to io.MultiWriter() in Go?

I am writing a Test function that testing go program interacting with a command line program. That is os.Stdio -> cmd.Stdin cmd.Stdin -> os.Stdin I could

embedding golang server with flutter

I have web server written in golang which uses graphql package gqlgen and gorm for database. Since golang can be compiled and run on android I wanted to create

Visual Studio Code's "Run Test | Debug Test" option missing from unit tests

I used to see "Run Test | Debug Test" links top of every test function in VS Code for Go. But they are missing now. How can I re-enable them? This picture show

Acknowledge messages in NSQ

I'm new to NSQ and was wondering whether it is possible to acknowledge that a message was consumed (just like in Google PubSub). I'm using Golang, and while goi

Initializing objects in GoLang - Heap/stack does that concept exist?

I just started with GoLang. I have noticed there are some initializations like this agentUi := &f.Foo{ Reader: os.Stdin, Writer: o

Go binary.Read into slice of data gives zero result

I want to read and write binary data to file and my data is simply slice. The encoding part is working, but my decoding via binary.Read gives zero result. What

In Go generics, how to use a common method for types in a union constraint?

I'm trying to understand the usage of the type union constraint in Go generics (v1.18). Here is the code I tried: type A struct { } type B struct { } type AB

How to measure RTT/latency through TCP clients (created in GoLang) from a TCP server created in GoLang?

so I am hosting a TCP server through GoLang and then I want to connect to my TCP server using multiple TCP clients and measure the RTT every time a new client i

How to make a one-time payment in Stripe?

I am trying to make my site do a one time payment and verify, /payment/confirm will verify the payment went through and add the item to the current user, and /p

Passing file from JavaScript to Go server

I am trying to pass a set of FORM values from client to server. FORM values include files, user names and other details as well. how do i decode the file in the

Ignoring an object in struct is nil and not when it's an empty array

Is it possible to only use omitempty when an object is nil and not when it's an empty array? I would like for the JSON marshaller to not display the value when

kubectl substring match using go-template

I am trying to find a way to match a substring in the go-template in kubectl. I am only able to find operators like those listed below, however, none of them is

How can you read POST data from a javascript XMLHttpRequest in Golang?

Here's the javascript function called: function cwk_submit_form() { var form = document.getElementById("FORM_ID") var XHR = new XMLHttpRequest(); con

Ho to debug Go app with DLV and MODD on Docker

I'm running a Go app on the Docker and want to use VSCode to debug it via DLV at the same time using MODD for app rebuild. So far I cannot figure out how to con

Appending values to existing values of environment variables in go

How can I append another value to an existing value of a go environment variable? If CGO_CXXFLAGS has the value "-I/blah/blah" Since the following doesn't work