Category "go"

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

Saving PDF file in SQL Server using Golang

I'm having issue in saving a PDF file in SQL Server database using stored procedure in Golang. Below is the code. tsql := fmt.Sprintf("DECLARE @tmp varbinary(ma

golang: BaseRepository usage with different struct return type [duplicate]

I have the following code with two repositories that have the same functionality but different return types. I want to call the findAll method

Go 1.17: How to log error with the stack trace

How to log the line number and file name of the error? I tried %w, zap logger's Errorw, but its not working as good as github.com/pkg/errors, which is sadly arc

Enqueueing a message to Azure Storage in an Azure function without changing the output

I have a custom handler written in Go running as an Azure Function. It has an endpoint with two methods: POST /entities PUT /entities It was easy to make my ap

golang naked return in function without named return

i have gone through some naked return/named returns(here) and similar question here but still have some doubts in my understanding on naked return. Below is cod

Error when parsing redis aggregation reply. redigo: unexpected element type for Strings, got type []interface {} on reply position 4

I use redigo to use redis in golang I have tried to use group with reducerTOLIST but I got the following error: Error parsing Aggregate Reply: redigo: unexpect

Go: Why do processes/Threads started using Win32API funcs seem to hijack and kill the parent proccess?

Now, the following code does what it's supposed to do, load calc.exe to memory and execute it, it does that fine. I've stitched together this code to show Creat

Unable to get mp4 tkhd info using go-mp4

Using package github.com/abema/go-mp4 when i try to run the example in the docs i get following error: invalid operation: box (variable of type *mp4.BoxInfo) is

Converting an array into a linked list in Golang

definition of linked list: type ListNode struct { Val int Next *ListNode } insert helper that does the pointer manipulation: I am aware that root.Val

Use ticker to periodically load all the files in memory from a path which keeps changing frequently?

I have an application which needs to read files from two different path. After reading all these files, I need to load them up in memory in products map. Path:

How to send logs to a different location : Kubernetes

So I want to develop multiple flavors of log one for generic use and other for performing a specific operation I want to separate those logs by storing them in

How to check if the value of a generic type is the zero value?

The generics proposal has a section on how to return the zero value of a type parameter, but it does not mention how to check if a value of a parametrized type