Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [golang]

The term sometimes used for the Go Programming Language, since searching for just Go is usually too broad.

Filter by
Sorted by
Tagged with
1 vote
1 answer
100 views

Return function after kicking off background process

I have a process in golang that I want to kickoff through a RPC call but then have the function return early whilst the process continues in the background. Specifically it’s just a basic db transfer ...
Person1's user avatar
  • 21
-2 votes
1 answer
313 views

Go’s answer to c10k problem

I have few questions on the go's answer to c10K problem. How is an event loop different from the network poller described in this blog? I see a striking similarity between waiting threads and waiting ...
ProgramCpp's user avatar
1 vote
2 answers
673 views

design pattern to avoid deadlock with mutex in golang

What would the appropriate design pattern to avoid deadlock when several functions use the same mutex ? It is quite easy to forget what method uses the lock and so it happens that you call a function ...
cylon86's user avatar
  • 111
0 votes
1 answer
326 views

Cheap But Effective Solution for Logging in a private rest microservices backend api

I've created a backend following a microservices architecture and now I need to implement logging. my understanding After reading some articles about this topic, I've listed below some "pretty ...
Big_Boulard's user avatar
3 votes
1 answer
289 views

How are interfaces implemented behind the scenes in the Go language?

I have read this article which indicates a double tuple structure, but it is unfortunately light on implementation details, which is what I am looking for. So... how are interfaces implemented in Go? ...
SRNissen's user avatar
  • 161
0 votes
1 answer
308 views

Cron job to read multiple "entities" from the database

I have one microservice (in GO) that needs to read a whole table every hour, filter out some data and send it to another application. So as an example, imagine I have the following model: type User ...
Manuelarte's user avatar
1 vote
1 answer
290 views

Creating a new type as slice of strings in Rust?

I have a little bit of experience with Go, that I have been trying to use as a reference point to wrap my mind around Rust via a cards game I wrote in Go that I would like to now write in Rust. I know ...
Daniel's user avatar
  • 119
0 votes
1 answer
384 views

Making side effects explicit even in non-pure functions

I try to have as many pure functions as possible, but if I can't, I at least try to make the side effects as explicit as possible. Here is an example (in Go) type State struct { count int } func (...
AndreaL's user avatar
  • 119
1 vote
1 answer
237 views

How to solve duplicate request with Distributed Lock Management in Golang

I’m trying to test concurrently request (brute force test), with 1000 request/sec (same request id). I’m using Rest API. The service running on distributed system, I’m using 3 pods. The problem is I ...
Abyan Juang Kecci's user avatar
-1 votes
1 answer
171 views

Writing a API for a hardware device for mutliple platforms

We want to create an API to communicate witha device we currently sell. The API should be available for several platforms like C / C++ / .NET / Python and available for Windows and Linux. The idea is ...
Felix Almesberger's user avatar
0 votes
2 answers
1k views

Golang interface-implementation circular dependency

In trying to separate interface from implementation, I ran into a circular dependency problem. There is a best practice in the world of Java: consume interfaces instead of concrete classes. That is, ...
selamba's user avatar
  • 109
3 votes
5 answers
1k views

(How) can the circle-ellipse problem be solved by using composition rather than inheritance?

I was reading about composition over inheritance and came across a question about solving the Circle-Ellipse Problem in Object-Oriented Programming. This kind of problem is often used as an example of ...
drkvogel's user avatar
  • 147
2 votes
1 answer
172 views

How do we maintain consistent-read promise to clients + handling ID collision when using a fallback queue?

In my company, we are using Event Sourcing pattern to implement a storage for all changes to the price of a booking. Across the company, different services might try to append events to a booking ...
JamesBoyZ's user avatar
  • 245
0 votes
2 answers
1k views

Golang Design Pattern for Generating View Objects in a REST API?

