Stack Exchange Network

Stack Exchange network consists of 175 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.

2
votes
1answer
59 views

Fetching configuration or default value

I have two code snippets, doing exactly the same thing and both get the job done: use defaults use from config Which is cleaner to use in golang and why? first option: ...
5
votes
1answer
82 views

Find the longest word in a string

I have written code in the language Go. I wonder if anyone can do it in a very simple and effective way, because every language has its own way to solve this problem. My experience is in JavaScript. ...
2
votes
0answers
34 views

Simple REST Base Web Server with Unit Tests

I am building out a simple web server in Go. My goal is to expand on this framework in a different application I am building. Here is my github repo https://github.com/jmacnc/gowebserver Is what I ...
1
vote
1answer
77 views

Remove adjacent duplicates in golang

This is an exercise in a book which ask me to implement Write an in-place function to eliminate adjacent duplicates in a []string slice. I am relatively new to golang and I am not sure if my ...
1
vote
1answer
70 views

Go command-line tool to do some simple byte manipulation

I have some files containing 16-bit words in big-endian order, and a tool to process them that assumes little-endian order. I therefore need to swap the order of each pair of bytes in my files. This ...
3
votes
1answer
57 views

Go implementation of dining philosophers

Follow-up of this question. Questions: is this code a correct implementation of the Dining Philosophers problem? what is there to improve regarding Go Best Practices? ...
2
votes
1answer
44 views

Gin framework project with an endpoint to return a list of users based on their score

My relevant work experience is with Java (mostly web development with Dropwizard/Spring) so I can not avoid using the same practices as I do in a Java project. The project is there but I am going to ...
1
vote
0answers
25 views

Go - avoid result reassignement in OOP [duplicate]

I'm learning Go and I wrote this for a programming challenge. It is working (building and running) but I feel the code is not what Go code should be: The code implements the steps a podracer takes to ...
1
vote
1answer
51 views

Simulating pod racing over a 2D map : am I implementing OOP in a GO-like fashion?

I'm learning Go and I wrote this for a programming challenge. It is working (building and running) but I feel the code is not what Go code should be. I used an OOP design. Is it correctly implemented ...
3
votes
0answers
37 views

N-Queens problem using other pieces using Go

I wrote a solution to a problem based on the N-Queens problem which should use more pieces than just queens. Problem is it's very slow, it probably has to do with how I modeled data and my lack of ...
1
vote
1answer
37 views

Decode Argon2 parameters and handling decode errors

I am writing a function to decode Argon2 hashed string to extract parameters. I need to handle many decode errors, and handle those errors lead to write many repeating ...
0
votes
0answers
27 views

Golang tool to check public repositories list in Github

Didn't post on the Codereview for a while but trying to learn Golang now and wrote my first utility a few days ago and will be glad to see what I did wrong here and what can be done better. This tool ...
1
vote
0answers
26 views

Extracting attribute value from multiple XML nodes in golang?

I'm attempting to parse an SVG file to get all of the colors that are present in the file. SVGs are XML based and their structure can vary a bit. For example: ...
1
vote
0answers
24 views

client handling of tcp server in go

I'm writing a service for a ORPG and I expect traffic of about 10kb of packets per second from multiple clients. I just want to know if my approach is correct? Are there areas I can improve? This is ...
1
vote
0answers
26 views

Transforming golden and input files in test table

I'm trying to find a way to create a test table from golden and input files. I have the following dir structure: ...
8
votes
1answer
86 views

Quiz game with timer

This is my first Go program. I would like to know what could be improved, what is done wrong, and anything else that I should know. The CSV contains 10 questions with the 10 answers separated by a ...
3
votes
0answers
81 views

Writing Go object code that respects Go guidelines

I'm learning Go and I wrote this for a programming challenge. It is working (building and running) but I feel the code is not what Go code should be: Am I using the ...
3
votes
1answer
105 views

Golang HTTP requests

I'm beginning to learn about Golang and I would like to have some advice about the following program. ...
3
votes
2answers
76 views

Download and save bulk URL concurrently

I am new to Go and wrote program to download and save bulk URLs concurrently. It is working correctly, but I would like to make it more efficient and follow best practices. ...
6
votes
2answers
112 views

Parse dblp XML and output sums of publications grouped by year and type

The following Go program parses a gzipped XML file (available here) which contains bibliographic information on computer science publications and has the following indicative structure: ...
2
votes
0answers
77 views

Simple Go Linux daemon to send/receive gob-encoded data on a socket

I'm currently working on a linux daemon and would like some feedback. The program is a simple unix socket server that sends around gob encoded messages. I'm still getting the hang of concurrency in go ...
7
votes
1answer
166 views

Drawing a snowman in ASCII art

I am learning Go and as an exercise I did this challenge from Code Golf (without the golfing), where an ASCII art snowman is drawn from a combination of body parts, based on an 8-digit code taken as ...
0
votes
1answer
86 views

Finding the longest Collatz sequence using Go, concurrently

I am working through this problem on project euler. Basic purpose of the code: ...
2
votes
1answer
76 views

Helium written in Go [closed]

Help me with code code review. Helium is my pet project, written in Golang. Helium is a small, simple, modular constructor with some pre-built components. https://github.com/im-kulikov/helium Simple ...
2
votes
0answers
49 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
60 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
60 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
77 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 ...
7
votes
2answers
74 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
216 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
43 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
21 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
89 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
28 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
363 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
24 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
20 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
41 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
40 views
2
votes
1answer
70 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
65 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
186 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
67 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
33 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
271 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
55 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
453 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
636 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
55 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
106 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 ...