I'd like to start porting a few of my little scripts to Go (that do pretty poor messy parallelism in Python), and I was wondering what a good resource/book type thing would be for people learning Go. Like, the equivalent of learn you some haskell or whatnot. Also some advice on "wtf library do I use for this".
Is there some sort of Go package manager? How does all this shit work?
Yes, the Go tool comes with package-management capabilities. "go get labix.org/v2/mgo" will download the very excellent MongoDB driver mgo, for example.
But then actually implementing something useful is cryptic and obscure. I tried figuring out how to connect to a postgresql server following the spaghetti documentation of https://github.com/bmizerany/pq and http://golang.org/pkg/database/sql/ and have yet to find anything useful. Hacking around only leaves me with frustration. Searching around only leads me to unhelpful descriptions of what the GO command does in MSSQL Server.
func TestExec(t *testing.T) {
db := openTestConn(t)
defer db.Close()
_, err := db.Exec("CREATE TEMP TABLE temp (a int)")
if err != nil {
t.Fatal(err)
}
r, err := db.Exec("INSERT INTO temp VALUES (1)")
if err != nil {
t.Fatal(err)
}
What is it exactly that you tried and failed? Because looking at conn_test.go the API is dead simple and pretty much like any other db API of this kind.
Is there some sort of Go package manager? How does all this shit work?