Category "go"

How to use log4go with configuration file?

I have been trying to use log4go in golang. But I could not find a proper example where log4go configuration properties were used like rotation,maxSize etc to c

Unable to build protobuf to go endpoint

using protobuf version 2.6.1 ( which i installed via homebrew) I am trying to run $ protoc --go_out=../cloud/ *.proto I keep receiving this error. $ p

check if given path is a subdirectory of another in golang

Say we have two paths: c:\foo\bar\baz and c:\foo\bar Is there any package/method that will help me determine if one is a subdirectory of another? I am looking

How do I reverse a slice in go?

How do I reverse an arbitrary slice ([]interface{}) in Go? I'd rather not have to write Less and Swap to use sort.Reverse. Is there a simple, builtin way to do

Use google cloud aiplatform with golang

I have a vertex AI modele deployed on an endpoint and want to do some prediction from my app in golang. To do this I create code inspired by this exemple : http

Is it possible to mock a function imported from a package in golang?

I have the following method to test, which uses a function imported from a package. import x.y.z func abc() { ... v := z.SomeFunc() ... } Is it

Reading Stdout from a subprocess

I am attempting to spawn a subprocess from Golang. The goal is to read and process the input line-by-line. Here is what I am trying to get working: func readSt

How to format current time into YYYY-MM-DDTHH:MM:SSZ

Never tried Go before and currently doing a small project. One of the task is to get current system time and represent it in YYYY-MM-DDT00:00:00Z format. I beli

Correct way of getting Client's IP Addresses from http.Request

What's the correct way to get all client's IP Addresses from http.Request? In PHP there are a lot of variables that I should check. Is it the same on Go? One

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

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