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

intersect chanels in go

I have a simple golang app in which I have two background tasks that produce data, Each of them use it's own channel to signel it produced another unit of data. I have a single consumer that needs the ...
0
votes
0answers
17 views

Filtering methods for 3 collections

I'll start by saying that I just started learning Go coming from Python (and some basic on Java), so I am trying to understand how to write Go code in more idiomatic way and not in a Python way. Any ...
2
votes
2answers
43 views

Mocking Interfaces Golang

I thought of doing the following to mock/test functions in Go and wanted some advice. Let's say you have an interface for a repository: ...
1
vote
1answer
50 views

Golang - Splitting a string by a separator not prefixed by an escape string

I need to split a string by a separator but don't want to split if the separator is prefixed by the escape string. For example: ...
1
vote
1answer
60 views

Merge Intervals(Golang)

Solving the merge intervals problem in golang(link: https://leetcode.com/problems/merge-intervals/). The Problem ...
4
votes
1answer
54 views

Idiomatic Go Lexer

I have written some Go code that produces the output I would like, but I am unsure if the code itself "smells" good. I would like to know if it contains any anti-patterns, exemplifies bad ...
2
votes
1answer
58 views

Install helm chart automatically

I use the following code which works ok! The code is installing helm charts in loop in k8s cluster, and I want to verify that I'm writing it ok. ...
0
votes
1answer
17 views

Go Web API for Sending Emails via Contact Form

I've been playing around with Go and finally found a use case for a little web service I could build. It takes JSON data via an HTTP POST request and sends me an email via Mailgun's API (it's used for ...
0
votes
0answers
40 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
67 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
31 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
36 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
28 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
2answers
88 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
33 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
90 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
43 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
21 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
52 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
53 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
41 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. ...
2
votes
2answers
193 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
80 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
56 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
116 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
46 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
76 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 ...
1
vote
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 ...
1
vote
1answer
43 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 ...
1
vote
1answer
39 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
70 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
106 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
91 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
90 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
65 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
299 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
54 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
88 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
136 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
45 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
27 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
159 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
51 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
49 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. ...

1
2 3 4 5
11