Questions tagged [golang]
The term sometimes used for the Go Programming Language, since searching for just Go is usually too broad.
26
questions
18
votes
7answers
4k 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
...
-1
votes
1answer
57 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 ...
3
votes
1answer
44 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 ...
-3
votes
0answers
27 views
creating websocket connection in GO
I am trying to create a connection with a wss endpoint. My assumption is I make an endpoint on my system (socket) and listen on it, and create a client to connect to the endpoint of the website. I am ...
1
vote
0answers
29 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 ...
0
votes
1answer
57 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 ...
-1
votes
1answer
127 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 ...
1
vote
0answers
54 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 ...
0
votes
1answer
146 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 ...
1
vote
1answer
78 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 ...
0
votes
1answer
438 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 ...
4
votes
1answer
1k 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, ...
9
votes
1answer
6k 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 ...
-2
votes
1answer
234 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 ...
1
vote
0answers
115 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 "...
1
vote
2answers
209 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 ...
1
vote
1answer
113 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/...
0
votes
2answers
97 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 ...
4
votes
4answers
3k 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 ...
1
vote
1answer
479 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 ...
-1
votes
1answer
7k 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},
{"...
2
votes
1answer
308 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....
0
votes
3answers
237 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 ...
2
votes
1answer
150 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 ...
-8
votes
1answer
330 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 (...
13
votes
3answers
15k 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 ...