go

Is it possible to include inline assembly in Google Go code?

Is it possible to include inline assembly in Google Go code? ...

Why does Go compile quickly?

I've Googled and poked around the Go website, but I can't seem to find an explanation for Go's extraordinary build times. Are they products of the language features (or lack thereof), a highly optimized compiler, or something else? I'm not trying to promote Go; I'm just curious. ...

Haskell's TypeClasses and Go's Interfaces

What are the similarities and the differences between Haskell's TypeClasses and Go's Interfaces? What are the relative merits / demerits of the two approaches? ...

use of import statement

I've been toying around Go for a couple of weeks now, so far so good. Now I am writing a program splitted across different files like this: . |-- geometry | |-- cone | `-- cone.go |-- main.go |-- Makefile the problem is i can't import cone.go in the main.go, the compiler doesn't find it. Anybody? ...

Default rules in Make

Is there a mechanism in make to allow for default global implicit rules that are available anywhere, similar to the built-in rules? Make provides some built-inimplicit rules for compiling C/C++/Fortran files, without even requiring a Makefile for simple cases. However, when compiling other languages (e.g. Go programming language files)...

How to implement a simple queue properly?

The current Go library doesn't provide the queue container. To implement a simple queue, I use circle array as the underlying data structure. It follows algorithms mentioned in TAOCP: Insert Y into queue X: X[R]<-Y; R<-(R+1)%M; if R=F then OVERFLOW. Delete Y from queue X: if F=R then UNDERFLOW; Y<-X[F]; F<-(F+1) % M. F: Front, R: Rear, ...

Go Channels in Ruby

In the Go programming language, you can send Messages around using a construct called "Channels". http://golang.org/doc/effective_go.html#channels I would love to use something like that in Ruby, especially for IPC. Pseudocode of what I want: channel = Channel.new fork do 3.times{ channel.send("foo ") } exit! end Thread.new do ...

For a struct vertex, what's the difference between map[int]vertex and map[int]*vertex?

To define a map from int to struct vertex, should I define map[int]vertex or map[int]*vertex? Which one is preferred? I extended Chickencha's code: package main type vertex struct { x, y int } func main() { a := make(map[int]vertex) b := make(map[int]*vertex) v := &vertex{0, 0} a[0] = *v b[0] = v v.x, ...

How do I encrypt with an RSA private key read from a PEM file using the Go programming language?

How do I do the equivalent of the following C++ code in go? RSA *key = PEM_read_RSAPrivateKey(f, NULL, NULL, NULL); std::vector<CK_BYTE> out(128); RSA_private_encrypt(in.size(), &in[0], &out[0], key, RSA_PKCS1_PADDING) I've looked at the Go rsa package. It looks like EncryptPKCS1v15() may be the equivalent of RSA_private_encrypt(). ...

What is a "value" array?

In C, the idea of an array is very straightforward—simply a pointer to the first element in a row of elements in memory, which can be accessed via pointer arithmetic/ the standard array[i] syntax. However, in languages like Google Go, "arrays are values", not pointers. What does that mean? How is it implemented? ...

How exactly do interfaces work in Go?

After reading the spec, and the "Effective Go" section on them, I still don't quite understand how interfaces work in Go. Like, where do you define them? How does interface enforcement work? And is there a way to specify somewhere that an object implements an interface, as opposed to simply defining the methods in the interface? Apolog...

Where is the io library defined in Go?

Specifically, where are io.reader and io.writer interfaces defined? ...

When should `new` be used in Go?

It seems pointless to be used in primitive language constructs, as you can't specify any sort of values func main() { y := new([]float) fmt.Printf("Len = %d", len(*y) ) // => Len = 0 } For stucts it makes a bit more sense, but what's the difference between saying y := new(my_stuct) and the seemingly more concise y := &my_struc...

Unnamed arrays in structs in Go

So I can have struct { int x []int } However, struct { int []int } will result in a syntax error: unexpected [, expecting }. Is there a way of having unnamed arrays in structs in Go? If so, what's the correct syntax? ...

More idiomatic way of adding channel result to queue on completion

So, right now, I just pass a pointer to a Queue object (implementation doesn't really matter) and call queue.add(result) at the end of goroutines that should add things to the queue. I need that same sort of functionality—and of course doing a loop checking completion with the comma ok syntax is unacceptable in terms of performance vers...

Go-Scala-Go! What are the main differences?

I just found this web page comparing some code written in Scala, C# and Go. I am astonished to see how close Scala and Go code looks like, much more than Scala code compared to C# code. So my question is: What are the most significant differences between Scala and Go? ...

Problem using json in Golang (Go)

I am using json to store data on disk between program calls, the program runs fine for some time, but after that it displays error in json decoding, "invalid character '1' after top-level value ". Can anyone suggest some solution to this problem ? ...

iteration + casting in go

i have this snippet of code that use an iterator on a list for x:= range s.faces.Iter(){ x.Render() } as the compiler points, x is of type interface{} and there isn't a method (i interface)Render() defined in my code. changing to for x:= range s.faces.Iter(){ x.(faceTri).Render() } compile, because there is a method func ...

Compiling .go ( google go language ) in Windows ... & Can python connect to Go?

Hi all, i know that go language does not support windows yet, now, how can i compile .go file is windows ? and can python connect to go ? like connecting c++ or java to python ... lol ...

What language is the Go programming language written in?

I think the title is self explanatory. ...