Category "go"

Go rest api using GIN Framework returning status code 400

I am trying to write a rest endpoint using gin which should return status 200. I have coded it as well in the same way, but am getting status 400. My code is as

Dynamic prometheus labels in Gauge

I wonder if/how it's possible to add dynamic labels. I don't know the key or the quantity of the labels which I would like to add to my gauge values. What I tr

Getting Go to recognize when new line is added to a TOML config file

I am trying to create a simple cli tool in Go using a TOML config file. I want to be able to store frequent commands I use on the command line for other tools,

How to print UTF-8 (or unicode) characters in Go (golang) on Windows

Let's have a look at this: ✓ Hello, 世界 As you can see there is a unicode checkmark and chinese/japanese characters. In go, If I use MSYS

How to get route inside middleware go-chi

To check authorization i need to know the route inside the authorization middleware. I checked docs from go-chi and did it that way: func Authenticator(next htt

Golang comparing two yaml files and updating them

Im a newbie in golang. I am trying to compare two yaml files and update the 2nd file's value if there is any new value in 1st yaml for that particular key. So t

How to access JWT sub-claims using Go?

I need to retrieve the values of sub-claims from a JWT in Go. I have (legacy) JWTs I need to parse in go, which contain a custom claim "data" which holds an Js

How to fix parsing go.mod module declares its path as "x" but was required as "y"

I am working on a go project, which has a dependency on original-project. I now want to change the behavior in this project by modifying original-project. So I

How can I get the client IP address and user-agent in Golang gRPC?

I set up a series of gRPC requests and responses which all work fine, but I'm stuck when I try to get the client IP address and user-agent who is calling my gRP

Golang: statically finding all strings in code

I would like to parse a package and output all of the strings in the code. The specific use case is to collect sql strings and run them through a sql parser, bu

Split a string only by the first element in golang

I'm trying to parse git branch names and split them so I can seperate the remote and the branch name Previously I just split on the first slash: func ParseBra

GCP logs show function "Function execution took xxx ms. Finished with status: response error" whenever my header status code is not 200

As stated in the title, whenever I set my response header to be any status code besides the default (200), I receive a response error in my logs. This did not h

how to get lonely value from a slice golang [duplicate]

I want to create a function that can retrieve data that has no duplicates from a slice an example of a slice that will be processed: number1 :

Golang WebSocket connection

I started learning Golang. And I have this project, where I need to stream some data from API via WebSocket connection, and print it in the console. And the t

cpu / memory amount not populated in core.v1.Pod.PodSpec

Using the following code: func GetPods(clientset *kubernetes.Clientset, name, namespace string) ([]corev1.Pod, error) { list, err := clientset.CoreV1().Pod

How to run go file on vscode?

I can't run the go program on vscode on my Win11 computer (no run button, pressing Ctrl+F5 or F5 doesn't work,like this: vscode ) and I can't debug it. It's not

Go ReadString issues: The filename, directory name, or volume label syntax is incorrect

can anyone figure this out? I think the problem might be in the readstring() argument when being passed to the create file function. I tried resolving it by str

Golang: Unzip files in Go gets char encoding problems in the files names when file has been zipped in windows

I´m trying to unzip files in Go (Golang) using the zip lib. The problem is that when the zip file has been zipped in windows all special characters get me

not compatible with reflect.StructTag.Get

I was working in Google CLoud and all was fine.. but when I clone all my project in my PC, I have this messages in every JSON struct. struct field tag bson:"ed

Golang 'exec.Command' treat single quote parameter special?

I am refer to the post How to execute system command with unknown arguments? to run a jq command on my ubuntu shell. Below is the code I tried import ( "fmt