Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [go]

Go, commonly referred to as "golang", is a fast, statically typed, compiled language created by Google. The language was initially developed as an alternative to C++ for server infrastructure and has native support for concurrency.

0
votes
0answers
11 views

Web server using syscalls in Go

I'm new to Go and wanted to implement a web server using system calls to get a better feel for how everything works. I'm looking for feedback on idiomatic go especially error handling and using ...
3
votes
1answer
41 views

Polynomial implementation in Golang

I am writing a numerical analysis library in golang for which I need to implement a polynomial struct. Here is the source code: ...
2
votes
1answer
47 views

Locate substrings within a file

Here, I am reading in a newline delimited file that can be millions of repeating lines that looks like this: ...
0
votes
0answers
39 views

Golang message bus for a game engine

I wrote a memory bus struct in golang to allow systems to interact with each other without knowing anything about the receiver. This is for a game engine. I know it's not good to write games in ...
4
votes
0answers
43 views

Prettify phone numbers

I am a java developer and I am trying to learn Go. I tried to make a simple code that take numbers from a .txt file and make print them in a prettier format. That ...
1
vote
2answers
45 views

Golang execute several go routine in loop and then wait

I'm new in Go and excited with its easy-to-use concurrency implementation. However I'm not sure if I'm doing it right in Golang way. Consider the code where I spawn ...
0
votes
0answers
25 views

Check mongodb status is running or not

I have written a program in golang which check the mongodb is running or not using commands. But I'm not sure that the program is sufficient or there is something need to change in the program Can you ...
0
votes
0answers
17 views

Go wrapper around io.Writer that tracks the number of bytes written

The code below implements ProgressWriter, a wrapper around io.Writer that can track the number of bytes written, and a function <...
2
votes
1answer
79 views

Finding all prime numbers within a range

I am trying to find all primes less than 2,000,000 and sum them together. My code currently takes 1'36" to run. Is there a faster way to get my solution? The logic I am following in this code is make ...
3
votes
1answer
25 views

Go API server - request handlers becoming excessively long

I'm developing a API server in Go. My route handlers are becoming excessively long, especially when the response needs a lot of information. For the following response type: ...
4
votes
0answers
348 views

CLI Utility Go - First Go Program

TLDR Python developer; first project in Go; looking for feedback :) Repo Overview I just started learning Go (need to use it at work). As a fan of project-based learning, I put together a small ...
0
votes
0answers
23 views

Plugin generator in Go

This is my first go program. It is a plugin generator and works only with Linux. The repository is open. It basically creates some Go code in some temporary file defining a function taken from ...
0
votes
0answers
19 views

Go interface design for a cluster provisioner application

I'm fairly new to Go and working on an application to create VMs in a some cloud provider. I'm trying to design interfaces and I'd love some reviews. The application creates a cluster (group of VMs ...
1
vote
1answer
39 views

Generating Image & Serving via HTTP with Go

What is does I'm reading The Go Programming Language. Below is my code for the last exercise in the first chapter, which is to create a webserver, generate an image, and serve the image via the ...
1
vote
1answer
36 views
2
votes
1answer
47 views

Reading shards from a Kinesis stream

Here is part of my implementation of reading a Kinesis stream. I am not confident that this is the best way to implement synchronizing returns from goroutine. Assuming there are N shards in the ...
2
votes
1answer
51 views

GOLang Game of Life Implementation

I decided to give Go a try and implemented a Game of Life Kata exercise in GOLang. I have no prior experience in Go and the majority of my experience comes from Java, C#, and Python. My code appears ...
3
votes
2answers
71 views

Go grep command clone

I am trying to make a simple clone of the command line utility grep. I'm working on it just for fun and to practice Go. The thing is, I am trying to make it in a way that if several files are given at ...
0
votes
1answer
44 views

Cartesian Product in Go

I am still fairly new to go, and would appreciate any tips on style, best practices, etc, but am especially interested to know if this non-recursive cartesian product implementation can be made ...
1
vote
0answers
26 views

Displaying Singapore bus arrival times using a Go template

I am wondering whether my template usage in main.go could be better. For example in other code I notice: ...
1
vote
0answers
111 views

Golang gRPC context to check if cancelled or if deadline is exceeded while running function code

I am writing a gRPC Golang application and am looking for the best way to check if the deadline is exceeded or if the client cancelled the call. On the server side I created a channel called ...
4
votes
1answer
46 views

Converting Markdown to HTML using Go

I recently ported a blog of mine from Python to Go (to improve speed and performance) and while all is great so far, I'd like some help optimising the Markdown ...
3
votes
1answer
89 views

Writing to a file in Golang across concurrent go routines

I've been reading around how golang writes to a file, and this stack overflow question and this reddit question highlights the fact Go doesn't gurantee atomicity when writing to a file system. ...
14
votes
2answers
584 views

Translate nucleic acid sequence into its corresponding amino acid sequence

Goal of the program The goal of the program is to translate a nucleic acid sequence into its corresponding amino acid sequence. The nucleic sequences have to be formatted in a specific format called <...
3
votes
0answers
45 views

Game of life in Go

I wrote the Game Of Life algorithm with Go. There are a million ways that we can implement the algorithm, but I want to know is it implemented in good-way or not? I wonder how can I improve the ...
1
vote
0answers
76 views

