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)

4
votes
1answer
46 views

Alternate letters to UpperCase

As an exercise I repeated this Java question, but in Go: Convert string to mixed case The objective is for every second letter to be converted to uppercase. Go string processing is relatively new to ...
2
votes
0answers
26 views

Concurrent resizable ring buffer Golang

I'm trying to find the fastest way to enqueue and dequeue items concurrently in Go. There are some restrictions: it needs to be unbounded memory allocation should be low. multiple producers ...
2
votes
1answer
22 views

Uploading large videos using go

I am using the following function to upload videos (around 1 gb). It works properly. My requirements are (these checks are being done in a different function using the mediainfo library): check if ...
0
votes
0answers
7 views

Detect cause of failing rename [migrated]

I use some code similar to the lines below. The rename can fail if the directory is blocked because some application has a file open in it. ...
1
vote
1answer
43 views

Golang: reading and processing a big csv file

I am quite new to Golang. I am trying to write a script to read a CSV file containing 1 million domain names, lookup these domain names and store the results in another CSV file. I am trying the ...
4
votes
1answer
24 views

recursive descent parser

Here is a non-predictive recursive descent parser I wrote for the following grammar: ...
3
votes
0answers
38 views

Golang Tour Web Crawler Exercise

In the last few days I've played around with Go a little and took the language tour. The last exercise (text here) requires you to crawl a graph that simulates a set of Web pages with links, using ...
4
votes
1answer
94 views

Encrypting strings in Golang

This is a an example application for testing some encryption and decryption functions in Golang. The functions encryptString(), ...
-2
votes
0answers
23 views

Logging an HTTP request and response in a Go web server

I have written a code which is basically a web server, handling request ...
1
vote
0answers
21 views

Idiomatic abstract inheritance with Go

I am currently discovering Golang, and I try to implement some random variable generation functions similar to R functions. To avoid code repetition, I'd like to use inheritance, which is quite ...
4
votes
2answers
64 views

Go lang Tour Webcrawler Exercise - Solution

I am new in Go and for study I have to hold a presentation about concurrency in Go. I think the Go lang Tour - Webcrawler exercise is a nice example to talk about that. Before I will do that, it would ...
5
votes
1answer
75 views

Summing chemical properties in a CSV stream

I have written my first program in go. It's rewritten from python. Program takes csv file, emulates query ...
4
votes
0answers
45 views

ICMP ping program in Go

I've just written a ping application in Go. I'm proud of the logic, but I want some help to refactor it. The program has too much code in main, and pulling ...
4
votes
2answers
67 views

Port pinger command line tool

Checking if some port is up on the network is a very common task when working with remote services. A common way to check is using telnet, but I have two practical ...
3
votes
1answer
49 views

A scalable lock-free channel

Here's my lock-free channel impl lfchan, I didn't want to copy/paste the code here since it is multiple files. I'm trying to get an idea of what can be improved or if there are any bugs in it. ...
1
vote
1answer
63 views

Library to handle strings and numbers

I have created a pretty bad (just being honest) Golang library. I will take any and all advice, as long as it's helpful. Sorry it's so long. Also, I easily forget some things, so many functions in ...
3
votes
1answer
47 views

Golang Flood Fill

I started learning Go a few months ago and am trying to shake the rust off after a project took me out of the Go world for several weeks. I'd appreciate a code review on this flood fill algorithm I ...
3
votes
2answers
63 views

Decimal-to-fraction solver

I have created a program that turns a decimal into a fraction: ...
3
votes
2answers
77 views

Parse Numerals from a String in Golang

I recently tried my hand at writing Go code for a project I'm working on. In order to help myself get a better grasp I decided to write a simple yet somewhat practical program for parsing numeral ...
5
votes
3answers
155 views

Selection sort algorithm

I am just trying to use Go so I will be thankful for all remarks and corrections: ...
2
votes
1answer
48 views

Regular expression matching with string slice in Go

I have a slice of strings, and within each string contains multiple key=value formatted messages. I want to pull all the keys out of the strings so I can collect ...
2
votes
1answer
57 views

MongoDB CRUD operations for various types of data in Go

First of all I am a newbie in Go. I wrote a CRUD REST API that consists of handlers, a database layer and so on, and it contains a lot of code duplication. I see some patterns here, and I know how to ...
5
votes
1answer
78 views

Circuit Simulator

I'm trying to learn Golang from Java, and to do this, I wrote a basic circuit simulator with only two circuits. Is there anything I can do better to make it more idiomatic? Simulator.go ...
1
vote
0answers
50 views

XOR 256 Block Encrypting and Decrypting

I am quite new to Go but have found it to be very useful for my use case (game server). I have a routine that encrypts/decrypts the game packets which was written in C++ which can be seen here and ...
4
votes
3answers
84 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
87 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. ...
-1
votes
1answer
35 views

Listings Manager

I am trying to learn to code using Dependency Injection and Inversion of Control in Go. Please consider the following code. I am basically creating an interface ...
6
votes
3answers
104 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 ...
1
vote
1answer
99 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
109 views

Golang implementation of Pascal's triangle

How can I improve my code and make it more idiomatic? ...
6
votes
1answer
66 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
99 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
125 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
81 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
228 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
37 views
3
votes
0answers
45 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
109 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
81 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
71 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
48 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
65 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
59 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
82 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
161 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
137 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
35 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
49 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 ...
4
votes
0answers
37 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 ...