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
-3 votes
0 answers
19 views

Golang PION/WebRTC: Issues with Audio Transmission via PortAudio and OPUS Encoding [closed]

I am encountering issues with a Go script for a WebRTC-based application using the GO/PION library. The application captures a video stream and makes it available over a WebRTC connection, while also ...
Josè Pavese's user avatar
3 votes
1 answer
67 views

Golang Optimize Unzipping FiIes

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

String character changes (case insensitive) - Go

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

Application that interacts with a remote GitHub repository with retries

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

Linux terminal like parsing

I'm creating a program that will hopefully operate like linux terminal (basic commands) for learning purposes. ...
depperm's user avatar
  • 937
0 votes
0 answers
102 views

Function writing data to a spreadsheet

The code below works as intended: write data by iterating over columns, while iterating over rows while iterating over sheets. ...
Sergei's user avatar
  • 1
1 vote
1 answer
129 views

A very simple secrets cache

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

Parallelized merge sort implementation in Go

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
0 answers
46 views

Go log file swapper

Please review my code. I left some comments where I think something might be wrong, but any comment is appreciated. I am writing a package for a project I am currently building. Its purpose is simply ...
Daniel Burgos's user avatar
1 vote
1 answer
260 views

Gracefully shutdown http.Server{}

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
0 votes
1 answer
222 views

golang HTTP client that follows pagination header

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
  • 1
0 votes
1 answer
49 views

Aggregate transactions in slips

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

I have use this approch in my golang mongo REST APIs' DAO layer, need to clarify this is a good way or not

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

Idiomatic retry loop in Go

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
0 votes
0 answers
35 views

Gorilla/mux request DTO builder

I got tired of having to extract the provided input from the requests manually so I made a library with which I can extract the values from the request a build a given DTO. The idea is to create ...
Enthys's user avatar
  • 101
0 votes
0 answers
19 views

Golang code that gets data from Kubernetes API and Writes to Spanner

Code for writing a Writer that is used to dump data in a Spanner table. Specifically concerned about the function: ...
Aviral Srivastava's user avatar
3 votes
0 answers
76 views

CLI app to spin up a Docker cluster

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

Golang: package setup to orchestrate initialization

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
  • 413
1 vote
0 answers
66 views

Write a library for Mutex protected variables in Go

Problem description I'm trying to write a library for protecting variables from concurrent access using sync.RWMutex. The goal is to prevent accidental misuse and promote best practices and I didn't ...
Falco's user avatar
  • 428
1 vote
1 answer
151 views

Implementation of a lock free queue using CompareAndSwap in Go

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

Determining if a file is UTF-8 text by looking at its first n bytes

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
0 votes
1 answer
173 views

A producer (mapper) and consumer (reducer) problem with concurrency in go with race conditions

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

Golang waiter implementation pattern

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

Remove unwanted chars from CSV header as it's being read

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

Parsing shortcodes out of a string

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

Capture stdout output of a function call

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
  • 420
0 votes
1 answer
140 views

Readlines abstraction for Golang

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,499
2 votes
1 answer
189 views

Distributed lock service implementation in Golang

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
0 answers
238 views

Golang HTTPS certificate expiry checking CLI tool (UPDATED)

I previously submitted this CLI tool to this site for review and have made changes based on comments by the reviewer. I have refactored the code, fixed a bug (the tool will no longer output ...
preetpalS's user avatar
0 votes
1 answer
47 views

Count occurrence of elements in map during creation

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
  • 431
4 votes
1 answer
538 views

Golang HTTPS certificate expiry checking CLI tool

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
1 vote
0 answers
87 views

Dining Philosophers in golang

I'd appreciate any feedback on this code. The assignment was to have each philosopher eat three times. I introduced time into the problem where eating takes 20 minutes and then the philosopher ...
Robert Lugg's user avatar
1 vote
0 answers
1k views

Timeout middleware in Gin -Golang

This is an implementation of a custom timeout middleware. I am creating a context with a deadline in my middleware and using it in the rest handlers for timeouts (to wrap the query to DB eventually) ...
Manish Kumar's user avatar
0 votes
1 answer
997 views

A Go endpoint to get all items from DynamoDB and return them as a JSON response

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
1 vote
0 answers
457 views

Golang Program to convert RGB and Hex to DMC colors

I wrote a small console app for converting RGB or Hex values (by specfying on top of the input file) to the nearest colour of DMC thread. I'm curious to know how I could improve my code organisation ...
Adam Parker's user avatar
4 votes
1 answer
764 views

Launching two goroutines in parallel and returning result of the first finished

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

Simple goroutines to make multiple http calls

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

Golang implementation of dining philosophers variant

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

Finding files using multiple coroutines

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
6 votes
2 answers
491 views

caesar cipher decoder and encoder - go

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
  • 63
2 votes
2 answers
121 views

Change interface depending on if statement

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

How to avoid nested map allocations in below code?

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
0 votes
1 answer
93 views

go mars rover kata go

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

The levers puzzle

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

Networking code for a Golang P2P library

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

Go Routine: Multiple Consumers to RabbitMQ

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

Golang function that reads S3 files and populates maps with strings as keys

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
  • 239
1 vote
0 answers
36 views

Managing TimeMachinesCorp POE clock via UDP

I've got a working implementation of a go program to talk UDP to TimeMachinesCorp POE clocks. This code is also in a github repo which notes things I know aren't implemented yet. I feel like there's ...
chicks's user avatar
  • 2,863
2 votes
1 answer
984 views

MongoDB abstraction in Go with generics

I'm working on a new project with go. So I figured I would give this new feature a run (it's fun!). Although, I'm not sure I'm implementing this the way it's suposed to be. I've read the following ...
Russo's user avatar
  • 123
2 votes
1 answer
141 views

Golang solution to CTCI 1.2: Check whether two strings are permutations of each other

Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think. https://github.com/samjingwen/ctci Below is ...
Sam Jing Wen's user avatar

1
2 3 4 5
12