Questions tagged [go]

Go is an open-source programming language. It is statically-typed, with a syntax loosely derived from C, adding automatic memory management, type safety, some dynamic typing capabilities, additional built-in types such as variable-length arrays (called slices) and key-value maps, and a large standard library.

Go (sometimes "Golang" for search-ability) is a general-purpose programming language. While originally created by Google, Go is an open source project with a large contributor base. It aims to be efficient both for development and execution with a focus on fast compilation and increased maintainability of large projects. Go was originally targeted at systems programming tasks such as building server/web applications, high throughput middleware, and databases, but it has a growing ecosystem of libraries allowing it to be used for a wide variety of tasks such as developing end-user daemons, CLIs, and desktop/mobile applications.

The first class concurrency mechanisms of Go make it easier to write programs that get the most out of multicore and networked machines, while its structural type system enables flexible and modular program construction. Go compiles quickly to memory safe machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that develops like a dynamically typed, interpreted language, but performs like native code.

Go Reference Documentation

Go Tutorials

Go Books (Paid)

Go Books (Free)

Popular Go Projects

Go Mailing Lists

Go IRC Channel

Online Go Compilers

Go FAQ

Go Code Editors & IDEs

Go Dependency Management

53896 questions
21
votes
2 answers

Thread-safe way to funnel data from multiple go routines

Given the following example: http://play.golang.org/p/owvJ8Oi77S func produce(dataChannel chan int) { for i := 0; i < 10; i++ { dataChannel <- i } } func main() { dataChannel := make(chan int) go produce(dataChannel) go…
Chris
  • 15,555
  • 3
  • 49
  • 58
21
votes
1 answer

Is there a way to cast Structs for sending over a channel

In GOLANG is there an easy to way to cast structs for polymorphic behavior across channels? I'm trying to send different versions of a struct across one channel, so for example I'm going to have different types of Events, like a LoginEvent. Each one…
Matthew Campbell
  • 401
  • 1
  • 4
  • 7
21
votes
18 answers

Trouble with go tour crawler exercise

I'm going through the go tour and I feel like I have a pretty good understanding of the language except for concurrency. On slide 72 there is an exercise that asks the reader to parallelize a web crawler (and to make it not cover repeats but I…
David Mason
  • 1,377
  • 2
  • 11
  • 14
21
votes
2 answers

throw: all goroutines are asleep - deadlock

Given the following simple Go program package main import ( "fmt" ) func total(ch chan int) { res := 0 for iter := range ch { res += iter } ch <- res } func main() { ch := make(chan int) go total(ch) ch <-…
adk
  • 4,043
  • 9
  • 32
  • 38
21
votes
3 answers

golang pointers on pointers as function parameters

I have the following function: func addCatsToMap(m map[string][]CatHouse, meowId int, treats Set, dog *Dog) { //if (complicated thing) add Cat to m } where Set, the type of treats, is an interface with the following definition: type Set…
Nick Siderakis
  • 1,941
  • 2
  • 20
  • 39
21
votes
5 answers

Reference to string literals in Go

In my application I will frequently pass references to a static string. I wish to avoid having Go allocate memory for each call, but I failed to get the address to my string literal. Why is it not possible to take the address of a string literal…
ANisus
  • 60,676
  • 28
  • 141
  • 147
21
votes
3 answers

Golang: http server leaving open goroutines

I've put up an http server written in Go and it's getting a little over a thousand visitors a day. I have an accumulating Goroutine problem now. Over the course of a day I seem to get a little over a thousand new Goroutines from the http…
Daniel
  • 35,039
  • 9
  • 83
  • 70
21
votes
3 answers

Go session variables?

I'm new to the Go language (Golang) and I'm writing a web-based application. I'd like to use session variables, like the kind in PHP (variables that are available from one page to the next and unique for a user session). Is there something like…
Ross Salas
  • 211
  • 1
  • 2
  • 3
21
votes
2 answers

Can I type assert a slice of interface values?

I am trying to type assert from a []Node, to []Symbol. In my code, Symbol implements the Node interface. Here is some surrounding code: 43 func applyLambda(args []Node, env Env) Node { 44 if len(args) > 2 { 45 panic("invalid argument…
Matt Joiner
  • 100,604
  • 94
  • 332
  • 495
20
votes
2 answers

Google Go and SQLite: What library to use and how?

I'm fairly new to Google's Go, but I'm trying to learn more by writing a simple application to talk to an SQLite 3 database. So far I've come across a few different sqlite libraries, but they all seem to be sparsely maintained or have little or no…
Seth
  • 1,550
  • 3
  • 15
  • 20
20
votes
3 answers

GAE Golang - log.Print()?

Where can one read logs created by calling function: log.Print("Message") The tab "Logs" under Main seems to only display information about what URLs were called, but without any debug information that would be displayed by the application.
ThePiachu
  • 7,295
  • 15
  • 57
  • 93
20
votes
5 answers

List of currently running process in Go

How can I get the list of currently running processes in Go? The OS package provides some functions: http://golang.org/pkg/os/ but doesn't give anything to see the list of running processes.
Kunal P.Bharati
  • 869
  • 4
  • 10
  • 17
20
votes
6 answers

Go - How to create a parser

I want to build a parser but have some problems understanding how to do this. Sample string I would like to parse {key1 = value1 | key2 = {key3 = value3} | key4 = {key5 = { key6 = value6 }}} Preferably I would like to get an output similar to a…
fritjof
  • 223
  • 1
  • 2
  • 4
20
votes
3 answers

How do I get CMake to work with the go programming language?

I have been using CMake with C++ to build libraries and executables and would like to use the same for the go programming language. What steps do I need to take to configure CMake so it would work with the go programming language? Essentially, my…
kfmfe04
  • 14,193
  • 11
  • 67
  • 132
20
votes
4 answers

Can Native Client (NaCl) programs be written in languages other than C or C++?

Would it be possible to write a native client application in Python or Go that could then run in the browser?
Alexis
  • 19,151
  • 17
  • 91
  • 134
1 2 3
99
100