Handling CRUD methods with gorm and go-swagger

I've an application that uses gorm and go-swagger for a simple API. One of the route's handlers bloated to 66 lines, being ...
6
votes
0answers
95 views

Flight API querier

I am learning Go and wrote a small application that queries the Skyscanner API as my first attempt at learning. I was hoping someone more expert than me in the language could look over it at broad ...
1
vote
1answer
52 views

Finding suggested flight destinations from database in Golang

This is my first Go project. Coming from a Java developer background, this code just smells very bad. But, cannot figure out better way to do this. It's a small app to find suggested flight ...
5
votes
1answer
69 views

Small program to get binary diff offset between two small files

Trivial utility program meant to go through the list of (small) files and report file offset of the first difference between them. The goal of the code is simplicity. Any recommendations are useful. ...
4
votes
1answer
42 views

Making a Zsync file archive with checksums

I'm learning go by doing it. I tried to port the Java's ZsyncMake implementation into Golang. I also employ the Go's concurrency API with goroutine and channel. I have some experience in Java, but ...
0
votes
1answer
53 views

Modeling a classroom with teacher and students using the mediator pattern in Go

I've made this implementation of a classroom with teacher and students using mediator pattern. Mediator is the teacher and colleague are studends. Main function is the following. Main function ...
1
vote
1answer
165 views

Property file into configuration in Go

My first ever attempt at Go. Writing a small app. It takes a property file and uses it to populate a Config object. After adding the first property of the Config object (dateformat) I realised that ...
1
vote
0answers
15 views

Extract script body or script src for internal and external JS scripts respectively

I have written a function func getScriptsFromUrl that accepts a URL and creates two files with script body and script src for internal and external JS scripts ...
1
vote
0answers
61 views

Hello, World BDD in Golang

I've tried to do some BDD in Golang using Godog. File Hello.feature: ...
1
vote
2answers
84 views

Extract unique words from given text and group by letter count

The task is for training go-lang. The idea is to extract unique words sorted and grouped by length. Might be useful in learning new words. The program uses command line argument assuming it's a file ...
2
votes
0answers
71 views

Getting all unique permutations from a slice of integers slices in golang,

For a project I'm working on I have a set of number sets, and I need all unique permutations of them. I want to return only one copy of each unique number set, and I'm struggling to figure out how ...
0
votes
0answers
16 views

Go SQL relationship scanner

I have written a function which takes in an sql.Rows instance and returns an array of model.Trip instances derived from the rows....
1
vote
0answers
12 views

Dealing with API routes in form of interfaces

Today I had an interesting idea. I have been copy/pasting the following line for each kind of request method for every route. ...
2
votes
0answers
50 views

A task scheduler with persistence

I wrote a task scheduler package with data persistence in Go. However, the logic seems super messy... even it seems passed all tests. Is there any better way to structure the code and finish few ...
0
votes
1answer
64 views

Reading lines from a file and processing them concurrently

I'd like to read lines from a file and process them concurrently. I came up with the following code to do this: ...
3
votes
2answers
162 views

int to Roman numerals in Go / Golang

For a new project, I've started learning Golang. This is one of my very first steps in Go. The objective that I've given myself is to convert int to a String representing the roman numeral of that ...
1
vote
0answers
96 views

Concurrent hash map implementation with Go's channels

I've implemented a concurrent hash map in Go. I'm fairly new to this language as I have mostly Python background so I'm looking for suggestions how to improve my code. I've ran the tests with ...
2
votes
1answer
110 views

Interview Take Home Challenge: Chat server

Recent take-home challenge I was assigned from a recruiter prior to technical interviews with the team. The team wanted it written in GOlang (I had no experience in the language) but told the ...
2
votes
0answers
58 views

Exporting tables from 30 databases

What my code do: Connecting to 30 DB (consistently) Copying DB file to temp.dat Reading temp.dat Writing read data to file So, it connects 30 times with different databases. This take 6-7 second (...
4
votes
2answers
121 views

Show all primes in go

I'm trying to go through Adrian simple programming tasks; Elementary task 8 It's basically asking for an infinite loop to print every prime number as it finds it. Are there too many ...
3
votes
1answer
77 views

HTTP Load test with Golang

I am a golang novice... I am trying to write an application that takes in many requests - up to a sustained 10000 HTTP posts/sec and post the payload to two back-ends in parallel (5 second timeout). ...
3
votes
1answer
724 views

golang rabbitmq message consumer

I need to process rabbitmq messages with golang with worker style, is this correct way to process rabbitmq messages with golang? ...
1
vote
0answers
42 views

Go: Generate color palettes for set of files in a directory based on a specific field property in each of them [closed]

Intro Last time I coded was with Pascal in high school, for reasons I decided to pick up Go and for the sake of learning while doing I made this program. It works as seen from the succesfully ...
0
votes
1answer
161 views

XML file parsing in Go

Below is a piece of code that is responsible for serializing files. ZL_LIST and PERS_LIST are XML file structs, I have not shown ...
4
votes
1answer
144 views

Inefficient binary search? Hackerrank - Climbing the Leaderboard

I'm learning Golang and have been trying to get 100% on the following Hackerrank practice challenge: Climbing the Leaderboard The code passes ~8 of 11 tests. The Hackerrank tests are time-bound and ...