I have moderate Golang experience and lots of experience in other programming languages such as Java, Python, Rust, Scala, and others. I'm comfortable with building REST services and most of the other ...
Naftuli Kay's user avatar
  • 1,621
0 votes
0 answers
94 views

What is considered as best practice for defining common types in golang?

We have set of common types (mostly structs, scalars, string IDs) that are used across different packages in a project written in Golang. Currently we define them in a package named "models" ...
oare234's user avatar
11 votes
1 answer
3k views

Why Golang projects seldom use mocking library in testing?

New to golang and is now researching on how to do test in golang. I see that there are popular mocking library like gomock. However, at the same time, I see that large golang open source projects don'...
cytsunny's user avatar
  • 637
62 votes
10 answers
25k views

Does it ever make sense to use more concurrent processes than processor cores?

I've got some process in Go. Here's an example counting lines in text, though the question is meant to be far more general than this particular example: func lineCount(s string) int { count := 0 ...
TheEnvironmentalist's user avatar
0 votes
1 answer
560 views

Race conditions in API calls within Golang microservices

I have a microservice architecture running on Heroku. I am having some problems handling race conditions. The problem is, that service A: Needs to fetch the user's balance through an API call to ...
Harald Nordgren's user avatar
3 votes
1 answer
1k views

How to test channel pipelines in Go

I use the "channel pipeline" pattern quite a lot in Go, which looks something like this: // getSomeNums spits out ints onto a channel. Temperatures, pressures, doesn't matter func ...
Tal's user avatar
  • 141
1 vote
0 answers
42 views

Offloading database joins to IOT devices

Solution as it is right now I have this solution where I gather information from a proprietary product of a different company in various sites. The solution is based on a single go binary that ...
Marged's user avatar
  • 225
0 votes
1 answer
116 views

How should I distribute my app with my own OAuth2 client ID, without letting anyone find it out?

I've written an app using golang which uses OAuth2(Authorization code flow with PKCE) to interact with the Gmail API. If I build the app using my own client ID then my client ID can easily be found ...
Utkarsh Verma's user avatar
-1 votes
1 answer
158 views

Is there existing technology write code to be executed in response to an email being sent for a certain email? [closed]

Similarly to a rest api, I want a server to listen for an email to an address I have created, and in response to mail being received, run code that I have created. Is this possible already? I ...
Rahmi Pruitt's user avatar
1 vote
0 answers
242 views

Can I add new function for protobuf generated struct

I am using protobuf definitions to define message types. Structure looks like message1 { } message2 { bytes msg1 = 1 } So message2 has a field which is a byte array representation of message1. I ...
Korba's user avatar
  • 111
0 votes
1 answer
222 views

REST API with 1000 query templates?

How do I manage maybe 1000 SQL-queries in a Golang REST API? My SQL experience is at the upper basic level using Postgresql. I am today using a tool that you can use plain SQL as well as sort of ORM ...
sibert's user avatar
  • 113
2 votes
1 answer
108 views

Building object with arbitrary functionalities

I am trying to look for the right design pattern for the below scenario. I am trying to create an object/binary with different modules, a module is a functionality that I want to provide to that ...
Timothy Leung's user avatar
1 vote
1 answer
723 views

How can a factory method stay true to "Accept interfaces, and return structs" in Golang?

Let's us say I have a package which contains different types of TV structs. Now, based on the parameters passed I would like to return a specific TV type. How is it possible to return the specific ...
pinkpanther's user avatar
6 votes
1 answer
2k views

How to test interactors in clean architecture?

After reading the last book from Robert C. Martin, I've tried a to develop some big Go applications following clean architecture. While writing interactors, I end up with a lot of complex unit tests, ...
luistm's user avatar
  • 163
9 votes
1 answer
7k views

How to structure a Go application, architected according to the clean architecture

I'm trying to build a project using the clean architecture, as described here. I found a great article on how to do this in Go. The example is a very simple one, and the author puts their code into ...
bigblind's user avatar
  • 1,425
-1 votes
1 answer
361 views

How to deal with licensing when importing remote packages in golang?

In golang, one can import packages with urls such as import "github.com/foo/bar". Do I still have to include the license of the remote package, as I'm not including library source code directly? How ...
ollien's user avatar
  • 129
1 vote
0 answers
163 views

Concurrently parsing records in a binary file in Go

I have a binary file that I want to parse. The file is broken up into records that are 1024 bytes each. The high level steps needed are: Read 1024 bytes at a time from the file. Parse each 1024-byte "...
Dan's user avatar
  • 127
1 vote
2 answers
216 views

How can I include common strings (regexes) in several projects written in different languages?

I have a simple Go library (~300 lines, mostly type declarations and nice methods and compatibility methods for gomobile etc., also pretty-printing scripts). The heart of the whole project are two ...
Mika Feiler's user avatar
1 vote
1 answer
209 views

How perform automated tests over code that changes a DBMS (throught DML or DDL)?

I'm written a software as an exercise to improve my skills and I ask my self about how to test code that changes a database. Let the code in my github: https://github.com/daniloanp/Ensaios/blob/...
Danilo's user avatar
  • 11
0 votes
2 answers
102 views

How can I effectively design password authentication for encryption in my project?

I'm working on a small personal project that involves a user entering a password that would then allow them to view a text file that would otherwise be encrypted. I'm having trouble wrapping my head ...
Grant Seltzer's user avatar
5 votes
6 answers
5k views

Flow control in Go without a for loop

I've been set a challenge that I'm trying to get my head around, but am struggling with the best (or 'correct') way to implement it. The challenge is to create a simple console app written in Go that ...
Hexodus's user avatar
  • 77
1 vote
1 answer
656 views

Exposing blocking API in golang?

I have a golang library that abstracts a network service (think IRC-alike). The network server produces events which users of my library should consume. I'm using blocking network calls internally. I ...
mappu's user avatar
  • 21
-1 votes
1 answer
8k views

Sorting an array based on another array's order, quickly [closed]

There are two arrays of maps. The first array contains maps of ID values in a specific order (but not necessarily either pure ASC or DESC ordering): // pseudo code first := [ {"id": 1}, {"...
Curtis La Graff's user avatar
2 votes
1 answer
884 views

Best Possible Way To Write Unit Tests For HTTP Middleware

I am using this go library(https://github.com/abourget/goproxy) to create a custom proxy server app. The app is utilizing several middleware of the following form: MyMiddlewarFunc(ctx *goproxy....
Rana's user avatar
  • 141
0 votes
3 answers
256 views

Identical Databases for Multiple Users Reading Efficiency

Our project utilizes a static database (no writes). With many users we don't actually have a problem per se reading it. If a database "locks" per read request by any user, then would it not be more ...
victoroux's user avatar
  • 103
2 votes
1 answer
227 views

TDD Duplicate Testing on Related Classes

In following the principle of testing only the exported functions on a package (using Go - or for others languages, the public functions on a class), I'm running into a scenario where related packages ...
Andy Brewer's user avatar
-8 votes
1 answer
368 views

Golang Testing Process [closed]

I am new to golang and RunC and now doing some research on it as a part of my intership. What kind of contents do the ' _test.go ' functions check during testing a program or a container with Golang (...
Sambhu's user avatar
  • 1
17 votes
5 answers
22k views

Use of "this" in Golang

On the closest thing Golang has to a style guide found here, under Receiver Names this is written: The name of a method's receiver should be a reflection of its identity; often a one or two letter ...
Adam 's user avatar
  • 1,387
35 votes
4 answers
6k views

How much is Google investing in the Go language? [closed]

I have read quite a bit about the Go language, and it seems promising. The last important bit of information I am missing before I decide on spending more effort on the language is: How much money/man ...
David's user avatar
  • 4,439