Category "go"

HTTPS for Golang API

I am new to Golang and I did set up a "hello world!" test message for a Golang API on our VPS. It works just fine at http://www.example.com:8080/hello. I would

How to get monotonic part of time.Time in Go

am currently working with timestamps and I would like to store in a variable the monotonic clock reading section. Let's say that I have this: 2022-03-31 10:20:2

golang access values from map inside a map

I am leveraging Avi Go SDK to fetch avi healthmonitor configuration as below var healthmonitormap map[string]interface{} err = aviClient.AviSession.GetObjectByN

Websocket with special characters

I am using websocket with client nodejs and server golang (net library) via tcp. I am read data sent from client but many special chars. Some one can help me ab

What is the meaning of 'leak/leaking param' in Golang Escape Analysis

func main() { i1 := 1 A1(&i1) } func A1(i1 *int) *int { return i1 } And the result of escape analysis is ./main.go:18:9: parameter i1 leak

Encode JWT properly

I'm trying to write simple JWT implementation with these functionalities: Generating token using HMAC Validating token (if signature is correct or exp is not ti

Protobuf golang - How to read values from *_struct.Struct [closed]

I am trying to convert Protobuf *_struct.Struct to map[string]interface{} what is the right way to do it? func convertToMap(input *_struct.Str

unmarshal xml to []structs with xml.Name

Problem I need to unmarshal XML from an 3rd party application to my GO struct. what i tried I created structs and am able to generate identical XML from my code

S.O.S. Visual Studio can't run go file, go: no such tool "asm"

I've been learning Go in Visual Studio Code and wasn't having any problems until I tried to create a mod file for the first time this morning. Now, whenever I t

Generate RSA key with large public exponent

Step 1. I generated RSA key pairs for Alice and Bob, respectively, and encrypted a message for Alice using Alice's public key. Step 2. I multiplied the public

Is it possible to create new linked list nodes inside a loop in goLang?

I need to create a nodes for a linked list and return the head inside a Function. Definition for each node: type ListNode struct { Val int Next *ListNo

GoLang html template if condition

I made a web app in Go which search for a query in a mysql database. Everything works fine, but I do not know how to obtain following: if there is no result in

How to mock a file with interface imported from another file

I try to create a mock of a file with an interface imported from another file. I have try with `aux_files` and `imports` but I did non succeed to have a correc

How to use the incluxdb1-client library of golang to query the data?

My library is github.com/influxdata/influxdb1-client/v2,and I need to use it to operate the VictoriaMetrics, For example, I need to make the following qu

Apache Beam Go SDK: how to convert PCollection<string> to PCollection<KV<string, string>>?

I'm using the Apache Beam Go SDK and having a hard time getting a PCollection in the correct format for grouping/combining by key. I have multiple records per k

Optional calls in GoMock

I want to use GoMock to test some code, without coupling my tests too tightly to the actual implementation of the thing under test. But GoMock seems to require

How does a value in Go context get marshalled when the context is passed over to a remote service?

Below is the signature of the WithValue func. func WithValue(parent Context, key, val interface{}) Context I took a look at Go official documentation but they

How to reduce code duplication in function which converts basic types to string in Go

I've written a simple function in Go (1.18.1), which takes any (a.k. interface{}) type as input and returns the value as string, in case of a nil pointer, the f

ups label generation with multiline address restful api

I am trying to generate a label with a multiline address.... the docs say the occurrence of AddressLine can appear three times. however this is invalid json and

how to make Goroutine not Concurrency if Same Function

Is there any way to make goroutine execute one after another ( one by one) if it was the same function? I didn't mean to use goroutine firstly. However, "os/exe