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.

learn more… | top users | synonyms (1)

3
votes
3answers
64 views

Command called 'sprinkle'

I have a command called sprinkle. I'm not going to explain anything about it, because I want whoever that reviews the code to also tell me how much of the command ...
2
votes
2answers
50 views

Slice chunking in Go

I have a slice with ~2.1 million log message strings in it that I am parsing for regular expression matches. For any matches, I add it to a local slice and then return said slice. ...
-2
votes
1answer
26 views

Listings Manager

I am trying to learn to code using Dependency Injection and IoC in GoLang. Please consider the following code. I am basically creating an interface ListingManager ...
6
votes
3answers
70 views

Selection sort algorithm with increasing/decreasing sort options

I am running through some traditional algorithms in Go, and I was hoping to get feedback on efficiency and optimization. Below is a basic selection sort algorithm that takes a parameter to dictate ...
0
votes
2answers
41 views

Executing periodic tasks

I am writing a code in Golang to execute a periodic function (every 2 second). According to documentation and an example I have written two programs. Can anybody tell which one is better? Also, is ...
3
votes
3answers
73 views

Golang implementation of Pascal's triangle

How can I improve my code and make it more idiomatic? ...
6
votes
1answer
53 views

Folder watching in Go

To try and track down a troublesome AS400 bug, my company wants me to keep track of the order in which files are put into a folder. I spent an hour whipping something up in Go, but I'm still pretty ...
6
votes
0answers
86 views

Web Crawler in Go

I'm a beginner in Go, just finished the Golang tour. This crawler is not the same as the one in the exercises in the tour but something I wrote myself. I am looking for suggestions for making it ...
12
votes
1answer
110 views

A* Go application

I've written a generic implementation of the A* algorithm as a first Go program, since I had implemented that both in C and in Python before and Go reminds me a bit of both. I'm looking for general ...
8
votes
0answers
62 views

Go database helper code

