Google Go: An Inside Look at Its Advanced Features

 
 
By Jeff Cogswell  |  Posted 2012-11-05
 
 
 

Go Looks Like Another C

The Go language looks like another C-based language, but from a programming perspective, it feels and works more like a modern dynamic language.

Go Looks Like Another C

Advanced Features

Go includes a large number of external packages with features such as compression, cryptography, image handling, Web development and operating systems support.

Advanced Features

Additional Support

Recently Google has added Go to the list of languages that you can use for programming their App Engine for cloud-based development.

Additional Support

Go Is for Multicore

Go supports multicore programming natively. You can see here all eight cores peaked out as the parallel code was distributed among the cores.

Go Is for Multicore

Support for Closures

Like most modern languages, Go includes support for closures, even though it's a strongly typed language.

Support for Closures

'Goroutines'

Although the outer loop finished, the individual "goroutines" still had access to the outer loop's variables through closure. Each thread printed the value of the variable, "hello."

'Goroutines'

Working With Each Core

Go lets you specify the number of cores to use as you launch your "goroutines." Here we're using eight cores.

Working With Each Core

How it Works

Because we used eight cores, no cores were left for the outer loop, which, in turn, waited until the scheduler allowed it to move forward.

How it Works

Adjusting to Seven Cores

By adjusting the number of cores down to seven, one will be left for the outer thread.

Adjusting to Seven Cores

Conclusion

Indeed, leaving one thread for the outer allowed the loop to finish before all the inner threads even ran.

Conclusion

Rocket Fuel