Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
1 vote
0 answers
141 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 ...
user avatar
  • 169
1 vote
0 answers
30 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 ...
user avatar
  • 2,646
2 votes
1 answer
85 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 ...
user avatar
  • 123
2 votes
1 answer
66 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 ...
user avatar
1 vote
1 answer
88 views

Suggestions for improvement for generic array and map functions in Go 1.18

Yesterday I build some generic functions for the new official Golang 1.18 release. What do you think about it and what could be added and improved? ...
user avatar
1 vote
1 answer
93 views

Read bunch of files in parallel and populate concurrent map

I am trying to read bunch of S3 parquet files in parallel from a S3 bucket. After reading all these files, I am populating my products and ...
user avatar
  • 169
3 votes
1 answer
64 views

Parse data into struct efficiently by reducing memory footprint

I have a simple program where I am deserializing my bytes byteSlice into a ClientProduct array struct. And then I iterate over ...
user avatar
  • 169
1 vote
1 answer
39 views

Re-usable worker pool classes

I am trying to read multiple files in parallel in such a way so that each go routine that is reading a file write its data to that channel, then have a single go-routine that listens to that channel ...
user avatar
  • 169
2 votes
1 answer
75 views

DelayQueue in Go

I tried to use Go to write a DelayQueue. I referred to the implementation in Java. So the general logic is to have a minimum heap, then try to fetch the top element ...
user avatar
  • 121
1 vote
1 answer
81 views

Chunk output into files, based on number of entries and total size

Below is my client code which stream all the customer URLs from a golang grpc server. It takes Request input parameter and streams customer URLs based on matching a ...
user avatar
  • 169
7 votes
1 answer
165 views

Download artifacts using HTTP

The public code is SaveAsFile(). It takes a URL, checksum and authentication info, and downloads the artifact and its hash using HTTP. It saves the content as a ...
user avatar
  • 173
0 votes
0 answers
27 views

Chinese listening practice tool

I recently decided to pick up some Go and wanted to rewrite a Python webapp that I wrote as a Chinese listening practice aid. Here's the code I was basing it on. With a bit of luck, a production ...
user avatar
  • 395
1 vote
0 answers
54 views

Interview Golang test improvements [closed]

I've been interviewing for some Golang jobs and this was a test that I was assigned. FYI: I'm posting this question to improve my skills and see what I could've done differently to make it better. I ...
user avatar
  • 111
0 votes
1 answer
95 views

Using classes for X number of config files which needs to be read individually in memory

I am working with lot of config files. I need to read all those individual config file in their own struct and then make one giant Config struct which holds all ...
user avatar
  • 169
0 votes
0 answers
66 views

Multiplayer Game Byte Array Serialization With Go And C# Tool

it's a tool I developed to make byte arrays meaningful in multiplayer games. A tool that prepares the encode and decode codes for go and c#. example input(example.customExtension) ...
user avatar
  • 23
2 votes
0 answers
68 views

Go REST API feedback [closed]

My intention is to create an API as generic and DRY as possible using Go. To achieve this, I have made some more or less common decisions: To use AJAX call to avoid reloading page when updating the ...
user avatar
  • 121
0 votes
1 answer
74 views

Go logging wrapper that adds log levels

The package is essentially a small wrapper around the stdlib logger that provides a very simple, easy to use logger that can toggle between different log levels (DEBUG, INFO, WARNING, ERROR). Log ...
user avatar
2 votes
0 answers
68 views

Parallelized Web Crawler

Exercise is here: https://go.dev/tour/concurrency/10 Prompt: In this exercise you'll use Go's concurrency features to parallelize a web crawler. Modify the Crawl function to fetch URLs in parallel ...
user avatar
0 votes
0 answers
50 views

Hackerrank's New Year Chaos problem (find minimum number of swaps to reach a permutation)

I am trying to solve the problem to Hacker Rank's New Year chaos problem. I have come up with a not so elegant solution. This is failing to adhere to the timing constraints of Hackerrank My approach ...
user avatar
1 vote
2 answers
38 views

Pagination configuration via query parameters (head, last, page, limit and offset)

i have logic module for head, last, page, limit and offset filter. such as : ../example/param if no query, return all value ../example/param?limit=10 return the first 10 value ..example/param?offset=...
user avatar
6 votes
1 answer
168 views

Decompress tar.gz file in Go

I want to extract tar.gz file and store the contents in the same directory. I got below method which does the job but I wanted to see if there is any way to improve ...
user avatar
  • 169
0 votes
0 answers
43 views

Golang scan joined many to many tables

I have the following structs: ...
user avatar
  • 193
0 votes
0 answers
173 views

Go middleware for logging with ZAP and elastic APM

Please be brutal with my attempt at logging middle ware. The aim of the middle ware is to tag all the logging with the same tracing detail as the apm modules from elastic that are sent to apm-server ...
user avatar
0 votes
0 answers
79 views

Kosaraju's algorithm is too slow

I just implemented the Kosaraju's algorithm in Go. I tried to implement the same algorithm that is described in the relevant Wikipedia page: ...
user avatar
  • 993
1 vote
1 answer
54 views

Factory to create default or cyphered and encoded output marshalers

The following code bellow is a factory which creates two different objects for marshalling cyphered and ...
user avatar
0 votes
1 answer
66 views

Mongodb connection retry

Created a MongoDB client which is handling the retry in case of server connection failure. Please review and how I can improve further. ...
user avatar
  • 125
2 votes
1 answer
112 views

FizzBuzz JSON via Unix socket (Go)

