Is the go map structure thread-safe?
Is the Go map type thread safe? I have a program that has many goroutines reading and writing to a map type. If I need to implement a protection mechanism, what's the best way to do it? ...
Is the Go map type thread safe? I have a program that has many goroutines reading and writing to a map type. If I need to implement a protection mechanism, what's the best way to do it? ...
Basically what the title says: what's the process for compiling your average go* file? drop it on a compiler and execute the result? *note: The OP edited the question replacing "go" with "C", before it was rolled back. So some of the answers won't make sense. ...
I'm looking for something like PHP's print_r or python's dict. Anybody know if this function exists, or its something that needs to be implemented? ...
I was taking a look on Go language, but I want to know if there is any IDE developed only for it, but that have a GUI design feature, as Visual Studio and Netbeans. ...
I was reading about Go, and I can see that it's very good and can be a language used by many developers in some months, but I want to decide a simple thing: Learn Go or improve my Python or Ruby knowledge? Years developing with Python: 1 Years developing with Ruby: 0.3 ...
The Xml example in the go docs is broken. Does anyone know how to make it work? When I compile it, the result is: xmlexample.go:34: cannot use "name" (type string) as type xml.Name in field value xmlexample.go:34: cannot use nil as type string in field value xmlexample.go:34: too few values in struct initializer Here is the relevant c...
Can Go have optional parameters? Or can I just define two functions with the same name and a different number of arguments? ...
In Go, what's the easiest way to get the keys in a map sorted alphabetically? This is the shortest way I can do it: package main import "container/vector" import "fmt" import "sort" func main() { m := map[string]string {"b":"15", "z":"123123", "x":"sdf", "a":"12"} var keys vector.StringVector; for k,_ := range ( m ) { ...
I know I can iterate over a map m by, for k, v := range m { ... } and look for a key but is there a more efficient way of testing a key's existence in a map? Thanks. I couldn't find an answer in the language spec. ...
Hi, I have read this but still not fully aware of the advantage of slice against array.So I am expecting somebody in SO explain better than it and I am sure you can :) ...
I'm having a look at Go, which looks quite promising. I am trying to figure out how to get the size of a go struct, for example something like type Coord3d struct { X, Y, Z int64 } Of course I know that it's 24 bytes, but I'd like to know it programmatically.. Do you have any ideas how to do this ? ...
Would like to be able to take password entry from the stdin console, but, of course, without echoing what the user types. Is there something comparable to getpasswd functionality in Go? (Google's Go language) I tried using syscall.Read, but it echoes what is typed. ...
I want to create an array of exec.Cmd and pipe them together to make an squid authenticator. It works when the commands in file have no arguments. With arguments, it only reads EOF. I've checked the argv array and its content is ok. The relevant portion of the code is: func initCmd(file *os.File) []* exec.Cmd { var cmd [MAX_PR...
I'm trying to encode a large number to a list of bytes(uint8 in Go). The number of bytes is unknown, so I'd like to use vector. But Go doesn't provide vector of byte, what can I do? And is it possible to get a slice of such a byte vector? I intends to implement data compression. Instead of store small and large number with the same numb...
Go doesn't provide assertions. They are undeniably convenient, but our experience has been that programmers use them as a crutch to avoid thinking about proper error handling and reporting. However it has print and println which does panic like print, aborts execution after printing panicln like println, aborts executi...
My source files tree is like this: /src /pkg /foo foo.go foo_test.go Inside foo.go: package foo func bar(n int) { ... } inside foo_test.go: package foo func testBar(t *testing.T) { bar(10) ... } My questions are: Does package name relates to directory name, source file name? If there is only one...
...for use in a multithreaded network server. I want to pass data around between multiple threads. Currently I'm using sockets, with the master thread blocking on select() and workers blocking on recv(), though I feel there probably are more advanced or prepackaged ways of handling this task in C++. ...
Not so long ago Google came out with this new programming language, which was said to be fast as C and intuitive and simple as python. I will not judge this assertions, but instead ask you: What do you think are Go's advantages and disadvantages? Can you tell us about a real use you have given to this programming language? Thanks! Man...
Can i use shared objects with Go (Google) programming language? ...
I feel a little silly as this should be an easy one, however I just started with go and can't figure it out. package main import "fmt" type Question struct { q []string a []string } func (item *Question) Add(q string, a string) { n := len(item.q) item.q[n] := q item.a[n] := a } func main() { var q Question q.Add("A?", "B.") } ...