Category "go"

what does "lst := List[int]{}" mean in Go [duplicate]

Here is the part of Go code I am reading: func main() { var m = map[int]string{1: "2", 2: "4", 4: "8"} fmt.Println("keys m:", MapKeys

Location of methods in memory [duplicate]

I am new in Go world, the question could be obvious. Let's say I have a struct Example, which has some methods: type Example struct {} func (

fabric invoke chaincode error: Failed to get endorsing peers: no endorsement combination can be satisfied

I have set up my fabric network with 3 orderers in one organization and a consortium with 5 organizaitons successfully. Each organization has only one peer node

Go import scope lookup for protobuf types

I'm building a transpiler and need to understand the protobuf/go scope lookup system. I've been trying to google the docs and finding no luck. Q: Is there a sha

How to set lower or upper in gorm model when primary key is mixed

I have a table with 3 columns: emrID (this is the primary key) patient_name (string) Comment(string) This my code import ( "gorm.io/driver/sqlite" "gorm

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