Questions tagged [go]

Go is an open-source programming language, with a syntax loosely derived from C. It's statically typed, with limited dynamic typing capabilities; it also features automatic memory management, built-in concurrency primitives, variable-length arrays – called slices –, and a large standard library.

Filter by
Sorted by
Tagged with
0 votes
0 answers
13 views

golang icmp ping issue using goroutines - getting duplicates

Would love some help on this ... I'm having difficulty using icmp ping with goroutines. My goal is to write code that will ping blocks of addresses eg 10.1.0.0/22, 10.1.4.0/22 etc in the quickest ...
waz's user avatar
  • 1
0 votes
0 answers
8 views

How to work with text properly in TextView/TextArea tview golang

So i'm using this tview library. Have a TextView. Try to put a text inside - it sets properly, but This one is good. But if i keep scrolling - it will go into a an endless void. I want to prevent ...
voodookiidoo's user avatar
1 vote
0 answers
24 views

How to call shared object function (loaded dynamically) from pointer in Go?

I try to call few shared object functions from Go. I don't want to write a C commented code to build a "CGO interface" for all functions. I write my shared object like that: #include <...
MauriceLambert's user avatar
2 votes
1 answer
20 views

PermissionDenied error while trying to read from Firestore with the Go SDK

I setup a test database with the following configuration rules for development: rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { ...
André Luiz Tiago Soares's user avatar
-2 votes
0 answers
30 views

How to handle interfaces that do too much [closed]

Say I have structs called SignupClient and AnalyticsClient. They both depend on UserService. Something that looks similar to this: type Repository interface { createUser() updateUser() ...
Dallin Davis's user avatar
0 votes
0 answers
21 views

how to debug golang in vscode

platform: windows 10 golang version : go1.21.1 windows/amd64 dlv version : Delve Debugger Version: 1.21.1 launch json: "version": "0.2.0", "configurations": [ ...
eric's user avatar
  • 11
1 vote
1 answer
24 views

I'm trying to get an element by it index of a slice in mongodb collection

What I need is just the lobby map, instead of it returning a map with the lobby map inside prefix with firstLobby: func GetLobbyByIndex(id string) error { _id, err := ConvertStringToOBjectID(id) ...
Lawrence Segun's user avatar
-1 votes
0 answers
34 views

How to apply custom YAML file to a kubernetes cluster, programatically

I have a YAML file that contains all the Kubernetes resources required to deploy an application including services, custom resources, deployment, etc. I need to apply the entire YAML file to the ...
hani's user avatar
  • 51
-2 votes
0 answers
36 views

Golang -> Makefile dont works

I use Visual Studio Code for Golang. I'm currently watching a tutorial on creating a Makefile to run an application. And here's what I noticed. When a teacher creates a Makefile, the icon of this ...
Mark Salamakhin's user avatar
0 votes
0 answers
10 views

How to attach to a cross compiled go binary for debugging purposes using the Visual Studio Code IDE?

I am using Visual Studio Code as the ide for a golang based application. The application will run on a linux target. I want to attach the VSC debugger to this cross compiled binary. The binary could ...
Mukul Mehra's user avatar
0 votes
0 answers
33 views

How to handle \\u in regex strings without breaking other escape sequences?

A smallish application is performing some schema validations. This is working as expected the majority of the time. The application is making use of gojsonschema to perform schema validation as the ...
Chris Edwards's user avatar
0 votes
0 answers
36 views

Copying data from proto message into another

I am writing a method which takes a big proto message and copies the information into another proto message(of same type), by reducing the size of few attributes). Example: Lets say the original proto ...
prblm_solver's user avatar
1 vote
0 answers
16 views

Unable to construct many to many relationship in gorm

i'm trying to construct user and friend table with a many to many relationship in gorm but unfortunely pop up the error ERROR: column "id" referenced in foreign key constraint does not exist ...
asd asd's user avatar
  • 11
2 votes
1 answer
68 views

How to resolve error "ORA-00911: invalid character" in Golang?

I am facing error "ORA-00911: invalid character" while invoking below function. If I use SQL query with hardcoded values (as of now it is commented out in below code snippet) then I am ...
Ranjeet's user avatar
  • 177
0 votes
1 answer
33 views

MongoDB On-Demand Materialized Views

Does golang mongo driver support materialized views? https://www.mongodb.com/docs/manual/core/materialized-views/
Neha's user avatar
  • 49
-3 votes
2 answers
58 views

design pattern to write a software development layer in go [closed]

I am attempting to create an API layer or software development kit (SDK) on top of an existing library in Golang. My goal is to make it highly flexible and extensible in Go so that we can add or ...
ravi's user avatar
  • 1
1 vote
0 answers
17 views

gorm m2m custom connection table, foreign key constraint setting is invalid

I try to migrate mysql's sql to gorm sql: CREATE TABLE IF NOT EXISTS `admin` ( `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS `...
januw a's user avatar
  • 2,096
2 votes
0 answers
19 views

Trouble Loading .wasm Files in HTML from a Golang File Server

I'm working on creating a sub-url for my file server in Golang. The Golang function code I have is: func main() { fs := http.FileServer(http.Dir("../../dist/")) http.Handle(&...
ccQpein's user avatar
  • 725
1 vote
2 answers
38 views

What does it mean to extract a dynamic type in type assertion? [duplicate]

When I read Donovan and Kernighan's Go programming language book, there is one thing that bugs me in the chapter statement type. Here are two quotes from that chapter:| «First, if the asserted type T ...
Тимур Имашев's user avatar
0 votes
0 answers
60 views

Why empty struct use no memory ? And why empty struct will use memory when it as a filed of a struct that has other fields?

I have two questions that make me confused. Why empty struct use no memory? If a := struct{}{}, the variable a how to be stored in the stack. When empty struct as a field of a struct, it will use ...
AquaOwO's user avatar
  • 25
1 vote
0 answers
32 views

GoLang: Preload not working properly, incorrectly adding WHERE (1 <> 1) to my queries?

I have my user struct type User struct { ID uuid.UUID `gorm:"type:uuid;primary_key;"` ... Roles []*Role `gorm:"many2many:user_roles_map"...
Cole Charc's user avatar
1 vote
1 answer
23 views

does tls.Config.VerifyPeerCertificate bypass the default provided checks in golang?

I want to implement stricter checks for allowing only few common names in a certificate. I was looking at this commit https://go-review.googlesource.com/c/go/+/26654/4/src/crypto/tls/handshake_client....
algonoob's user avatar
0 votes
0 answers
33 views

Permission denied to open a folder in docker [closed]

SO Im trying to upload an image to the server, on the docker container I've created the folder /gossip. but when I try to upload the files to the container, I get a permission denied error. this is ...
Joel Swakise TheDancer's user avatar
1 vote
0 answers
34 views

Build a go application that uses GORM, In a github workflow

I have a simple Go app that uses GORM (The boilerplate code from their site). I'm trying to go build it in a workflow in github, which runs on windows-latest. The built-in GCC compiler throws the ...
Yair Levi's user avatar
3 votes
1 answer
24 views

GOCD issue after changing material token

We have many pipelines setup in which we have added azure git as material. After some days token added in Git material is expired. So we updated git token in all pipelines. When tried to execute ...
Pramod Kumar's user avatar
1 vote
0 answers
10 views

Debugging breakpoints with dlv in go plugins for protoc

I'm developing a protoc plugin (call it protoc-gen-myplugin) that generates some code. To run the plugin all I do is build the golang binary and is make sure it is in my path and I run: protoc --...
jsnb's user avatar
  • 11
2 votes
0 answers
41 views

Implement C function in go

I'm trying to write a OpenVPN plugin in go. OpenVPN provides a interface as C header file. The header contains a function signature int openvpn_plugin_open_v3(const int version, struct ...
jkroepke's user avatar
0 votes
1 answer
25 views

How to run a Github Actions runner to test Go Rest API Server?

I have a github actions file. I am just building the go application, which is a rest API server and running couple of tests in the test folder. But in github actions runner, it is stuck on the "...
Jayanth Krishna's user avatar
1 vote
0 answers
20 views

Golang websocket wont connect

I got that error while connecting to my golang websocket this is my route setup in route.go func Setup(app *fiber.App) { app.Use(cache.New(cache.Config{ Next: func(c *fiber.Ctx) bool { ...
Danendra's user avatar
  • 175
1 vote
1 answer
33 views

Convert a gRPC trailer to an error object in Go

I receive errors from a gRPC call as a trailer and I want to convert it to an error object in Go. My problem is that the returned object is of type string and I can't find anyway to convert it to an ...
nemomaximus's user avatar
1 vote
1 answer
27 views

How do I timeout the wait on a redis pool

I am using https://github.com/gomodule/redigo for my pooled redis connection, The redis.Pool struct looks as follows type Pool struct { // Dial is an application supplied function for creating and ...
Asnim P Ansari's user avatar
2 votes
2 answers
33 views

Mocking NewManager() in unittests

I have a custom kubernetes operator written in Go. When writing unittests I came across the need to have a fake manager initialised. The manager is created with NewManager() function of the "sigs....
Богдан Божић's user avatar
1 vote
0 answers
51 views

How to implement decoupled error handling in Golang?

Consider the following controller and repo. var ErrNotFound = errors.New("not found") type Resource struct { Name string } type repository interface { CreateResource(ctx context....
Erik Johansson's user avatar
1 vote
1 answer
94 views

C# alternative to Go placeholder variables

In Go, I can easily write something like this: func isAvailableForUser(_ context.Context) bool { return true; } But C# behaviour is different: private bool IsAvailableForUser(IContext _) => ...
GettingPleasure's user avatar
0 votes
1 answer
62 views

AES 256 GCM encryption in Node.js and decryption in Golang

In an attempt to migrate legacy code to Golang from Node.js, I am playing around with AES encryption and decryption. Below is the problem statement. We have a token obtained from AES 256 GCM ...
Santhosh's user avatar
  • 140
1 vote
0 answers
34 views

How do I compile Go from sources if I received the building_Go_requires_Go_1_17_13_or_later error?

I tried to compile Go using an existing version of Go, but I was given this error message?. What does this mean if I want to compile Go from source? The last version of go that could be compiled with ...
Erich's user avatar
  • 1,930
-1 votes
0 answers
39 views

go get - proxy.golang.org connection refused

while installing or getting any kind of dependency with go get or go install I'll get a connection refused error. > go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest go: github....
microo8's user avatar
  • 3,606
-2 votes
0 answers
23 views

Unable to import a local package in a different module [duplicate]

adarshnanu@Adarshs-Air 29092023 % echo $GOPATH /Users/adarshnanu/dev/go Under GOPATH I have two folders, and each folder has different modules. 29092023 contains package main, and 02102023 contains ...
techentusiast's user avatar
1 vote
0 answers
90 views

How do you debug TCP socket creation in Linux?

I am developing a Linux-specific application in Go for a master's project in computer networking. My application quickly adds new IPv6 addresses to the NIC and creates TCP sockets from those addresses....
William John Holden's user avatar
0 votes
0 answers
54 views

How do I fix the value of a variable inside a closure? [closed]

I am attempting to run a function after x seconds via time.AfterFunc. However, the closure I pass into time.AfterFunc is not running with the values I expect. This is the callback I would like to run ...
alliang's user avatar
  • 47
3 votes
0 answers
48 views

VSCode Go disable parameters autocomplete

How to disable parameters autocomplete in VSCode using Go? I mean when I try to use new package by autocomplete, additionaly it inserts parameters in function. When type fmt.P I use suggestion fmt....
lavrd's user avatar
  • 31
0 votes
0 answers
36 views

Golang Template Variable Not Rendering

Hopefully this is a very simple question for y'all. I'm pretty new to Golang. I've already asked ChatGPT for help and we couldn't figure it out. I have an HTML page that I'd like to render using a ...
SapphireSun's user avatar
  • 9,170
1 vote
0 answers
55 views

How to parse slice of structs in Go Gin multipart request

This is my application: func main() { router := gin.Default() router.POST("user", func(c *gin.Context) { type address struct { City string `form:"city&...
Rafał Mańka's user avatar
1 vote
1 answer
18 views

How do I safely deprecate fields in Google Cloud Datastore?

I am working on an API that involves creating datastore entities and reading them back after some time from an asynchronous callback. I am trying to remove fields safely and more easily rollback, by ...
Max's user avatar
  • 33
1 vote
0 answers
23 views

Tracking upload progress with OCI transfer package

I was trying to set up a file uploader to OCI Object Storage, it is working fine so far, but I am not able to tell the current progress of a upload. My function looks like this: uploadObjectStorage := ...
guiarnaldo's user avatar
-2 votes
0 answers
18 views

Notification sound is not coming although the notification is come

I have a mobile app that helps staffs to give eachothers tasks and follow them up. This mobile app sends a notification when a staff opens a task for someone. Normally, if the notification is send to ...
zeynep's user avatar
  • 1
1 vote
0 answers
14 views

mgo.dial giving error "no reachable servers"

while trying to create a session , i am getting "no reachable servers" error below is the code func getSession() *mgo.Session { s, err := mgo.Dial("mongodb://127.0.0.1:27017") ...
Arya Rajput's user avatar
-2 votes
0 answers
28 views

Method invocation on type with receiver as argument [duplicate]

The following code compiles type A int func (A) foo() {} func main() { A.foo(1) } demo. See also same demo but with a variadic function. Is there a term to refer to calling a method with type....
Remi.b's user avatar
  • 17.5k
-1 votes
1 answer
51 views

What triggers GC other than memory allocations?

let's say I write zero allocation Go program, Can I safely assume that GC is never called at all? by the way, I'm aware of GOGC=off, I want to know what causes GC other than allocating memory itself
win-t's user avatar
  • 167
1 vote
1 answer
58 views

What is a good practice to wait for context cancel() to complete?

Given I have the program below, what is a good practice to make the method cancelled (service.Start()) complete (i.e. printing Done) before terminating by calling the cancel() function ? I only have a ...
Soc's user avatar
  • 301

1
2 3 4 5
1421