Hot answers tagged

15 votes
Accepted

Bruteforce MD5 Password cracker

First let's mention a bug / issue: Your passwords variable is accessed (read and modified) from multiple goroutines without any syncronization: this is a race ...
icza's user avatar
  • 956
12 votes

Are there ways to speed up this string fuzzy matching in Golang?

Review I - package go-fuzzywuzzy After a quick read of your Go code, the Go code for package go-fuzzywuzzy, and the Go ...
peterSO's user avatar
  • 3,466
11 votes
Accepted

Go function to test whether a file exists

Instead of checking with an if statement if errStat is null and then returning false: ...
Eliahu Aaron's user avatar
10 votes

Executing periodic tasks

A vs. B type questions are seldom good questions for a code review. Often the answer is "C". That's true this time too. You don't need a go routine for the "ticker". Your second implementation only ...
rolfl's user avatar
  • 97.3k
10 votes
Accepted

golang rabbitmq message consumer

There's not really a one "right" way of doing things, and all of the others are wrong. However, there's a number of things that are considered good practice, and WRT to those, your code can do with a ...
Elias Van Ootegem's user avatar
9 votes
Accepted

A* Go application

Bug Your code clearly states: Src: 0, 0 Dst: 0, 5 Excpeted answer: {(0,0), (1,1), (2,2), (2,3), (2,4), (1,5), (0,5)} But, when I run your code, I get: ...
rolfl's user avatar
  • 97.3k
9 votes
Accepted

Encrypting strings in Golang

Nice question. Consistent error handling. Regardless of the language, the key to a good program is consistency. Your code combines a combination of panic and <...
rolfl's user avatar
  • 97.3k
9 votes

Translate nucleic acid sequence into its corresponding amino acid sequence

This covers an interesting topic. Great work! Because I am unfamiliar with this area, I utilized your unit testing to ensure changes I make did not break functionality. If they do, I apologize and ...
esote's user avatar
  • 3,770
8 votes
Accepted

Simple BubbleSort in GoLang

let me know what I can improve in this code. For a real-world code review, code should be correct, maintainable, reasonably efficient, and, most importantly, readable. Writing code is a process of ...
peterSO's user avatar
  • 3,466
7 votes

Golang concurrent HTTP request

Inside SendRequst you are calling SendRequest again, which will make your stack full of recursive calls.
Ahmed Kamal's user avatar
7 votes
Accepted

Circuit Simulator

Your code is neat, and structured just like I would expect to see Java ;-) - separate files for each "class". In your case, though, the separation in to files is probably over the top, and if you are ...
rolfl's user avatar
  • 97.3k
7 votes

Selection sort algorithm

On Stack Overflow duplicate questions are closed. For your question, a search of Code Review Stack Exchange for "[go] selection sort" finds, amongst others, Selection sort algorithm with increasing/...
peterSO's user avatar
  • 3,466
7 votes

Golang Tour Webcrawler exercise

Combine the mutex with the thing it is locking into a single struct. Often mutex elements of a struct are unnamed, since you only need to lock and unlock the whole thing ...
matt.s's user avatar
  • 171
7 votes

Create a new unique file

Your code has a few items in it which concern me in a few small ways, and, in general, while I think your code is OK functionally, it could be done better (I am biased, I have done similar things, and ...
rolfl's user avatar
  • 97.3k
7 votes

Go function to test whether a file exists

Elegance is the wrong criterion. The key criterion is correctness, which implies readability and maintainability. As you read text, you notice misspelled words. Does that mean that you laboriously ...
peterSO's user avatar
  • 3,466
6 votes
Accepted

Selection sort algorithm with increasing/decreasing sort options

There are a few things I would point out as being poor go style. The two different nesting loops is where I would start: ...
rolfl's user avatar
  • 97.3k
6 votes
Accepted

Regular expression matching with string slice in Go

You're not making good use of regular expressions. A single regex can do the job: pattern := regexp.MustCompile(`([a-zA-Z]+)=`) The parentheses ...
janos's user avatar
  • 111k
6 votes
Accepted

Summing chemical properties in a CSV stream

Structure Functions..... you need more of them. Your large, monolithic main method makes your code hard to follow, and separating out functions would help a lot. Oh, and errors ... you need to handle ...
rolfl's user avatar
  • 97.3k
6 votes
Accepted

Reading and processing a big CSV file

Bugs Your code does have a problem with the concurrency, and it's a big one.... your buffered channels are not going to be able to complete the system. The issue is the unbuffered ...
rolfl's user avatar
  • 97.3k
6 votes
Accepted

Print all lines of a text file containing the same duplicated word

You have a bug I don't think your program works as intended. If a line exists \$N > 1\$ times, it will be printed \$N (N - 1)\$ times. Because: The first time it's seen, it will be added to ...
janos's user avatar
  • 111k
6 votes

Golang crypto library: security

The code in the question shows a CBC wrapper class. However, that wrapper class uses HMAC for authentication, without this being apparent in the name of the class. Having authenticated ciphertext is ...
Maarten Bodewes's user avatar
6 votes

Send multiple broadcast to multiple listeners

Concept The basic concept of having a channel that you hand out to all receivers, and then close that channel as a signal, is a good one. The way you use that concept in your example usage, is a bit ...
rolfl's user avatar
  • 97.3k
6 votes
Accepted

Go program to find duplicated files in a directory (recursively)

1. declare all 'var' at once instead of var dir string var workers int you can do var ( dir string workers int ) ...
felix's user avatar
  • 588
6 votes
Accepted

Return Unique items in a Go slice

This is not idiomatic writing style in Go, because the value variable is misleading: if _, value := keys[entry]; !value { The ...
janos's user avatar
  • 111k
6 votes
Accepted

Game of life in Go

I really liked the way you used Termbox; you should try Tcell as well for fun. Review The function ...
STEEL's user avatar
  • 228
6 votes

Go grep command clone

The thing is, even so, standard grep still gets results faster by an amount of 60 % less processing time For more information on what makes GNU grep fast, read this by the original author. Here is ...
esote's user avatar
  • 3,770
6 votes

Golang execute several go routine in loop and then wait

Every time you execute a go statement it is passed to the scheduler. What if scheduling is delayed? wg.Add(1) is not executed ...
peterSO's user avatar
  • 3,466
6 votes

Go implementation of dining philosophers

All in all, it's not a bad implementation at all. The bulk of my comments will focus on idiomatic golang stuff, and some small tweaks you can make to the main ...
Elias Van Ootegem's user avatar
6 votes
Accepted

Matrix Transpose in Golang

In Go, measure performance. Run benchmarks using the Go testing package. For example, ...
peterSO's user avatar
  • 3,466
5 votes
Accepted

Go Fish game written in Go

The following comments come from reading the code for the first time, straight from top to bottom. Directly after the definition for the GoFishGame type there ...
Roland Illig's user avatar
  • 21.3k

Only top scored, non community-wiki answers of a minimum length are eligible