Category "go"

Retrieve response metadata in interceptor in gRPC-go

For short: How can I retrieve response's initial_metadata with grpc.WithStreamInterceptor without wrapping grpc.ClientStream? The situation is I try to use an i

Can't we include vars in gorilla subrouter pathprefix?

I'm trying to add a subrouter to my router code : router := mux.NewRouter() baseRouter := router.PathPrefix("/api/v1").Subrouter() managementRouter := baseRoute

How to create generic method in Go? (method must have no type parameters)

Golang 1.18beta supports generic, I want to add an extension method on a generic slice. e.g. a map function is defined as this: func Map[E, V any](slice *[]E, i

How to avoid duplicate elements in slice in json validation?

Although I am not a pro-Golang developer, I am trying to restrict the duplicate elements from my array in struct during JSON validation. type Test struct { Test

Build excluding test modules

My project has the following structure: ├── api │   ├── api.go │   ├── api

Swagger generation is ignoring SecurityDefiniton

Cannot understand one thing, why swag init command is generating everything, except SecurityDefinition block For example, this is my code on main function: // @

no handler found for uri [<index>/_doc/<document_id>/_update] and method [POST]

Currently, i am using client go-elasticsearch version v7.8.0 and elastic of version 8.1.2. the elastic search got updated from version 7.x Now when I try to upd

Unable to debug Golang on Vscode M1 Mac (arm64)

I have an M1 mac and cannot invoke functions via DLV in VSCode. Unable to evaluate expression: backend does not support function calls Delve Debugger Version: 1

low bandwith usage on golang exec.Command("").Run()

I am building a golang app which uses youtube-dl to download some files from mixcloud. I recognized that when I execute youtube-dl https://www.mixcloud.com/Fatb

Issue sharing array between goroutines

I am trying to solve this golang exercise https://github.com/loong/go-concurrency-exercises/tree/master/1-producer-consumer. I guess I am close to the solution

grpc with mustEmbedUnimplemented*** method

Recently, grpc-go introduced the mustEmbedUnimplemented*** method. It is used for forward compatibility. In simple terms, I am unable to understand how it is he

vscode ssh develop Go cannot stop at breakpoint when code under /home/{username}/ floder

I have the remote develop problem. I want to ask for some advices to solve this problem. when my code under ~/ floder, debug cannot stop at breakpoints: when

force a transitive dependency version in golang

I have a question about dependencies in golang. My application defines a go.mod like this: module my.host.com/myapp require ( ext1.com/module1 v0.0.1 ) go

A structure that cannot be imported into a structure body

initialize/config.go package initialize type DatabaseConfig struct { MysqlConfig MysqlConfig `yaml:"mysql"` RedisConfig RedisConfig `yaml:"redis"` } t

Run gofmt on vim without plugin

I want to run gofmt on save on vim without installing any plugin. This is what I have tried (inspired by https://gist.github.com/tbrisbout/a91ac3419440cde40c5f5

Golang struct to Json schema

Hi I need to infer a json schema (github.com/go-openapi/spec.Schema) from a struct : type Testcase struct { Id string `json:"id,omitempty"`

In Go, when running exec.Command with /usr/bin/script before a command, an error is thrown: /usr/bin/script: invalid option -- 'P'

I am using Go to automate IBM Aspera uploads. I would like to capture the stdout/stderr percentage progress while this happens. I am running this on an ubuntu:l

Function type cannot have type parameters

I am trying to write a sample program to try and implementing the a data structure using go generic proposed in go2. As part of this I want to define a iterator

How to configure an Azure custom handler with a timer trigger?

I'm trying to configure a new function in my Golang custom handler that uses a timer trigger. But I haven't been able to find any documentation for it. I've rev

How can go-validator check fields against their zero value?

I'm trying to use https://github.com/go-playground/validator and need to ensure that user configuration has an inner struct populated (i.e. not Zero) while stil