Category "go"

How can I force go mod to accept a module that declares its path being different from its go.mod?

When I run go mod tidy, it breaks because a package imported by my project imports another package using path github.com/coreos/bbolt, but when it fetches the p

I add file to my API and got invalid character '-' in numeric literal in POST API

I know this code need to send a JSON instead of form data in the API err := ctx.ShouldBindJSON(&modelAdd) if err != nil { return err } But

How to validate an email address in Go

I have checked the StackOverflow and couldn't find any question that answers how to validate email in Go Language. After some research, I figured out and solved

When to use swagger route vs swagger operator

I am trying to auto-generate swagger.yaml file using go-swagger in my golang project. I understood difference between path and operation. And here are links for

In Go, why does exec.Command() fail but os.StartProcess() succeed launching "winget.exe"?

exec.Command() works for executing C:\Windows\System32\notepad.exe But exec.Command() doesn't work for executing C:\Users\<username>\AppData\Local\Microso

GCP Server crashing with "cloudsql.enable_instance_password_validation"

Over the past day I have been experiencing this error very frequently which results in the cloud instance needing to be reset in order to continue connections:

how to use Google Analytics Data API v1 with golang

there is no golang demo code to use Google Analytics Data API v1 in https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-librar

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