Go is a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.

learn more… | top users | synonyms

3
votes
1answer
31 views

File-based Equation Evaluation in Go

My program 'Monkey', written in Go, can take a file like this: + 9 13 / 10 2 And prints the output (in the case for the 'file' above, '22' and '5'.) Variables ...
2
votes
0answers
38 views

Implementation of merge sort and bubble sort

I'm new to Go and looking for a review of my merge sort and bubble sort implementations. What can be done better? Can my code be cleaner/clearer? ...
2
votes
2answers
58 views

Two-dimensional array allocation in Go

I am creating a two-dimensional array, which I am going to process later in ways similar to image MinFilter, procedural labyrinth generation, etc. -- implying using coordinates and neighbors. Here ...
3
votes
0answers
57 views

Concurrent download in Go

I wrote a program for downloading files in concurrent / parallel (GOMAXPROCS > 1) manner. This is my 2nd (non-toy) program written in Go. Please point out areas for improvement: ...
3
votes
0answers
36 views

Most intuitive way to register “commands” in an extensible IRC bot in Go

I'm writing an IRC bot as a toy project, and one of the goals is to be easy and straight-forward to implement and register new commands. As I'm new to Go, I don't know which would be the "Go way" for ...
4
votes
1answer
55 views

Number formatting

As part of a simple (naive) internationalization attempt in Go, I am trying to come up with a number formatting routine with customizable decimal and thousands separator. Is this approach alright? ...
3
votes
0answers
37 views

Does this go raytracing program follow best practices, and typical project layout?

I'm working through learning Go, so as an exercise, I'm writing a simple raytracer. I'd like general feedback on the code style & architecture. Specific areas of concern: Is the project layout ...
5
votes
1answer
65 views

Four algorithms to find the Nth fibonacci number: looking for both general and idiom feedback

I'm implementing some basic algorithms in Go as an introductory exercise. Here are four different algorithms to find the Nth fibonacci number. I'm looking for general feedback, but I'm specially ...
3
votes
0answers
62 views

Parsing an infix notation expression and converting to reverse polish notation

I'm pretty new to Go, and I do not know the best or idiomatic ways to do most of the stuff, so I'd appreciate feedback on how to make my code better, faster or more idiomatic. My program is a set of ...
4
votes
3answers
93 views

Wrote a package in Go. What did I do wrong? What did I do right?

I wrote a Player package in Go. It builds correctly, but I would love a review on what I did and did not do "the Go way". I'm new to coding in the language, although I've gotten about halfway through ...
2
votes
1answer
44 views

Make logparser faster