Today I've implemented a database helper in Go. I'm new in Go world so I just wanted someone with more experience to take a look and tell me what is good and especially, what is bad (and why, if ...
15
votes
1answer
152 views

Bruteforce MD5 Password cracker

I just started learning Go, and I wanted to created a project to learn more about concurrency in go. I heard about Go's lightweight threads, so I wanted to give them a try. This program uses ...
5
votes
1answer
34 views
3
votes
0answers
33 views

Command-line ssh address book app

I'm trying to learn a bit about Golang and decided to try out building an SSH address book command-line app. I used a YAML library to serialize and store data in a configuration file. The app has a ...
1
vote
0answers
79 views

Mobile app backend using Gin and Gorm ORM

I'm developing backend for my mobile app by using gin-gonic and gorm ORM (mysql). But I'm not sure api and db handle huge amount requests if clients increased. for example I'm using my db struct as ...
2
votes
3answers
57 views

Checking if a value is within a time range

How can I improve the style to avoid so many float64()s? ...
1
vote
0answers
43 views

Dining philosophers using channels

I have the following code to solve dinning philosophers problem using Go channels and am looking for review comments: ...
2
votes
0answers
43 views

The perfect multi-output logger

I needed to write my own lightweight GO multi-output logger for a work project and I've come up with https://github.com/asticode/go-logger. Basically the projects works like this: ...
5
votes
1answer
55 views

Comparing md5.Sum to text from file

In learning golang, I wrote a small CLI utility that will take paths as arguments and list out their md5 hash as hex strings. Included are two flags that alter functionality, ...
2
votes
2answers
55 views

Reading environment variables of various types

I need to extract some data from the environment variables using Go. This data can be string, boolean or integer, so I ended up writing three functions. ...
7
votes
1answer
80 views

Sum of primes in given range in Go

This piece of code calculates the sum of all prime numbers below 1 million. It stood out to me that the Ruby script is around 20% faster. I know that Go should be faster just for being a compiled ...
6
votes
0answers
124 views

Twitter clone in Golang

I have built a Twitter clone in Golang, using object orientation principles. I wish to know the design mistakes I have made. ...
0
votes
0answers
28 views

Downloading and reading data in go

I am trying to experiment with golang. This code spins off two Go routines: one to download data and another to read from the body. Both go threads are synced by the data channel. I have two ...
6
votes
2answers
122 views

Rob Pike's Golang presentation excercise of day 1

I'm following this presentation. At the very end there's an exercise about solving Fibonacci and says that instead of addition, make the operation setteable by a function. Is the following is a good ...
3
votes
0answers
33 views

Token generating library on Redis

This is a token generating library for Go that runs on top of Redis. I'm using it as part of a larger projects. The library needs to be able to generate and validate tokens and return the associated ...
2
votes
0answers
36 views

Flake ID implementation in Go

I have created an implementation in GO for generating Flake ids. The implementation in based on Factual\Skuld's implementation in Clojure Current limitations include: The current implementation does ...
3
votes
0answers
34 views

Baby Step Giant Step Discrete Log Solver

I've made a concurrent implementation of the Big Step Giant Step discrete log solver in Go. I'm pretty new to this branch of math, but it seems slow. Any way to speed it up or is this the limit of ...
3
votes
0answers
72 views

Cache with timeout per key

I wrote a general purpose library for in-memory cache with custom timeout for each key. ...
1
vote
0answers
53 views

Segment tree with lazy propagation

This is the implementation of segment tree with lazy propagation. Could you please review this code so that I can improve my ...
6
votes
0answers
71 views

Bounding volume hierarchy

I'm building a bounding volume hierarchy in Golang. I can tell my code works because I did some test on it and it gives the same results as the brute force implementation (brute force is to test all ...
3
votes
1answer
47 views

Map strings to (const) ints

I'm imagining go generate would be a good tool for this. I want to convert strings to ints to save space. ...
8
votes
1answer
102 views

cat program in Go

In order to learn Go, I've implemented the cat program in Go. I want to know if the code is idiomatic and what could be improved. ...
5
votes
1answer
141 views

Classifying by age

Problem: Classify the user (such as infant, child, teenager, adult) based on user's age. Solution Please run the solution here. The code snippet written below works well as expected. I want to ...
10
votes
1answer
225 views

A minimal version control system

I just finished writing a simple version control. You register files using "add", and then "com" will save them inside a directory, with an ID attached to it, same ID for all files. With "rev" it will ...
3
votes
1answer
78 views

Bottom up mergesort - singly linked list

I have written the following program in Go to mergesort a singly linked list. It does bottom up merge sort and hence does not have to find the mid of the linked list. Please review the algorithm and ...
4
votes
0answers
244 views

Gin web framework middleware

As a beginner in Go, I'm seeking feedback on a web framework middleware I wrote up. I reckon that knowledge of the web framework is not needed for the code review. The goal of this middleware is ...
2
votes
0answers
33 views

Test web application

I am writing a test web application in Golang. Create post handler: ...
11
votes
1answer
163 views

Concurrency interview

A little while back I had an interview where they posed a problem, in summary: Watch a certain directory, and process incoming JSON files These JSON files have various "Type" fields Every second ...
5
votes
0answers
42 views

Bayesian spam filter interface

In essence, what I'm looking to do is split a string into one-word and two-word segments, and train classifiers against them. First it lowercasifies the string, then strips all non-alphanumeric ...
2
votes
1answer
50 views

Using goroutines to bruteforce a secret code

For a puzzle I had to brute force a password. I've never used goroutines before, and I don't have much experience in concurrency. This is the cksum function, which takes an array of the ASCII code ...
3
votes
0answers
39 views

Project Euler #2 in Go

I just learned Go (yesterday in fact) and today I made this solution to Project Euler #2. The problem is to sum the even Fibonacci numbers. My program uses the matrix representation of the linear ...
3
votes
0answers
66 views

Golang A* Pathfinder

This is a generalized A* pathfinder in Go. I am new to the language and am eager for advice about best practices. In particular, I am not sure if the type assertion I make in ...
4
votes
1answer
114 views

Calculate total width of a range of numbers

I'm mostly curious if there's a faster or more efficient algorithm I could use. I created this for a unique side project, as well as for an issue at work, so what the function does (e.g., return a ...
9
votes
0answers
142 views

Go Fish game written in Go

A couple months back I made a go fish game in Go, just for the sake of that pun. It was pretty poorly done and made experienced Go-ers cry when they looked at it. I rewrote some of it to be more ...
5
votes
2answers
242 views

Equivalent binary trees (A Tour of Go)

Any suggestions on how to improve the code shown below for the Go-tour exercise? Exercise description: There can be many different binary trees with the same sequence of values stored at the ...
0
votes
0answers
131 views

HTTP handlers exercise (tour of go)

The challenge, from Tour of Go, "Exercise: HTTP Handlers": Implement the following types and define ServeHTTP methods on them. Register them to handle specific paths in your web server. ...
2
votes
1answer
38 views

Injecting an object in each function in Go

My current project uses a database represented as object. Furthermore I want to implement methods like CreateUser(), ...
2
votes
0answers
52 views

Restful API for parsing records

I'm trying to implement my own API. This code excerpt should show the basic working routines. The storage is temporary an in-memory-array and the only HTTP method for now is POST. I outsourced the ...
8
votes
2answers
1k views

Checking for any character common to two strings — Go is 50× slower than Python

I decided to learn Go, knowing Python. My approach is by solving easy problems like this one: You are given two strings, A and B. Find if there is a substring that appears in both A and B. ...
12
votes
2answers
141 views

A closer look at the chat's mumblings

The Go Playground was boring so I decided to make a small application that throws me into the language. It basically queries the chatroom every second for new messages and displays them in the output ...
2
votes
1answer
219 views

Natural mergesort

This is a problem from Robert Sedgwick's Algorithms book: Write a version of bottom-up mergesort that takes advantage of order in the array by proceeding as follows each time it needs to find two ...