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

learn more… | top users | synonyms

0
votes
0answers
95 views
+50

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 ...
1
vote
1answer
17 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
45 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. func padWithRandomBytes(b []byte) ...
1
vote
0answers
31 views

Go: 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
86 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
64 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
60 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: package main import ( ...
2
votes
1answer
197 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 ...
3
votes
1answer
256 views

Golang solution to Project Euler problem #81

Below is a Go solution to the problem 81 in project euler using uniform cost search to build a search tree. It works on the toy small problem but on the 80x80 matrix it runs out of space. Could anyone ...
4
votes
1answer
185 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. package main import ( "fmt" ) const ascii = ...
1
vote
1answer
78 views

Kindly review my Go logging package

Feel free to go get the package at: bitbucket.org/agallego/log or browse the code online. Thanks for the code review.
5
votes
0answers
75 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
188 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? package main func read_int32(data ...
8
votes
1answer
100 views

Creating random maze in Go

/* Create a random maze */ package main import ( "fmt" "math/rand" "time" ) const ( mazewidth = 15 mazeheight = 15 ) type room struct { x, y int } func (r room) ...
4
votes
2answers
163 views

Rot13 Reader in go

For this exercise I have done this; func between(start, end, value byte) bool{ if value > end { return false } else if value < start { return false } return true ...
1
vote
1answer
81 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
248 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
193 views

Improve performance of function

I've got a simple programm 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 ...
1
vote
2answers
227 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 ...