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

Possible Combinations m out n, sorted and without repetition

I wrote the following function to get all possible m-of-n combinations, sorted and without repetition. I am new to Go and I am wondering what are the possible enhancements I can make, in terms of ...
3
votes
1answer
57 views

Proper way to map the object

I have a simple task. Array of people object comes in, up to a thousand. Need to iterate over it, and create a custom payload for external service. I have created a working solution, but I would ...
1
vote
0answers
25 views

Parallelizing identical long-running tasks with Go channels

I have written a program in Go to compute the discrete logarithm mod primes (find \$x\$ such that \$h=g^x\mod p\$), and the algorithm I am using can be easily parallelized. Essentially, I am trying to ...
2
votes
1answer
28 views

Multiple input checks, repeat if conditions are not met

I've used this code to make some inputs checks. On any failed check, I need to ask again for proper input. I used labels and goto...
0
votes
0answers
16 views

Swagger API with Gorm DB connection

I have an API Swagger generated, I'm not satisfied with how I'm handling my part of the contract e.g. how I have constructed my db and ...
0
votes
1answer
67 views

filter and map functions

I am a JavaScript programmer beginning with Go. I tried to replicate filter and map functions like JavaScript's, as an exercise....
1
vote
0answers
27 views

Read value from config and return function

I’ve the following function which should be run in production I read some config If valid add the runner otherwise just return, the function is working! Is there a cleaner/better way to do it in go? ...
-1
votes
1answer
75 views

Find string enclosed in brackets [closed]

I have this find function. Is it concise, efficient and readable with good logic flow? ...
0
votes
1answer
42 views

Increment struct value using reflection

The main idea is, I have a struct and I will get a struct field as a string from another function, which I shall increment its value by 1. Below is the code I used and I think it is memory consuming. ...
1
vote
0answers
17 views

Breadth first search of a binary-tree with channels

As an exercise in using channels in Go I implemented a breadth-first traversal of a binary tree, using a channel as a queue to store the order of the nodes to traverse. After ironing out a bunch of ...
1
vote
0answers
35 views

Command line utility for user data migration from MUBI.com to letterboxd.com

Please make code review for command line utility for user data migration from MUBI.com to letterboxd.com. Utility makes Get HTTP request downloads json-data, parses it and saves as CSV-file. Can be ...
0
votes
0answers
45 views

2 Weeks into Go: Golang Tour WebCrawler Exercise

I'm on week 2 of learning go. I just completed the golang.org exercise on creating web crawler (https://tour.golang.org/concurrency/10) and I would please like feedback on my code. It feels overly ...
0
votes
0answers
40 views

Golang - Abstract Factory

Here I'm trying to learn the Abstract factory pattern. Have referred some examples and trying to mimic the same with some dummy server examples. Please help me to review this. ...
3
votes
2answers
182 views

Golang unbuffered channel - Correct Usage

Here is an example where I'm trying to understand the concepts of buffered channels> I have three functions and create a buffered channel of length 3. And also passed a waitgroup to nofiy when all ...
3
votes
1answer
66 views

Golang Rest API

I want to ask if there is a better way to arrange this. Main concern is whether the store is set up in a good way and if passing Pointer to ProductRepository is a good idea or there are better ways ...
0
votes
0answers
47 views

Golang parser for code generation and http request binding

After making some changes to an API realized I had to manually rewrite too many sections of code. That started me looking at different code generation techniques. I did a bit with Swagger/OpenAPI but ...
1
vote
1answer
80 views

Parallelized web crawler using goroutines and channels

As part of the "a tour of Go" section on golang.org, I was trying to make a (formerly singlethreaded) web crawler parallelized using goroutines. I got it working but it doesn't seem to "...
0
votes
0answers
43 views

Go: Optimize Inclusion/exclusion check

This function works as such: Use_Inclusions and Use_Exclusions are either true or false File_Type_Exclusions is a slice of ...
0
votes
1answer
74 views

Is there a better “Go” way to implement LC Add Two Numbers solution

Problem Statement: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the ...
2
votes
1answer
95 views

Reverse Root Solution

Solved one of the easiest problems from acm.timus.ru. 1001. Reverse Root The input stream contains a set of integer numbers Aᵢ (0 ≤ Aᵢ ≤ 10¹⁸). The numbers are separated by any number of spaces and ...
2
votes
1answer
42 views

Simple http helper in Go

Can you please share your thoughts on the following simple httphelper in Go? Thanks in advance. I mainly would like to know whether returning a channel of a custom type seems like a good idea and if ...
2
votes
1answer
38 views

Creating SQL Table from a Go Struct

I have been building an API in Go, which I want to link to a Postgres SQL table. I have always used NoSQL previously but thought ...
-2
votes
1answer
69 views

Am I using unnecessary If statements? [closed]

I have this following code snippet, I was wondering If I am using unnecessary If statements? ...
1
vote
1answer
72 views

SO golang example with infinite for / channel workers

I whipped this up as an example of how infinite loops can often be used to great effect in golang, and also to discuss closing channels and worker communications. It was strictly off the cuff, but I ...
2
votes
1answer
73 views

Testing a template function in GoLang using mocking - making it DRY & easy to follow

TL;DR I'm wondering how to organise test functions using mocks for GoLang drier & easier to follow. Function I have a template function that is very similar to ACF's getField: It take's in a ...
1
vote
0answers
61 views

Golang DB connection with AWS SSM Parameters and context

