Category "go"

How to install a go library from github without public key?

I want to install the gqrcode project and get from that project the following installation instructions: go get -u github.com/KangSpace/gqrcode When performing

Postgresql argument placeholder in jsonpath expression

I try to pass argument $1 to jsonpath-expression: SELECT 1 FROM %s.orders AS O WHERE order_info @? '$.items[*] ? (@.ProductID == $1)' but it doesn't work. P

How to use unsafe get a byte slice from a string without memory copy

I have read about "https://github.com/golang/go/issues/25484" about no-copy conversion from []byte to string. I am wondering if there is a way to convert a str

Go 1.13: gcc-5 not in PATH

I've installed Go 1.13.4 in Debian Linux 10 using brew, package golang (previously I've removed golang-1.11 installed via apt). It follows brew info output. $

Get name of function using reflection

I'm trying to use Go's reflection system to retrieve the name of a function but I get an empty string when calling the Name method on its type. Is this the expe

Golang - extract links using regex

Golang - extract links using regex I need to get all links from text which are in specific domain example.de using Regex in Go Below are all possible links that

go: cannot find main module; see 'go help modules'

I recently started using Go. I installed go's extension on vscode and I can use some commands like go run and go build but when I run go test I get the followin

is there a Generic way to assert type? [duplicate]

I have found myself writing the same function X number of times to get different types of Items out of my go-cache. The duplicate functions ar

Regex for 16 hex char string that contains at least one letter

I want to write regex to recgonize a hex string with length of 16 bytes, for example: 1a2b3c4d1a2b3c4d The following answers is NOT correct: [0-9a-fA-F]{16} b

Regex for 16 hex char string that contains at least one letter

I want to write regex to recgonize a hex string with length of 16 bytes, for example: 1a2b3c4d1a2b3c4d The following answers is NOT correct: [0-9a-fA-F]{16} b

Sum of two float64 variables in go [duplicate]

Could somebody explain me next rows: var a, b = 2.0000001, 3.00000 fmt.Println(a + b) fmt.Println(2.0000001 + 3.00000) results of prints: fir

How to check if a Go program isn't running via the go run command?

I want to know if there is a non OS-specific way to test if a Go program is launched by using the go run command or by executing the binary produced by the go b

How do I mimic `git --work-tree ...` with `go-git` in go?

I have a bare repository in which I need to add and commit a set of files. As far as I understand it, adding files to the index requires a worktree. Using git o

Prometheus counters: How to get current value with golang client?

I am using counters to count the number of requests. Is there any way to get current value of a prometheus counter? My aim is to reuse existing counter without

Building Go apps with private gitlab modules in Docker

I am trying to build my go apps on a docker file. Inside my go.mod there is private package that needs authentication/ssh. This question is similar to Building

MongoDB - Group by inner element

I am explaining with a simple example see my MongoDB collection looks like this: [ { pid: erwer, qty: 3, LevelDetails: {

Gorm Update and Get the Updated Rows in a single operation?

Is there any way to get the rows that have been updated using the update command in Gorm, using a single operation.

Unable to read "request.Body" in Go Chi router [duplicate]

Consider the following code in main/entry function r := chi.NewRouter() r.Use(middleware.RequestID) r.Use(middleware.RealIP) r

How to get in OpenTelemetry otelgin middleware the traceid or full context to provide it to grpc clients?

Atm, I work on a bunch of distributed microservices in go which I want to trace. I have an "api-gateway" that works via REST and then calls the needed microserv

Go boltDB query using bolthold 3 conditions

So I had this question before and I had an answer below the question which worked, but I just realized that the query I came out with does not work as planned.