How to parse *.py file with python?
If my question is duplicated, please let me know another thread, because I can't find it.
Why I like to do is, I like to try Basic Source Code Converter from Python to Go Language.
Which module should I use?
And your Idea on, should I go ahead or better not?
If I should go ahead, please let me know...
In looking at Go and Erlang's approach to concurrency, I noticed that they both rely on message passing.
This approach obviously alleviates the need for complex locks because there is no shared state.
However, consider the case of many clients wanting parallel read-only access to a single large data structure in memory -- like a suffix...
I'm used to Java's String where we can pass null rather than "" for special meanings, such as use a default value.
In Go, string is a primitive type, so I cannot pass nil (null) to a parameter that requires a string.
I could write the function using pointer type, like this:
func f(s *string)
so caller can call that function either a...
I am porting over some Java code into Google's Go language and I converting all code except I am stuck on just one part after an amazingly smooth port. My Go code looks like this and the section I am talking about is commented out:
func main() {
var puzzleHistory * vector.Vector;
puzzleHistory = vector.New(0);
var puzzle Peg...
In the following code, I create one peg puzzle then do a move on it which adds a move to its movesAlreadyDone vector. Then I create another peg puzzle then do a move on it which adds a move to its movesAlreadyDone vector. When I print out the values in that vector for the second one, it has the move in it from the first one along with th...
Let's say you have a company running a lot of C/C++, and you want to start planning migration to new technologies so you don't end up like COBOL companies 15 years ago.
For now, C/C++ runs more than fine and there is plenty dev on the market for it.
But you want to start thinking about it now, because given the huge running code base a...
I have the following code:
// eventloop.go
type Object interface {
ActivateSlot(name string, parameters vector.Vector);
}
// main.go
import loop "./eventloop"
// ...
const slotname = "printer"
type printer struct {
slot loop.Slot;
}
func (p *printer) Init() {
p.slot = loop.Slot{slotname, p}; // offending line
}
func ...
I've been trying to learn Go / Golang on my own, but I've been stumped on trying read and write to ordinary files.
I can get as far as: inFile,_ := os.Open(INFILE,0,0);
but actually getting the content of the file doesn't make sense, since the read function takes a []byte as a parameter??
func (file *File) Read(b []byte) (n int, err E...
How does one implement the Singleton design pattern in the go programming language?
...
Google's new language Go tries to make dependencies management easier by explicitly requiring that all dependencies listed in a module actually be used. The compiler will reject a module that declares a dependency to a module without using anything from that module.
It is illegal for a package to import itself or to import a package ...
Is there a way to get a list of all the keys in a go language map? The number
of elements is given by len(), but if I have a map like:
m := map[string] string = { "key1":"val1", "key2":"val2" };
how do I iterate over all the keys?
...
Is it possible to use an operator in place of a function in go?
For example, in the following code is it possible to replace add with +?
package main
import "fmt"
var cur, prev int = 1, 1
func fib(f func(int, int) int) int {
return f(cur, prev)
}
func main() {
add := func(x int, y int) int { return x + y };
fmt.Println(...
It seems to me Google's alternatives to exceptions are
GO: multi-value return "return val, err;"
GO, C++: nil checks (early return)
GO, C++: "handle the damn error" (my term)
C++: assert(expression)
Is multi-value return useful enough to act as an alternative? Why are "asserts" considered alternatives? Does Google think it O.K. if a...
The Go language creators write:
Go doesn't provide assertions. (...) Programmers use them as a crutch to
avoid thinking about proper error
handling and reporting.
What is your opinion about this?
...
I know that pointers in Go allow mutation of a function's arguments, but wouldn't it have been simpler if they adopted just references (with appropriate const or mutable qualifiers). Now we have pointers and for some built-in types like maps and channels implicit pass by reference.
Am I missing something or are pointers in Go just an un...
Let's say I want to run 'ls' in a go program, and store the results in a string. There seems to be a few commands to fork processes in the exec and os packages, but they require file arguments for stdout, etc. Is there a way to get the output as a string?
...
Is there a way to ensure that a goroutine will run only in a specific OS thread? For example, when GUI operations must run in the GUI thread, but there might be multiple goroutines running GUI code.
GOMAXPROCS(1) does the job technically, but that defeats the purpose of multithreading.
LockOSThread() works too, but that prevents any ot...
I am looking to write a simple client/server utilizing TCP sockets. Any ideas how to do network programming in Go?
...
In Go, a TCP connection (net.Conn) is a io.ReadWriteCloser. I'd like to test my network code by simulating a TCP connection. There are two requirements that I have:
the data to be read is stored in a string
whenever data is written, I'd like it to be stored in some kind of buffer which I can access later
Is there a data structure for...
As many of you might know Google just released it's "Go Language" (http://golang.org) as an experimental language. Does anyone know of any projects that people have been "experimenting" with? Just wondering what people's takes on it so far are. Although this may be too soon to tell.
...