Category "go"

Peeking into the top of the Priority Queue in Go?

I was trying to implement a sample program using heap, and I am able to Push and Pop from the Heap. I was able to implement the Push and Pop methods and use th

Go lang decode io.read JSON v.s. unmarshal giving different results

I have a handler like this: type Location struct { Lat float32 `json:"lat"` Lon float32 `json:"lon"` } func handleJSONLocation(res http.ResponseWriter

Build error in Go/Golang: Column does not implement gorm.ColumnType (missing AutoIncrement method)

I am facing this build error in Golang V1.17 intermittently. # gorm.io/driver/mysql ../../../../pkg/mod/gorm.io/driver/[email protected]/migrator.go:224:24: cannot u

How Can I log-in Amazon with Golang Colly

I am trying login to my amazon buyer account for getting tracking info. I made wordpress-woocommerce login and getting infos but I could not for Amazon. package

Unknown flag: --go_opt while regenerating gRPC code

I followed the gRPC quickstart document in this link https://grpc.io/docs/languages/go/quickstart/ and while regenerating the gRPC code i am getting error ( Unk

Regex catch bad octet in IP

Hi can someone explain me why last octet of the IP if 01 or 001 is not capched by this regex ? (\.?)([2-9][5-9][6-9]|[3-9][0-9][0-9]|0[0-9][0-9]?)($|\.) Debug

"go get" command not generating the bin folder when it is run in a shell script

I have installed go package. When I go to the instance(VM) and run the command go get github.com/linkedin/Burrow from a terminal/cmd it is downloading both "sr

How to get data from such blob:http:// url in golang?

I have an api written in go, which takes the input in form of blob file, actually a blob url from frontend , When the file gets uploaded to s3 it makes an empty

Recursive data structure unmarshalling gives error "cannot parse invalid wire-format data" in Go Lang Protobuf

OS and protobuf version go1.18.1 linux/amd64, github.com/golang/protobuf v1.5.2 Introduction I am trying to use recursive proto definitions. .proto file message

How to create a unique key for a map

I'm creating a structure where a developer can store a reference to something and retrieve it when needed using a reference key, but not delete the reference. H

Golang: How to color fmt.Fprintf output?

I know I can add colors to fmt.Println output with something like: package main import ( "fmt" ) func main() { colorReset := "\033[0m" colorRed :=

How to initialize a nested struct?

I cannot figure out how to initialize a nested struct. Find an example here: http://play.golang.org/p/NL6VXdHrjh package main type Configuration struct { V

How can i add enum in gorm?

I am writing PostgreSQL table schema. type TestTable struct { ID int `gorm:"column:id;primaryKey;autoIncrement"` CarType string `gorm:"colum

How to fetch blob from azure

I am trying to download some data from Azure Blob Storage in Go via the official azure-sdk-for-go. To setup my development environment I have successfully logge

How do I get the querystring using Golang's Fiber?

My code app.Get("/event/*", func(c *fiber.Ctx) error { // GET THE ACCOUNT FROM THE PATH fmt.Println("PATH")

Golang: Gorm Error on insert or update on table violates foreign key contraint

Im trying to create a REST service using Gorm that on startup will drop the database tables from my Postgres DB and then create and populate them with test data

GORM select certain column with preload

Let's say I have these struct that represent my models type QuestionHeader struct { QuestionHeaderId int `gorm:"primaryKey;column:question_id" json:"questi

gin/golang gin-gonic does not parse time.Time properly for unix json?

I cannot find the way to execute this code properly with UNIX: package main import ( "time" "github.com/gin-gonic/gin" "net/http" ) type Things struct

How to assign or return generic T that is constrained by union?

In other words, how do I implement type-specific solutions for different types in a union type set? Given the following code... type FieldType interface { s

Facing issue with having generic as return type in Golang

I'm invoking a function from another library whose return signature is defined as under: (*studentlib.Student[StudentResponse], error) Student is defined as: t