Category "go"

missing go.sum entry for module providing package <package_name>

Using the buffalo framework, after bootstraping it via buffalo new <project_name> I am trying to run buffalo dev Expecting to see: project running on por

How can I fetch a NULL boolean from Postgres in Go?

Go's zero value for a bool type is false. Postgres supports an undefined BOOL type, represented as NULL. This leads to problems when trying to fetch a BOOL val

How to Go/Gorm a megamenu?

I'm writing an e-commerce app in Go, and I've been stuck on the megamenu for a while now, trying to implement it with PostgreSQL tables. The end result, JSON re

Gorm: Is it possible to define shared methods for common db operations (e.g get by id)?

Using go and gorm in a project. I have created a dao level to wrap the database operations, each table has its own dao type. Current code Get method from FirstD

How to parse json array struct

I'm using the following code without success to parse json value but its inside array [] https://play.golang.org/p/5HdWeyEtvie package main import ( "encod

Go update slice iterating error "does not support indexing"

I'm trying to iterate through slice values and update one or more values, accessing it by index or iterating through them. Then I have the following problem. p

Executable not found in docker compose /bin/sh: 1: main: not found

I am trying to run my restful api in docker but having issue with my golang executable it is always not found. Here is my Dockerfile # Start from golang base im

Storing field of struct accessed via reflection

I am picking up quest parameters for my game from a CSV. The parameters include a stat tracked, e.g. "CardsDeployed", and conditions for what kind of cards are

How to pass variable ids to statement.Query() in golang?

I have this query in postgres which queries 1 or n users based on the parameters passed: select name, phone from clients where id in ('id1','id2') Now when I

How to return []byte from internal void * in C function by CGO?

I am wrapping an C function with the following definition: int parser_shift(parser* parser, void* buffer, int length); It removes up to length bytes from int

Golang custom sort is faster than native sort

I was just playing around with sorting in golang and I found a qsort function on stackoverflow. It seems to run about twice as fast as the native sort function

Unmarshalling json to structure using json.RawMessage

I need to unmarshal json object which may have the following formats: Format1: { "contactType": 2, "value": "0123456789" } Format2: { "contactType"

How to get the last element of a slice?

What is the Go way for extracting the last element of a slice? var slice []int slice = append(slice, 2) slice = append(slice, 7) slice[len(slice)-1:][0] // R

How to search for an element in a golang slice

I have a slice of structs. type Config struct { Key string Value string } // I form a slice of the above struct var myconfig []Config // unmarshal a

Does golang have the plan for supporting set datastructure?

This feature can be implemented with 'map'. countrySet := map[string]bool{ "US": true, "JP": true, "KR": true, } But to ease the eyes of readers, 'set'

is concurrent write on stdout threadsafe?

below code does not throw a data race package main import ( "fmt" "os" "strings" ) func main() { x := strings.Repeat(" ", 1024) go func()

What is the "any" type in Go 1.18?

In Visual Studio Code, the auto-complete tool (which I presume is gopls?) gives the following template: m.Range(func(key, value any) bool { }) where m is

Modifying a gif image in go...not setting transparency correctly

I have some code which performs the following logical operations: Read in and decode a gif image to a *GIF using gif.DecodeAll Modify some pixels in each frame

Gorm and Gin error 500 only when Updating

I've a pretty simple CRUD for a Task list, and so far I'm able to Create, List all, List by ID and Delete records, bu when I try to update, it gives me the foll

Cross Domain Cookie Golang ReactJs

In Go, I am setting the cookie for frontend: http.SetCookie(w, &http.Cookie{ Name: "jwt-token", Value: tokenString,