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.
175 questions
5
votes
2
answers
1k
views
Repository and Service Interfaces in an Accounting Software in Go with Uncle Bob's Clean Architecture
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 ...
1
vote
1
answer
113
views
Go, Error Handling, and Big Text Files - express error semantics in types
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 :=...
1
vote
1
answer
259
views
Is there any logical reason to "store" just one object file (.o) into archival file (.a)?
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 ...
1
vote
1
answer
134
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 ...
1
vote
0
answers
134
views
golang: pattern for handling message queues? Are named functions anti-idiomatic somehow?
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 ...
1
vote
1
answer
215
views
High Throughput Concurrent Map Access and Periodic Updates Causing Contention and Latency Spikes
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 ...
1
vote
2
answers
1k
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 ...
3
votes
1
answer
395
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?
...
1
vote
1
answer
362
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 ...
1
vote
1
answer
435
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 ...
-3
votes
1
answer
169
views
Using two different languages where one would suffice for the task (microservices)
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 ...
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, ...
2
votes
4
answers
1k
views
Is it ok to test an external function?
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 ...
1
vote
0
answers
182
views
Managing user session state with Google Sign In
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. ...
4
votes
2
answers
363
views
How to structure many complex conditionals on a class
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 {
...
0
votes
2
answers
2k
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 ...
0
votes
0
answers
217
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" ...
-3
votes
1
answer
426
views
Is Go's concurrency model suitable for distributed systems and for microservices?
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 ...
67
votes
9
answers
9k
views
Why do "checked exceptions", i.e., "value-or-error return values", work well in Rust and Go but not in Java?
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 = ...
2
votes
1
answer
158
views
Golang / React Webapp Architecture
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 ...
0
votes
1
answer
92
views
Pubsub model - publisher broadcast to remote subscribers
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....
0
votes
1
answer
639
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 ...
1
vote
0
answers
80
views
Issues Regarding Data Model Abstraction in Golang
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 ...
1
vote
0
answers
54
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 ...
1
vote
2
answers
169
views
How to agree on message schema in a Publish–subscribe pattern
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 ...