I'm working on setting up an app backend that's deployed automatically using infrastructure-as-code and a ci/cd pipeline. As a result of that I need the app server to gather DB credentials ...
3
votes
0answers
52 views

Checking data on an incoming request in Go

I am trying to learn Go and as way of throwing myself in the deep-end I thought it would be cool to try building a web framework instead of using an already existing solution. I'm coming from the ...
3
votes
1answer
61 views

Waiting for goroutines to finish

I have a program that starts a bunch of goroutines, feeds them data and when there is no more data, waits for the goroutines to finish. I use sync.WaitGroup. I am unsure if I am using correctly, in an ...
5
votes
0answers
55 views

Extracting numbers in specific ranges from a slice

Consider a slice with some floating point numbers: nums := []float64{0.17898, 0.25512, 1.98123, 1.35902, 0.97642} Suppose I want to extract the numbers lying in ...
4
votes
1answer
170 views

Historical Funding Rate Miner for ftx.com

I recently started to take a look at the Go programming language and decided to write a small project without practical use. The objectives were: Regularly poll the latest funding rates from https://...
3
votes
0answers
53 views

How can I make this code less verbose?

Newbie here. I have this gqlgen api with sqlc update code, which updates the user by given id with provided fields: ...
2
votes
0answers
37 views

Using go jobs with generic function

I use the following which works( I remove the unnnecery parts to the question) https://play.golang.org/p/OozjexJ4hZk The program is doing the following: run concurrent functions each function should ...
3
votes
1answer
53 views

Coded a Go Script that Sends proxy requests to backend servers

I've started Go for the last couple of months and I decided to challenging small projects, so I created this proxy requests script. It works well (in my opinion at least) but I'm looking for different ...
3
votes
1answer
81 views

Get client information with GET request in GO API

For an API I have defined a "Client" struct which contains all the fields the client has in the database. When a GET request is made with the client ID the whole struct(The struct contains ...
6
votes
1answer
134 views

Concurrent Web Crawler

Description As an exercise of learning go concurrency patterns, I decided too build a concurrent web crawler. I made use of the argparse module I put up for review a while back. I'm looking for ...
3
votes
0answers
44 views

Go language implementation of js promise static method

I try to implement the features of the js Promise using Go. Currently, I had implemented Promise.all(), Promise.allSettled() and ...
3
votes
0answers
26 views

Basic authentication with session ID

I'm quite new to web development. I want to implement basic session ID authentication. Here's the implementation ...
2
votes
0answers
24 views

Profiling redis RTT in go

I'm trying to determine best case round-trip times to a redis server. Particularly, I am trying to determine exactly how low I can get the latency on a local instance. On a technical level, this is ...
3
votes
0answers
137 views

Argparse for Golang

Reasons I'm recently learning Go with various exercises (might be more questions coming in the future) However, I'm quite annoyed with the default argument parsing module in Go flag as it doesn't ...
2
votes
2answers
50 views

Go Quiz exercise, part of Gophercises

This is the first exercise from https://gophercises.com/. Basically the idea is to parse a CSV file in a form of 'question:answer' and count the number of correct answers. Also you have a time out ...
1
vote
0answers
47 views

LeetCode 146: LRU Cache (Go)

Posting my code for LeetCode's LRU Cache, if you'd like to review, please do so, thank you for your time! Problem Design and implement a data structure for Least Recently Used (LRU) cache. It should ...
5
votes
0answers
102 views

Security of cookie based authorization Golang

I still write login system in Go(Golang) using cookies.But my system is still not secure enough.Can you review my code and provide some suggestions on how to improve the security?Previous question. ...
2
votes
0answers
95 views

Javascript / Go plug-and-play server-side WebRTC support for webcam streaming

I normally program in a linux vm and decided to do some machine learning with my webcam when I realized the vm didn't have access to my camera hardware. That kicked-off a mini project to create a plug-...
1
vote
0answers
23 views

Orchestrating an unknown number of goroutines

I recently wrote a piece of code to parallelise some code with goroutines and I was wondering if I could get some feedback. It looks overly complex... but I'm not sure how I could make it simpler. It'...
1
vote
1answer
109 views

Cookie authorization Golang

I'm writing login system in Go(Golang) using cookies.I think it's isn't safe enough. Can you provide some suggestions on how to improve the security. Main file: ...
3
votes
0answers
186 views

Dining philosophers problem in Go

I'm new in Golang and haven't done concurrency in a bit. I would love to hear your opinion on my Dining problem Go solution. Description here, with a tl;dr below: Five silent philosophers sit at a ...
2
votes
0answers
64 views

Structuring Service and DAO Layers in Go

I am having a bit of difficulty in designing my Go code. I'll try to demonstrate things with a very simple example of adding a new user to the database. My Handler is only doing one thing: Calling a ...
4
votes
2answers
61 views

An example of transferring the C ++ class hierarchy to Golang. Is it done correctly?

I am trying to transfer my c ++ experience to the Go area. I'm new to Go, so not sure if the implementation is correct. In any case, it looks very ugly compared to C ++ code. Is there a nicer solution?...
3
votes
0answers
34 views

n executions of a periodic goroutine

I'm new to Go and have a use-case for periodically executing an async work-function. I want the interval between work-function executions to be constant (not the time between one finishing and the ...
0
votes
0answers
54 views

Golang Error handling by a generic interface

I was wondering why we people don't use a generic interface instead of error type. You can see this pattern a lot in the Golang community: ...

1
2 3 4 5
11