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
4 views

Creating a "insert if exists" helper function in Helm

I'm creating a library chart that will be used across over a dozen different deployments. Each has only one container, and in the container description I have the following definitions in some but not ...
Kyle Dumouchelle's user avatar
0 votes
0 answers
6 views

Find multiple documents by id in MongoDb with Go

I'm trying to find multiple documents by id in MongoDb with Go, but I'm getting: cannot use bson.M{â¦} (value of type primitive.M) as primitive.D value in assignment Here is my code: // Define an ...
xpt's user avatar
  • 20.6k
0 votes
0 answers
9 views

Refactor an Object that expects one thing to expect many things

I am working on updating a Go codebase. Our company has a central data store, fictionally called DataStore, that you can publish to or read from various datasets or schemas. Our particular code base ...
wubbalubba's user avatar
0 votes
1 answer
21 views

Idiomatic way to iterate over a string and replace value in original string with mapped value

I have a working solution on iterating over a string and mapping the rune to a mapping package main import ( "fmt" ) func main() { numToString := map[rune]string{ '0': &...
Coldchain9's user avatar
  • 1,421
0 votes
0 answers
27 views

Appropriate Golang API timing measurement

given an API client/server couple written in Go, I need to measure the overall API duration on the client side, the main goal is to include network transmission time in the measurement and be sure to ...
apic's user avatar
  • 73
1 vote
0 answers
15 views

Telegram Bot API: Download files larger than 20 MB

I am using Telegram Bot Go SDK to catch three webhooks: telebot.OnPhoto telebot.OnVideo telebot.OnDocument and I am able to catch these updates successfully. However, as a second step, I want to ...
Harun Sasmaz's user avatar
1 vote
0 answers
17 views

Is there a way to import go modules from private repository using bazel

I have a go project which is managed using bazel. I want to add external dependency from a private repository. I am able to add the packages from the public repository using the go_repository ...
Mahima gupta's user avatar
1 vote
0 answers
16 views

I am trying to create an index in my .yaml file that I can use to access a nested array of key value pairs in an entity

Following are the structurs as defined in Go that I am using. type MetadataEntry struct { Key string Value string } // OCHAppointment represents the structure of an OCH appointment // still ...
John More's user avatar
1 vote
0 answers
15 views

Call oracle function with return and output values with Go and go-ora return EOF

In my project they want me to use go-ora as oracle driver, I was using godror and the call was working, but when I changed the driver this occur. My partial code is this: var newProdId, errMsg string ...
Fantasma's user avatar
1 vote
1 answer
47 views

Golang: Reflect returns different kind when same value depending on initialisation

Consider the following snippet of code: // You can edit this code! // Click here and start typing. package main import ( "fmt" "reflect" ) type MyStruct struct{} func ...
arl's user avatar
  • 53
-2 votes
0 answers
24 views

Getting int32 value wrong in Protobuf - Golang [closed]

I have started learning Protobuf recently & I'm facing issue with int32 value. I have assigned ID as int32 & assigned a value for it as 11 but getting output as 99. Can someone help me here to ...
Kalyan A's user avatar
  • 187
1 vote
0 answers
12 views

Issue with using hashicorp's memberlist on two different computers

i have a problem I have made a program that uses hashicorp's memberlist gossip protocol, to connect between clients and send data. When i am running two clients on the same computer, it works just ...
Giannis Petsis's user avatar
1 vote
0 answers
26 views

colly golang save local copy

I'm writing Scraping in Golang and wanted to implement this logic, first I save HTML copy on my computer and then I process this copy, after reading the documentation I found the method response.Save, ...
Shota's user avatar
  • 11
1 vote
0 answers
18 views

How to verify a user's password using "github.com/go-ldap/ldap/v3"?

I currently check a username/password combination by connecting the LDAP server and doing a bind request. This seems a very expensive way of checking. I found some information that there exists some ...
Christian Rößner's user avatar
1 vote
0 answers
18 views

got problem when replace github.com/apache/rocketmq-clients/golang to my github fork in go.mod

i use this in my go.mod: require github.com/apache/rocketmq-clients/golang v0.0.0-20230321063829-41bfbcf6130d and i want to replace it to my fork: github.com/ainokiseki/rocketmq-clients/golang first i ...
Bo Jiang's user avatar
1 vote
1 answer
19 views

Channel close by rabbitmq server and exception is not received by consumer

I am using GoLang, Rabbitmq server closing the connection with below error but consumer never receives the close message "channel is closed" as per the code. # rabbitmqctl version 3.12.1 # ...
Aryaman Gupta's user avatar
-1 votes
0 answers
28 views

Golang Generics: How to return a nil value for a T [duplicate]

My code is as below. I want to return specific type of value. func SomeFunc[T interface{}](filters []*pricing.Filter) (T, error) { sess, err := awsutil.GetAwsSession() if err != nil { ...
pavan kumar's user avatar
0 votes
1 answer
37 views

golang - default expression of switch

refer: https://go101.org/quizzes/switch-1.html package main import "fmt" func ExampleSwitchGo101_1() { f := func() bool { return false } switch f() // "{" ...
Eric's user avatar
  • 22.3k
-3 votes
0 answers
21 views

how to implement a custom secure handshake for a p2p network? [closed]

I need to implement a secure custom handshake for a p2p network. The goal is that only nodes which I can identify as "ours" (probably via a public key) would be able to join the network. I ...
phetherer's user avatar
0 votes
0 answers
33 views

How to error handle partition rebalancing?

In the deployment environment, Apache Pulsar is used as MsgQ broker. Goal is to select the Go client library that allow consumer to error handle amidst consumer group rebalancing. Consumer group ...
overexchange's user avatar
  • 15.8k
1 vote
1 answer
38 views

How to get related instruction code from instruction bytes?

I got the following error message when I run a Go program which contains some Go assembler codes: SIGILL: illegal instruction PC=0x508c04 m=0 sigcode=2 instruction bytes: 0xc4 0x42 0x68 0xf2 0xea 0xc5 ...
Emman Sun's user avatar
  • 363
1 vote
1 answer
22 views

DDD: Correct way to get an entity from other subdomain?

We have ordering and invoicing subdomain. We need to access order in order to create invoice. What is correct way to access order from invoicing application service? Have invoicing application ...
Pavle Milicevic's user avatar
-5 votes
1 answer
42 views

How to catch an error from instantiating a Type in Golang? [closed]

EDIT: although the example I gave was happening in main and hard coded, this was intended as a very simple example. In the real world, bad data might come in at any time and from a multitude of ...
John Horner's user avatar
0 votes
0 answers
35 views

Getting an error while using a string array in go struct

I have couple of struct types in my application and some of them have struct array as attribute like : type A struct { ... B String_Array `json:"item" gorm:"type:text"` ... } ...
hatirlatici's user avatar
  • 1,606
2 votes
0 answers
25 views

How to handle the correct file path for displaying an image on a web page

I'm struggling with how paths work with http.FileServer. I have the following code: server mux := http.NewServeMux() mux.HandleFunc("/", homeHandler) server := &http.Server{ ...
Ali K.'s user avatar
  • 29
2 votes
0 answers
23 views

Grpc-gateway or maintain simultaneous REST and GRPC servers?

I have mostly used REST or grpc separately in services. When I needed both, used go-kit. But in my new project, OpenAPIv3 is a high want on the REST side and grpc is also needed. I have two options: ...
aloha's user avatar
  • 1,581
2 votes
1 answer
43 views

golang regex split string based on keywords

this is my string like findstudentbyid Now I would split based on keywords like find word before find word and after by and by, id. So golang regex pattern is `(?i)(^find{1})(\w+)(by{1})(\w+)` I am ...
Asaduzzaman Sohel's user avatar
2 votes
0 answers
24 views

Cgo ignores CXXFLAGS -std=c++11 option

I have a golang app that includes a C header (a wrapper for C++ code that calls C++ class methods) and a static library that contains object files corresponding to this header. When I built the app I ...
UpVs's user avatar
  • 1,886
0 votes
1 answer
43 views

Why is the main goroutine blocked in this case thus resulting in a deadlock?

package main import "fmt" func square(numbers chan int, squares chan int) { for n := range numbers { squares <- n * n } close(squares) } func main() { numbers :=...
Don Draper's user avatar
1 vote
1 answer
21 views

golang fyne gui cannot resize a list

I'm trying to resize this (list) because it's showing only one row, and the second to see it need to scroll down I want to show multiple rows this is the code:- "fyne.io/fyne/v2/app" ...
MrObscure's user avatar
  • 487
1 vote
0 answers
36 views

How to arbitrarily stop goroutines from operating on input?

Let's say i am building a little script that brute forces paths on a url for pentesting purposes (like legal stuff :)), and i am building it like the code snippet below, however i would like to make a ...
hackerone member's user avatar
1 vote
0 answers
22 views

Using shortid as custom Object ID in MongoDB [duplicate]

Following up with Mongodb custom object id & Creating custom Object ID in MongoDB, I want to use shortid as custom Object ID in MongoDB. Here is my relevant Go code: type Book struct { _id ...
xpt's user avatar
  • 20.6k
1 vote
0 answers
24 views

Setting BLE Advertising Address using Tiny-Go Bluetooth

I'm using Tiny-Go's bluetooth to generate Bluetooth Low Energy (BLE) messages on a Raspberry Pi 4 (Raspbian, Linux 6.1.21, Bluez 5.55) like this: adv := constants.Adapter.DefaultAdvertisement() ...
Pencil Von Radiergummi's user avatar
0 votes
1 answer
42 views

Golang struct with type Error property JSON response always empty even tho struct prints error message to console

I have a custom Response struct to use in my gin controller. That Response has a field of type Erorr which I am populating inside my services method. I then check if the response object error is nil ...
BitQueen's user avatar
  • 621
2 votes
0 answers
56 views

Golang+CGO using ucontext crash(on-purpose) crash with SIGSEGV or SIGTRAP while using different stacks

I'm currently writing a Golang + CGO program, and will use posix ucontext in CGO. Since all my core logic will be in the bind function of ucontext, we should catch up all the bad code. And I test it ...
zzkcode's user avatar
  • 21
1 vote
0 answers
20 views

Golang GORM - db.Model(&Usertable).Create(data): How to pass the correct tablename?

I am trying to insert a row into a table defined as a model. Below is the relevant code snippets: Package Structure: gorm |- server |- insertRow.go |- pkg |- models |- mytable.go |- ...
Ravindra Rao's user avatar
-1 votes
0 answers
35 views

Go program not reading in env variables [closed]

I have a Go program that requires the use of some env variables that are already set in the shell. However, running the compiled binary and printing the envs show that they do not exist. Is this the ...
Ymi's user avatar
  • 627
0 votes
1 answer
59 views

Last values sent down the channel cannot be received in main goroutine Golang

Given TCP port scanner in golang. 2 implementations, the 1st is mine and the 2nd is from golang book. Supposed the 2nd one is 100% workable as tested before by many readers. But seemed both have the ...
Tsolan's user avatar
  • 41
1 vote
1 answer
57 views

How do I make golang project module accessible to another project pipeline on gitlab?

I have built 2 projects on my local machine. One called middleware and another called authentication. both have modules. module for middleware project is called gitlab.com/nrs16/util, and module for ...
nrs16's user avatar
  • 13
2 votes
1 answer
42 views

Can I constrain one type parameter based on another type parameter in Golang?

I'd like to create a generic method in Go that accepts a constrained parameter of type T and returns type R which is deterministic based on type T. Here is what I've tried: func genericsTest[T string ...
astonius's user avatar
1 vote
0 answers
27 views

HTTP Request upgrade WebSocket with middleware

So in my Go/Gin backend i have this routing path /driver/ws, where it goes through 2 middlewares for authentication. driver_confirmed := api.Group("/driver/") driver_confirmed.Use(...
M6Gpower's user avatar
  • 165
1 vote
0 answers
11 views

Pagination data from Find method GORM

I want to implement pagination using limits and offsets in my GORM app. Ive been coding in node or java in the past where the major ORMS all had some utilities to retrieve pagination data along side ...
BitQueen's user avatar
  • 621
0 votes
0 answers
21 views

Go: Execute SCP command and print output

I am trying to run an scp command using the CMD struct in Go's os/exec. The output should be printed to the console while the command is running. My problem is with the latter, I can't seem to get the ...
Bram  Vanbilsen's user avatar
0 votes
0 answers
15 views

Docker compose MySQL connection refused [duplicate]

I'm having problem where my service keep getting error from sql.Ping() But it works just fine when I only do sql.Open() without pinging MySQL server Output: dial tcp 172.19.0.3:3306: connect: ...
nullexcptn's user avatar
1 vote
0 answers
22 views

Cookie doesn't get sent event though set-cookie goes trough to the frontend

I have a golang gin backend hosted on localhost:8080 and a NuxtJS frontend on localhost:3000 with the following cors settings: r.Use(cors.New(cors.Config{ AllowOrigins: []string{"http://...
Snek's user avatar
  • 151
-1 votes
1 answer
97 views

Custom package is not in golang std

Trying to run my golang code and it exits with this error: main.go:5:2: package lesson/students is not in std (C:\Program Files\Go\src\lesson\students) Can't find info in google, help me please( ...
DJsega1's user avatar
  • 25
1 vote
0 answers
27 views

Tasks not distributing between workers - Distributed Systems GoLang

I'm trying to build a distributed password cracker in GoLang using hashcat but I'm trying for the coordinator(master) and workers to work right before adding the password cracking logic. Coordinator....
Ehtesham's user avatar
1 vote
0 answers
35 views

go grpc: could not import github.com/golang/protobuf/proto (no required module provides package "github.com/golang/protobuf/proto")

The proto file is importing "github.com/golang/protobuf/proto" instead of "google.golang.org/protobuf/proto" when "protoc --proto_path=proto proto/*.proto --go_out=plugins=...
Worldwide's user avatar
0 votes
0 answers
45 views

Why I am able to call a receiver function which don't have an argument with an argument in go? [duplicate]

type Num []int type Number interface{ gimmeNum() int } func (n Num) gimmeNum() int { if len(n) == 0{ return -1 } return n[0] } func main(){ nums := Num{1, 2, 3} n :=...
Manuel Antony's user avatar
0 votes
0 answers
26 views

Golang - Set custom TraceID and SpanID in OpenTelemetry

I have 2 Async (non-HTTP) jobs running in different processes. I want to use my own generated TraceIDs and SpanIDs for all Traces and Spans using OpenTelemetry library for GO. (I am using Signoz for ...
sunny thakur's user avatar

1
2 3 4 5
1419