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
1
vote
1
answer
181
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 ...
4
votes
2
answers
732
views
why would one use the "Functional Options" pattern in go?
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 ...
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 ...
0
votes
2
answers
245
views
Seeking a Third Opinion on Kafka Consumer Implementation and Architectural Disagreements
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 ...
1
vote
4
answers
8k
views
In Go when to write a function with or without a receiver?
We're trying to write Go in the most possibile idiomatic way, but sometimes we struggle to find which is the best way.
For example in our service we're creating/converting a struct from another one:
...
1
vote
1
answer
115
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 :=...
22
votes
5
answers
11k
views
Is a common library a good idea?
I've always thought that a "common library" was a good idea. By that I mean a library that contains the common functionality that is often needed by a few different applications. It results in less ...
1
vote
1
answer
261
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
513
views
How to handle different json response for the same api rest endpoint and different http status
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, ...
18
votes
5
answers
23k
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 ...
3
votes
1
answer
398
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
136
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 ...
4
votes
5
answers
2k
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 ...
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 ...
-2
votes
1
answer
544
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 ...