At heart, this program is just the basic "FizzBuzz" program. However, the program was pushed further, by making it a client-server via Unix Socket: Server run, and listening on a socket. ...
user avatar
  • 23
4 votes
2 answers
190 views

first Go program: Tic Tac Toe

If I formatted my question wrong, feel free to notify me or update, this is my first question on this subforum This is literally my first ever Go project, decided to make a Tic Tac Toe (ironically I ...
user avatar
  • 752
1 vote
0 answers
98 views

Small recursive script in go to clone all projects in a Group

I've just created a small script to clone all projects within a Gitlab Group and all Subgroups inside it. As I am trying to level up my Go skills, I would welcome any reviews and enhancement on my ...
user avatar
0 votes
0 answers
25 views

API handler to retrieve universities from MongoDB

I have this handler for my API endpoint /api/universities. My main concern is the overall quality of the code and the efficiency of my use of ...
user avatar
  • 193
2 votes
1 answer
82 views

golang http.Client wrapper with rate and concurrency limiting

My goal is to safely consume an API without getting 429 Too Many Requests error, activating DDoS protection or going over system limit of maximum open file ...
user avatar
2 votes
0 answers
156 views

Simple implementation of various cache replacement policies

I am new to golang and I tried to implement various cache replacement algorithms (FIFO, FILO, LRU, MRU, LFU) in a generic or flexible fashion. I added some tests as well. My implementation uses the ...
user avatar
  • 359
1 vote
1 answer
60 views

Example of handling chained errors in Go with help of CustomError object

My code snippet represents a way of handling chained errors. I need a code-review to understand whether my way is idiomatic and relevant for the 2021? My personal requirements: I want each package of ...
user avatar
1 vote
2 answers
360 views

move duplicate items at the end of the array

I have array [1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4] so I want to move all duplicates at the end of the array [1, 2, 3, 4,1, 2, 2, 3, 3, 4, 4, 4]. is there is another best way to do the same Go Time O(n)...
user avatar
1 vote
0 answers
34 views

Kademlia identifier package written in go

I'm very new with Go (started to learn it two weeks ago) and I would like to get your comments on the code below. The code is implementation of identifier used by DHT (Kademlia) The code works as ...
user avatar
  • 257
1 vote
1 answer
459 views

Concurrent processing of a slice

I am trying to learn Go concurrency patterns and best practices on my own. I have invented a simple task for myself. I want to process a slice of integers in a parallel manner by dividing it into sub-...
user avatar
2 votes
1 answer
37 views

Loading configuration options from environment or default values

I have this method that I feel has code repetition that can be improved but since I am new to Go, I am not quite sure how to improve it. I would appreciate if anyone can give me their opinion. ...
user avatar
  • 123
3 votes
2 answers
294 views

Parsing custom text file using haskell

I am working on writing code for find difference between two text files that should be ideally same. the format of file is ...
user avatar
-1 votes
1 answer
134 views

How to make this code's design better?

Github repo I've attempted a backend assignment in Go from geektrust Assignment Link. I'm not sure the code that I have written is idiomatic in the go way. I need some feedback on this code based on ...
user avatar
4 votes
1 answer
77 views

Plan 9 freq(1) in go

I implemented the freq(1) program from Plan 9 in go. ...
user avatar
  • 854
3 votes
0 answers
88 views

I recently wrote sort of structs in golang

I am a bit concerned about style (functions, variable names, spacings, etc.). I am also not sure about whether I should return error or panic. What do you think? ...
user avatar
  • 31
0 votes
0 answers
51 views

Calculate intersection point of 2 or 3 moving averages

I want to calculate the intersection point, in time, of 2 or 3 moving averages. To solve this problem I decided to transform the moving average(ma) data into geometrical lines and calculate the ...
user avatar
1 vote
1 answer
59 views

Go Brainf*ck Interpreter

Recently wrote a brainfuck interpreter in Go. Here's the Github Repo Brainfuck Areas that need work The parsing for brackets [] is still buggy and is known to fail ...
user avatar
5 votes
1 answer
250 views

Golang keep installation status for multiple installations process

Im fairly new to Golang and I appreciate any feedback about how to make the code cleaner. The code is called by go-routine and should update status (fail/success ...
user avatar
  • 281
1 vote
2 answers
129 views

Improving my solution to the Quiz project from Gophercises in Golang

I'm new to Go and I completed the first challenge from Gophercises. Any feedback would be highly appreciated. There are some things that I am unsure of if they are made in an optimal way. Github repo ...
user avatar
4 votes
0 answers
269 views

Simple RESTful counting API in Golang

Description This is a simple (and hopefully) RESTful API in Golang that uses Redis. I have next to no prior experience in Golang and absolutely no prior experience with Redis. The API is a simple ...
user avatar
0 votes
1 answer
120 views

Perform sum of squared numbers without using for loop

I have to find the sum of number after performing square operation in the given input the negative numbers need to be ignored. The input Format is, first line is number of test cases followed by N as ...
user avatar
1 vote
1 answer
89 views

BoltDB Lookup and Add methods and advice on unit testing

I am writing a Go package that handles communication with BoltDB as a part of some larger project. I have 2 methods for interacting with DB. ...
user avatar
1 vote
1 answer
71 views

Go Lang custom convert array into string with two separators

This is my custom function to join strings from an array into one string. We can provide normal separator and the last one. ...
user avatar
  • 11
2 votes
0 answers
47 views

A terminal based atom feed reader written in golang

I'm a beginner trying to get a better understanding of golang so I decided to write an atom feeder that runs from the terminal. I am using the gofeed library to parse the atom feeds and the tview ...
user avatar

1
2 3 4 5
12