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

learn more… | top users | synonyms

2
votes
0answers
19 views

Parsing CSVs for bulk database insertions

I'm writing this as (eventually) part of a larger program. This will serve as the bulk data insertion from .csv files we parse. I'm primarily looking for parts that are breaking Go's formatting, ...
7
votes
0answers
33 views

Go Go Gadget Web Crawler

In A Tour of Go, you are given the following problem: In this exercise you'll use Go's concurrency features to parallelize a web crawler. Modify the ...
2
votes
0answers
40 views

Is this web service synchronized correctly?

I'm new to both concurrency programming and Go. I've written a small server side script that gets the title and ratings of a book for a given ISBN. I've to optimise performance by using a cache and ...
4
votes
1answer
75 views

Unmarshaling dynamic JSON

I have JSON object response returned from the server which is similar to this one: ...
3
votes
1answer
40 views

Command line flags & sorting algorithms

I've made my first-ever program in Go, which sorts a given input of integers. There are 2 options: The list of unsorted integers and the algorithm to use. Since it's my first go project I'm a bit ...
4
votes
1answer
76 views

Merge sort in Golang

I am just starting out with golang. I implemented the merge sort algorithm just to practice. Any suggestions or criticisms regarding the coding style? ...
7
votes
2answers
157 views

Subnetting calculator in Go

Whenever I try to learn a new language, I write a subnetting calculator. Here's my attempt with Go. In particular, I think I'm not writing idiomatic Go, as well as abusing ...
1
vote
0answers
28 views

Daisychain channels

I watch the presentation about concurrent programming presented by Rob Pike and I saw the daisychain example. I tried to rewrite this code to make it more readable. Everything went well, but I am ...
7
votes
1answer
89 views

Golang HTTP status checker

I'm writing my first somewhat production ready (or not) Go program and could do with some feedback from someone more experienced with go. The code reads a list of URLs from a JSON file and then makes ...
4
votes
1answer
150 views

Graph (adjacency list) for BFS and DFS in Golang

I am trying to implement a Graph data structure in Golang and choose to use adjacency list representation. When starting to implement adjacency list, I have an idea ...
4
votes
1answer
81 views

Channels vs. “for loop” prime number generator

I've found a question on SO (here), which is a prime number generator that uses channels. First of all, I had some trouble to find out how this code works, but later on, I saw the fun of it. Then, all ...
4
votes
0answers
42 views

Reading OS X file tags

I'm investigating Go for use in our internal network / office project management system, and need a way to check and edit the color tags that you can set in Finder on files or folders (extended ...
4
votes
0answers
57 views

Equivalent binary trees (structure & values)

I am following the Golang tour and I have been asked to build a couple of functions to manipulate binary trees. My code runs as expected, but I would like to know if I could further improve my code. ...
3
votes
2answers
57 views

Go string formatting

I'm very new to Go, and am trying to get some experience by re-writing some of my Python code in Go. Below is a function that takes an IP address (ipv4) in integer form and returns the string ...
5
votes
1answer
78 views

Is my spin-lock implementation correct?

I'm working on a project where a spinlock is more appropriate than a mutex, and after few tries I came up with: ...
3
votes
2answers
85 views

in_array() in Go

This function's objective is very simple. It takes array and checks if val is a value inside of this array. It returns whether ...
2
votes
1answer
59 views

Deferred log file close

My code works in that it compiles, and when executed writes out a log file using a buffered writer. But I wonder whether: I am correct in assuming that this actually winds up deferring a ...
1
vote
1answer
54 views

Securely shuffling an array with 75 numbers in Go

I have a SHA512 hex string consisting of my random input and that of the user. Since rand.Seed only accepts a int64 I can never ...
6
votes
2answers
96 views

Is this a good way of managing parallel go routines when I care about ordering of results?

I have a process with a number of stages that need to be completed in sequence. Each stage is largely parallelisable, involving looping over a large data structure and processing each item ...
3
votes
1answer
38 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 ...
3
votes
2answers
124 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
78 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
86 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
50 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
61 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
52 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
102 views

Four algorithms to find the Nth Fibonacci number

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
129 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
109 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
56 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
76 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
73 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
93 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
212 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
115 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
164 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
150 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? ...
10
votes
3answers
911 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
362 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
176 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 ...
2
votes
1answer
1k 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
318 views

Split and word count in go

Could it be written better? ...
0
votes
1answer
225 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 ...
4
votes
1answer
88 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
57 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
68 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
564 views

String converting and parsing a few rows of a .csv file

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
116 views

Project Euler 10: Summation of primes in Go

Here is my first try at Google's Go language, trying to solve Project Euler Problem 10: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. ...
2
votes
2answers
173 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
869 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 ...