Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.

Questions tagged [go]

Go, also called golang, is an open source programming language initially developed at Google. It is a statically-typed language with syntax loosely derived from that of C, adding automatic memory management, type safety, some dynamic-typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library.

Filter by
Sorted by
Tagged with
5 votes
2 answers
1k views

I'm trying to get hands-on experience with Uncle Bob's Clean Architecture in Go, but I'm running into some issues. Also, I'm not yet familiar with all of Go's idioms. For testing purposes, I'm ...
Crite's user avatar
  • 61
4 votes
2 answers
694 views

I just learned about the Functional Options pattern in golang. what are the benefits of using it over just allowing to pass a config struct and just overriding the default values provided in the ...
moshevi's user avatar
  • 149
1 vote
1 answer
113 views

The title Go, Error Handling, and Big Text Files is a blog post from Wesley Aptekar-Cassels from 2021. In this blog post he reports about a problem he faced parsing long text files. He tried scanner :=...
surfmuggle's user avatar
1 vote
1 answer
506 views

I have an endpoint similar to GET ../produtcs/123 where 123 stands for an ID. The REST service response with either status 200 and a json object A {"deliveryData": {"status": 200, ...
surfmuggle's user avatar
1 vote
1 answer
258 views

As far as I understand (not much), the archival .a file is just, roughly speaking, the collection/batch of object .o files. It's like a library of compiled code that can be cached and which can be ...
LeaBit's user avatar
  • 151
0 votes
2 answers
242 views

I've been at my current job for about 4-5 months, mainly working with Go, and I have no prior experience with Kafka. Before this, my background was in JavaScript, Node.js, React, etc. I recently got a ...
Anatoly's user avatar
  • 274
1 vote
1 answer
132 views

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

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

Had a discussion today in how to implement services that work with messages coming in from event queues. We call these services processors. One of us argues for using several functions, while the ...
Albert Balbastre-Morte's user avatar
0 votes
4 answers
3k views

I'm relatively new to Go but I come from a C#/OOP background where unit testing private methods isn't something that's generally done. I currently have a senior developer telling me it's "bad ...
Al_M42KM's user avatar
1 vote
1 answer
214 views

I am working on a Go application where two concurrent maps, products and productCatalog, are accessed by numerous threads in live traffic to retrieve data at high throughput. These maps are populated ...
dragons's user avatar
  • 121
0 votes
0 answers
105 views

I'm very new in DDD and I was following one of the videos of GohperCon to structure of my Golang App using DDD with Hexagonal Architecture. At the lowest (deepest) layer is the storage that can be ...
markfw's user avatar
  • 101
1 vote
2 answers
1k views

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

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

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

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

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

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

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

I followed the guide here https://quarkus.io/guides/building-native-image to set up a minimal quarkus webservice graalvm native image. Ran command 'time quarkus build --native' to compile the example. ...
vancan1ty's user avatar
  • 119
-3 votes
1 answer
169 views

I previously asked this on StackOverflow, but doesn't fit there and I was suggested to move it here. I was thinking about using two seperate backend languages for seperating concerns in a project of ...
HackXIt's user avatar
  • 97
-1 votes
1 answer
234 views

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

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

I've recently been learning go and the versioning system seems rather odd to me. Most languages / dependency management systems that I'm familiar with (like rust and cargo) have an explicit way to ...
joshmeranda's user avatar
2 votes
4 answers
1k views

I have a utility function called connectToMongoDB() which connects to MongoDB. Basically, it creates a client for MongoDB and returns that. I'm making a library and I'm thinking of unit testing the ...
DaCool1's user avatar
  • 37
4 votes
5 answers
2k views

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
  • 157
1 vote
0 answers
182 views

I need some help with my authentication design. Happy to share any code as needed... Overview I have implemented the Google Sign-in (new web implementation here) button in my client web application. ...
Zack Shainsky's user avatar
2 votes
1 answer
190 views

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
4 votes
2 answers
363 views

I have a class (as a protobuf) OrderChange, that represents when an order (imagine Amazon.com) changes: message OrderChange { Order old_order = 1; Order new_order = 2; } message Order { ...
onepiece's user avatar
  • 169
1 vote
0 answers
332 views

I need to consume several APIs concurrently. In order to do that I decided to containerize each API client code and manage them using Kubernetes. Some of those APIs need to be "walked". They ...
beardeadclown's user avatar
0 votes
2 answers
2k views

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
1 answer
504 views

I'm working on a project which focuses on simple HTTP-related actions (to get my feet wet really). I'm using the net/http package, which I thought was very convenient for almost all requirements ...
Chien's user avatar
  • 129
0 votes
0 answers
215 views

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
1 vote
1 answer
236 views

I'm asking myself above question since I implemented an API that accesses a third-party API and currently write tests to increase my code coverage in the class that communicates with the third-party ...
hullunist's user avatar
  • 137
-3 votes
1 answer
426 views

In Programming Distributed Computing Systems: 7.3.4 Distribution Distributed computing is inherently concurrent. However, distribution aspects go far beyond concurrency. Of particular importance from ...
Tim's user avatar
  • 5,555
11 votes
1 answer
3k views

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
67 votes
9 answers
9k views

Java has "checked exceptions", which force the caller of the method to either handle an exception or to rethrow it, e.g. // requires ParseException to be handled or rethrown int i = ...
Heinzi's user avatar
  • 9,868
1 vote
1 answer
345 views

I have a Single Page Application that uses React-Router and is served via Go backend. The pre-built static app is accessible at app.com which then uses app.com/api to load dynamic data. If a user goes ...
Coupcoup's user avatar
  • 220
2 votes
1 answer
158 views

A project is structured as so: A build server listens to changes in two repositories: a frontend and backend repo. When it picks up a change it builds, tests, and deploys the updates to a production ...
Coupcoup's user avatar
  • 220
0 votes
1 answer
695 views

I'm designing a monolith RESTful API that potentially sometime in the future may turn into microservices. I'm also trying following Uncle Bob's clean code as well. My question lies in structuring the ...
Gabe's user avatar
  • 127
0 votes
1 answer
92 views

With a single publisher(go-routine) and multiple subscribers(go-routine) on same machine, below message hub help create pubsub model: type PublisherHub struct { subscribers map[*subscribmediator....
overexchange's user avatar
  • 2,315
63 votes
10 answers
26k views

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

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

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

I am currently writing a quiz web-app with a React front-end and a Golang backend, with a PostgreSQL database to keep track of the quizzes, the questions on the quizzes, and the choices in the ...
Eddie Hatfield's user avatar
2 votes
2 answers
236 views

Within our codebase we have integration tests like these: func TestActivateSuspendedFoo() { // setup all dependencies baz := jsonToStruct( "baz": { "a": ...
Filipe Gorges Reuwsaat's user avatar
1 vote
0 answers
54 views

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
  • 235
1 vote
1 answer
1k views

I'm trying to learn about MODBUS as a free-time project. It is a long standing desire to write my own driver in Golang. That being said, I'm now trying to design the concurrency model for device ...
Tim's user avatar
  • 121
1 vote
2 answers
169 views

I'm working on a project that uses PubSub(GCP), my question is not specific to GCP, it's more regarding to the architectural pattern(I'm used to statically typed languages, and I have a hard time ...
alex's user avatar
  • 21
0 votes
1 answer
552 views

In order to build a messaging app, I have followed this example : https://github.com/gorilla/websocket/tree/master/examples/chat This consists of a Hub, running in a single goroutine in the program, ...
BinaryVeil's user avatar