I'm learning go. I wrote a simple logparser for SLF4J in Python some time ago and tried to port it to go as an exercise. The algorithm is identical, but the go-solution isn't quite as fast (the Python ...
0
votes
0answers
51 views

Iterative DFS algorithm

I've written an iterative version for DFS. For a quick overview of the benchmark results for a complete graph: So it looks like it behaves within the boundaries of the theoretical complexity. ...
3
votes
0answers
54 views

Queue with “unlimited” buffer in Go

This is small piece of bigger puzzle, but usable by its own. It an attempt to have a nonblocking queue with "unlimited" (besides memory size) buffer length. Got unit-tests 100% statement coverage, it ...
1
vote
1answer
78 views

Shuffling an array of cards

I have a deck of flashcards that I want to shuffle. Here's the method I'm using to shuffle them: ...
3
votes
2answers
184 views

Am I writing good Go here? Python functions converted to Go

I originally asked this question on StackOverflow. Reproduced here by recommendation. I've got a number of Python scripts that I'm considering converting to Go. I'm seeking confirmation that I'm ...
1
vote
1answer
82 views

Approximating square root (loops and functions exercise)

Just looking for some feedback on my solution for Tour of Go Exercise 24 - Loops and Functions. Is there anything that looks like a wrong way to do things in go? anything I could have done better? ...
3
votes
1answer
119 views

Web Crawler (A Tour of Go #71)

So I was trying to do this exercise from Tour of Go. I managed to get it working. I am not at all sure that it is correctly concurrent or idiomatic (I started learning Go, like, 4 hours ago). I would ...
1
vote
2answers
118 views

A Tour of Go, problem #56 - error handling

New to Go, trying to solve Tour of Go, Exercise 56, which is about error handling. Can the following error handling method can be further improved? ...
8
votes
3answers
646 views

golang channel in C#

I have tried to mimic golang channels in C#; and it's performance is pretty good compared to golang itself. On may machine, each channel operation of golang takes ~75 nano-sec and each ...
2
votes
1answer
235 views

RC4 implementation in Go

I'm new to Go, and as a learning project I've been implementing RC4, attempting to follow pseudo-code in the Wikipedia links (and trying not to look at the far-superior version in the crypto package). ...
3
votes
3answers
120 views

Is this idiomatic Go code?

Would the following be considered idiomatic Go code? My main concerns are: The use of maps for this purpose. I basically want the data structure to be completely dynamic in size and have easy ...
1
vote
1answer
672 views

Fibonacci generator with golang

This is my fibonacci generator: package main import "fmt" func main() { for i, j := 0, 1; j < 100; i, j = i+j,i { fmt.Println(i) } } It's ...
1
vote
2answers
191 views

Split and word count in go

Could it be written better? ...
0
votes
1answer
195 views

Using Barrier to Implement Go's Wait Group

I have implemented a WaitGroup class to simulate WaitGroup in Go lang. Then I've found that I can use Barrier in a different manner, to achieve the same thing. My WaitGroup has some additional ...
3
votes
1answer
81 views

Sleepsort in Go

I implemented sleepsort in Go. I am new to channels, and I'd like to get some advice on them, especially on how to close channels after N messages have been sent on them. Currently I use a counter and ...
1
vote
1answer
55 views

Pad a function with random bytes

I'm writing a function to append 5-10 bytes (count is random) at the beginning of a byte array, and 5-10 random bytes at the end. Here's the code I have so far. ...
2
votes
0answers
67 views

Stream-chaining

My goal is to have a reusable pattern for doing concurrent stream-processing in Go. The stream has to be closable from any node. Errors should cleanly close the stream and forward the error to the ...
2
votes
2answers
477 views

refactoring golang code

There are not many available resources for refactoring go code. I'm a novice gopher who would appreciate any feedback on a small program which reads a csv file, string converts and parses a few rows ...
0
votes
1answer
100 views

Project Euler 10: Summation of primes in Go

Here is my first try at googles Go language, trying to solve Eulers Problem 10: http://projecteuler.net/problem=10 Any suggestions on the style and usage (best practice) of Go? One more thing, ...
2
votes
2answers
143 views

exercise #40 in A Tour of Go

My quick searching did not reveal anyone sharing their solution to this exercise, so am not sure if there are other (and better) approaches to mine: ...
2
votes
1answer
717 views

Am I using Golang concurrency correctly to increase reliability?

This code takes text from the standard input, maps it to a struct (if possible), and creates a JSON string from that. I'm using a barcode scanner for the input, and I've attempted to use goroutines ...
5
votes
2answers
572 views

Golang solution to Project Euler #81 (min path through a matrix)

Project Euler problem 81 asks: In the 5 by 5 matrix below, ...
4
votes
1answer
288 views

My first Go program: Caesar Cipher

I'm learning Go at this moment and it is my first program in Go, so I will be thankfull for any suggestion, remarks and observations. ...
0
votes
1answer
110 views

Kindly review my Go logging package [closed]

Feel free to go get the package at: bitbucket.org/agallego/log or browse the code online. Thanks for the code review.
6
votes
0answers
157 views

Concurrency limit map in Go

Please someone who knows locks, mutexes, and Go, review the following code. Task: per host concurrency limits for web crawler (map[string]Semaphore). I considered chan struct{} (chan bool) approach, ...
1
vote
1answer
1k views

Effectively convert little endian byte slice to int32

I have a data stream of bytes and I'd like to get a little endian encoded int32 from four bytes. Is there a better way than to do this like the following code? ...
8
votes
1answer
116 views

Creating random maze in Go

...
6
votes
2answers
699 views

Rot13 Reader in go

For this exercise I have done this; ...
1
vote
1answer
103 views

Comparing two images

I have some code in Go that is attempting to compare two images and determine how different they are. The method is fairly crude, but it is fast enough. Basically it just compares both images pixel by ...
2
votes
2answers
291 views

code review for count then sort problems (go lang)

the question is simple, for a input [apple, banana, orange, apple, banana, apple], the program will count it as a map: {apple : 3, orange: 1, banana: 2}, then sort this map by it's values, get ...
5
votes
1answer
238 views

Solving the travelling salesman problem using a genetic algorithm

I've got a simple program written in Golang that takes a map as input and tries to solve the travelling salesman problem by using a genetic algorithm. My Crossover method is a real performance killer ...
2
votes
2answers
307 views

Is there a better solution to this Fibonacci implementation in Go?

At the end of the Day 1 Go Course slides (pdf) there is an exercise stated as follows (NOTE: the course in the linked presentation is considered obsolete. If you are looking to learn Go the suggested ...