Skip to main content

Questions tagged [go]

Go, commonly referred to as "golang", is a fast, statically typed, compiled language created by Google. The language was initially developed as an alternative to C++ for server infrastructure and has native support for concurrency.

Filter by
Sorted by
Tagged with
-2 votes
1 answer
138 views

Pprof Profiling Snapshot I have a critical user facing Go API in which I call an internal API. The API response time is <200ms but the response unmarshalling with goccy JSON is taking 500ms. The ...
user avatar
-1 votes
1 answer
99 views

sorry for my English. I create paysystem. I want to structure the project based on https://github.com/golang-standards/project-layout. I would also like to hear general comments on the code. Thank you ...
David Meyster's user avatar
5 votes
2 answers
151 views

TLDR: First time dev in Go moving from Java and I need feedback on my simple CLI Tool. I wanted to get competent in Go as a very junior developer, so this is my first basic project in go. I set a goal ...
Magd Aref's user avatar
7 votes
3 answers
1k views

I am trying to create golang inspired cancellable context in C++ for use in worker threads and other tasks. I have tried to avoid using raw pointers, but ever since I started writing C++ code, I ...
Mahdi Chaari's user avatar
5 votes
1 answer
146 views

I am learning Go by working through programming puzzles. There is shared boilerplate between puzzles that I want to factor out into into some kind of helper structure: Read the input (always the same,...
user289146's user avatar
1 vote
0 answers
91 views

In one of our projects it became rather painful to use the Go standard library's sync.Map as it lacks type safety, i.e. it became rather tedious to do and check ...
Runxi Yu's user avatar
  • 119
4 votes
1 answer
122 views

I wrote a small (~350 lines) golang application mainly for fun to explore the language. I was wondering what the standard layout of a little testing tool like this would be from a seasoned golang dev. ...
btolsen131's user avatar
4 votes
1 answer
113 views

I’ve developed a Go program to benchmark a FHIR server by uploading a dataset of FHIR resources concurrently. The goal is to stress-test the server by sending a specified number (...
Martin Hinze's user avatar
1 vote
1 answer
297 views

I am trying to solve the following problem in leetcode. https://leetcode.com/problems/kth-largest-element-in-an-array/description Given an integer array \$nums\$ and an integer \$k\$, return the \$k^\...
Debanjan's user avatar
3 votes
2 answers
231 views

I have code that concurrently reads data from a stream, processes elements, and writes the data to another stream. Each of these individual operations may fail, in which case I want processing to halt ...
Will Beason's user avatar
2 votes
2 answers
175 views

I have a scenario where I need to acquire lock on a resource inside a goroutine and release the lock (only once) after a timeout or when the goroutine is done with it's job. I came up with a way to ...
Ram Dittakavi's user avatar
1 vote
1 answer
70 views

I was reading about the implementation of distributed locks where we need to verify the lease using a fencing token as per this article - https://martin.kleppmann.com/2016/02/08/how-to-do-distributed-...
Pratyush Prateek's user avatar
1 vote
1 answer
161 views

I am learning Go and trying to write a Bird design in Go. Here is the code. How can I improve it? bird/bird.go ...
coder's user avatar
  • 2,471
4 votes
2 answers
224 views

I have been working on optimizing some code I use for compressing images and linting content in epub files. I originally used cli utilities to help get the job done before moving to using Go code as ...
user avatar
5 votes
1 answer
297 views

I saw this question on one of the socials, presented as an Apple interview question. I have had to paraphrase as it was not given in text format. (Credit: Instagram @greghogg5) Given a string (S) ...
Romeo Lima's user avatar
2 votes
1 answer
88 views

I came up with the logic for an app that talks to a remote GitHub repository using below. I tried to stick to Go best practices and approaches, but would like to identify bottlenecks and adopt better ...
Inian's user avatar
  • 181
1 vote
1 answer
130 views

I'm creating a program that will hopefully operate like linux terminal (basic commands) for learning purposes. ...
depperm's user avatar
  • 1,117
1 vote
1 answer
164 views

This package is a part of a web application which is an internal company tool. This web application may need access to a number of secretes stored in hashicorp vault. The secrets rarely change, ...
Andrew Savinykh's user avatar
4 votes
1 answer
139 views

I'm currently learning Go. To enhance my understanding of Go goroutine, I write a parallelized version of classic merge sort where I try to split the workload into parallel goroutines. Implementation <...
torez233's user avatar
  • 141
1 vote
1 answer
399 views

I want to learn the proper way to gracefully shutdown a http.Server{}. Some answers I found would not handle ctrl-c signals. ...
mahtues's user avatar
  • 11
1 vote
1 answer
279 views

I'm new to Go from another language and I'm most interested to know if this implementation has anything that's not idiomatic Go, but any feedback is welcome and you're not going to hurt my feelings by ...
ETLJ's user avatar
  • 111
0 votes
1 answer
70 views

I wrote code to aggregate transactions in slips. I'm concerned with the performance of my code because it uses 3 loops that are nested so the time complexity will be cubic. This code won't scale well ...
bit's user avatar
  • 143
0 votes
1 answer
104 views

I have used this approach in my Golang MongoDB REST APIs' DAO layer, I need to clarify whether this is a good way or not, code is as follows, ...
Nisal Edu's user avatar
  • 103
2 votes
3 answers
480 views

I recently started taking on the Gossip Glomers distributed systems challanges as a way for me to practice writing Go and learn something new. In order to solve one of the challenges, I had a request ...
stefanobaghino's user avatar
3 votes
0 answers
96 views

This is my first Go project. I've written a CLI app to provision a database cluster on docker containers. Since it's a distributed database, you can configure per-node services. For example: to ...
user219820's user avatar
0 votes
1 answer
80 views

The following code implements a package, which can be used to execute functions in the correct order based on dependencies. Example: ...
ceving's user avatar
  • 483
1 vote
1 answer
191 views

Here is my implementation of a lock free queue using CompareAndSwap operation. ...
Tauseef Ahmad's user avatar
3 votes
1 answer
368 views

I'm trying to find out whether a particular file is UTF-8 encoded readable text, by which I mean printable symbols, whitespaces, \n, ...
korolev's user avatar
  • 33
1 vote
1 answer
201 views

Link to go playground https://go.dev/play/p/ctQDpDW6pui This code has been based on suggestions and conversations in this thread here Architecture: A read method creates a channel shared with ...
JavaDeveloper's user avatar
2 votes
1 answer
271 views

I'm working on a simple waiter implementation, waiter - is a code that polls an external API until a desired response is received within a given period of time. I would like to keep it simple, but at ...
b.b3rn4rd's user avatar
  • 123
2 votes
1 answer
202 views

In trying to answer this question on StackOverflow about using the gocarina/gocsv package to read a CSV with a header column name that has a comma, I got to thinking about how to preprocess the first ...
Zach Young's user avatar
0 votes
1 answer
108 views

I wrote this shortcode parsing and it runs in \$O(N^2)\$. Is there a way to better optimize this? ...
ericraio's user avatar
  • 151
2 votes
2 answers
2k views

Are there any major flaws to implement this test helper function? I know that the preferred way (refactoring) would simply make the function to be tested return its value and delegate printing to ...
ojdo's user avatar
  • 430
1 vote
1 answer
170 views

I've just started learning Golang and was solving some problems which required me to read lines of text from a file. I decided to abstract away the reading part so that I can use Go's ...
smac89's user avatar
  • 1,539
2 votes
1 answer
229 views

I have multiple E2E tests (written in Java) which share login details, each test during runtime will query the locker API for login details which is running on its own dedicated server. Below is my ...
Pawan Kumar's user avatar
1 vote
1 answer
77 views

This code works, but it's so ugly, so I was hesitant to put it on display. There must be a nicer/easier way to achieve this. The main issue is to count each unique occurrence during runtime when the ...
JonB's user avatar
  • 451
4 votes
1 answer
615 views

I am a beginner at using Golang, I would like advice about the following program. It is a CLI tool that can check the expiration dates of HTTPS certificates concurrently. I have only used the standard ...
preetpalS's user avatar
0 votes
1 answer
1k views

Let me start by stating that I am currently in the process of learning Go and AWS CDK. What better way to learn than building a Serverless Todo API!? Using the Go AWS CDK (v2) I have built my ...
J86's user avatar
  • 414
4 votes
1 answer
808 views

Real case: I need to retrieve data from a web service (main process), but in case that web service is taking too long, I retrieve the data from the cache (that data might be older) in a parallel ...
Andrey's user avatar
  • 141
3 votes
1 answer
143 views

I have a program which calls a lot of URLs with the help of a goroutine and assigns the result to a mapping. As a beginner in go I chose the simplest implementation as possible. I have ended up ...
rihekopo's user avatar
  • 131
2 votes
2 answers
793 views

I would like to implement a variant of the classical dining philosophers problem which has the definition as: Implement the dining philosopher’s problem with the following constraints/modifications. ...
Vincent Wen's user avatar
2 votes
2 answers
146 views

I'm trying to write a simple program to find a certain file name within a directory tree. I use up to 30 coroutines. Is there anything wrong with this code or what needs to be improved? ...
woxihuanxiayua's user avatar
7 votes
2 answers
546 views

I implemented my first algorithm in golang - the caesar cipher. Is there something i could do more efficiently? I am quite new to go and any improvement suggestions are welcome. ...
s4vage's user avatar
  • 73
2 votes
2 answers
159 views

I'm using fiber and mongodb. Field "field" is needed to obtain certain data to unload the load on the database. If field "field" is empty, then needs to output all the data from ...
Boro8ey's user avatar
  • 23
1 vote
1 answer
82 views

I have a below struct where I have a nested map for CustomersIndex which allocates bunch of internal maps causing memory increase. I profiled it so I noticed this. ...
norman's user avatar
  • 21
1 vote
1 answer
111 views

A kata is an exercise. In martial art is form. In software development is a way to practicing. For example in TDD. Mars rover kata aims to solve some problem in the context of the mars rover. Here you ...
sensorario's user avatar
0 votes
2 answers
94 views

I started playing Pathfinder: Kingmaker, and very soon ended up in a room with 6 levers, and a task to open a secret door by manipulating the levers. I assumed that the correct position for all the ...
Andrew Savinykh's user avatar
2 votes
0 answers
375 views

I am working in a Noise-based P2P lib that has only basic TCP networking implemented so far. I am looking for anyone who get interested in this project that want to helps with reviews to the code and ...
Geo's user avatar
  • 21
1 vote
1 answer
2k views

Here I'm trying to create the multiple consumers of rabbitmq queue using the goroutines. Also, I'm trying to achieve a graceful shutdown. Is the following approach create any memory leaks? or is it ...
Srikanth's user avatar
  • 135
4 votes
1 answer
366 views

I have a below read function which is called by multiple go routines to read s3 files and it populates two concurrent map as ...
AndyP's user avatar
  • 249

1
2 3 4 5
12