Questions tagged [go]
Go, also called golang, is an open source programming language initially developed at Google. It is a statically-typed language with syntax loosely derived from that of C, adding automatic memory management, type safety, some dynamic-typing capabilities, additional built-in types such as variable-length arrays and key-value maps, and a large standard library.
175 questions
91
votes
1
answer
25k
views
How are Rust Traits different from Go Interfaces?
I am relatively familiar with Go, having written a number of small programs in it. Rust, of course, I am less familiar with but keeping an eye on.
Having recently read http://yager.io/programming/go....
77
votes
3
answers
70k
views
Sets Data Structure in Golang
I really like google golang but could some one explain what the rationale is for the implementors having left out a basic data structure such as sets from the standard library?
63
votes
10
answers
26k
views
Does it ever make sense to use more concurrent processes than processor cores?
I've got some process in Go. Here's an example counting lines in text, though the question is meant to be far more general than this particular example:
func lineCount(s string) int {
count := 0
...
58
votes
12
answers
7k
views
What are the chances of Google's Go becoming a mainstream language? [closed]
Who here is learning Go? Are other companies looking at using it? Is it likely to become widely used?
36
votes
8
answers
7k
views
When would you need "hundreds of thousands" of threads?
Erlang, Go, and Rust all claim in one way or another that they support concurrent programming with cheap "threads"/coroutines. The Go FAQ states:
It is practical to create hundreds of thousands of ...
35
votes
4
answers
6k
views
How much is Google investing in the Go language? [closed]
I have read quite a bit about the Go language, and it seems promising. The last important bit of information I am missing before I decide on spending more effort on the language is: How much money/man ...
22
votes
5
answers
11k
views
Is a common library a good idea?
I've always thought that a "common library" was a good idea. By that I mean a library that contains the common functionality that is often needed by a few different applications. It results in less ...
19
votes
1
answer
6k
views
Erlang and Go concurrent programming, objective differences between CSP and Actors?
I was looking into concurrent programming in Erlang and Go programming languages. As per my finding they are used Actor model and CSP respectively.
But still I am confused with what are the objective ...
18
votes
3
answers
2k
views
Advantages of a left to right language syntax
I've been watching an interview with Herb Sutter on Channel9 and he mentioned at the end of the video that left to right language syntax would be on the top on his whishlist for a future C++ standard(...
16
votes
1
answer
9k
views
Why did Golang discontinue the "netchan" package?
The Golang "netchan" package seems to have been discontinued.
That makes me think that the concept of "networked channels" were not a good practice after all. (Why wouldn't them just "let it be" ...
14
votes
5
answers
4k
views
Benefits of classic OOP over Go-like language
I've been thinking a lot about language design and what elements would be necessary for an "ideal" programming language, and studying Google's Go has led me to question a lot of otherwise common ...
11
votes
3
answers
2k
views
What is the difference between Haskell's type classes and Go's interfaces?
I am wondering if there is a difference between Haskell's type classes and Go's interfaces. Both define types based on functions, in that way, that a value matches a type, if a function required by ...
10
votes
2
answers
4k
views
Type inference in Golang/Haskell
I've read that Go doesn't actually have true type inference in the sense that functional languages such as ML or Haskell have, but I haven't been able to find a simple to understand comparison of the ...
9
votes
3
answers
617
views
Why does Go have a special case for abs(0)
I was playing around with Go, and found this particular interesting code for the abs function in the math package:
http://golang.org/src/pkg/math/abs.go
14 func abs(x float64) float64 {
15 ...
9
votes
1
answer
7k
views
How to structure a Go application, architected according to the clean architecture
I'm trying to build a project using the clean architecture, as described here. I found a great article on how to do this in Go.
The example is a very simple one, and the author puts their code into ...
6
votes
2
answers
16k
views
Does Go implicitly discourage getters and setters and encourage direct member access?
As the title says, is accessing public struct fields more idiomatic in Go than getters and setters? Wouldn't that lead to violation of data encapsulation, also public fields in other OO languages like ...
6
votes
2
answers
317
views
Language that can statically ensure a map's fields are present
If data is simple and objects are complex, I'm curious if there are any existing statically typed languages that would be able to augment(?) a map type into a type with guaranteed fields. I realize ...
6
votes
1
answer
796
views
Optimizing hash lookup & memory performance in Go
As an exercise, I'm implementing HashLife in Go.
In brief, HashLife works by memoizing nodes in a quadtree so that once a given node's value in the future has been calculated, it can just be looked ...
5
votes
2
answers
3k
views
What degree of low-level programming can be achieved with Languages like Go?
Go and D provide garbage collection, and yet they claim to be system programming languages. What degree of low-level programming can be achieved with languages having garbage collection?
For low-...
5
votes
2
answers
3k
views
GO - Goroutine and Concurrency
Background:
pthreads follow pre-emptive scheduling, whereas C++ fibers follow cooperative scheduling.
With Pthreads: the current execution path may be interrupted or preempted at any time This ...
5
votes
1
answer
2k
views
What is the motivation for Go lang syntax? [closed]
Since the Go lang is getting popular, I started to play with it. I do derive from Java language so when I saw the Go syntax it has been a bit strange to me.
sample code from go lang project site:
...
5
votes
1
answer
315
views
Idiomatic way of writing a GUI system in Go?
I'm writing a little GUI system for my game in Go. So far my structure is kind of like this:
type Component interface {
Update()
Render(ctx)
Translate()
GetComponent() []Component
...
4
votes
5
answers
2k
views
(How) can the circle-ellipse problem be solved by using composition rather than inheritance?
I was reading about composition over inheritance and came across a question about solving the Circle-Ellipse Problem in Object-Oriented Programming. This kind of problem is often used as an example of ...
4
votes
2
answers
363
views
How to structure many complex conditionals on a class
I have a class (as a protobuf) OrderChange, that represents when an order (imagine Amazon.com) changes:
message OrderChange {
Order old_order = 1;
Order new_order = 2;
}
message Order {
...
4
votes
2
answers
3k
views
Why does gofmt discourage blank lines at the end of files?
Since I started programming, I've always been taught to leave a trailing blank line at the end of my files, the reason usually being something relating to how it makes concatenated files easier to ...