Go is f*cking awesome – Trevor "burlyscudd" Rosen – @trevrosen (GitHub/Twitter)



Go is f*cking awesome – Trevor "burlyscudd" Rosen – @trevrosen (GitHub/Twitter)

0 0


aha-go

AHA presentation on Go(lang)

On Github trevrosen / aha-go

Go is f*cking awesome

Trevor "burlyscudd" Rosen

@trevrosen (GitHub/Twitter)

Who am I?

  • Work at Rapid7 on Metasploit
  • More a software guy than a security guy
  • Someone who likes new languages
  • Go n00b

What is Go?

  • New-ish (2009) "systems" language
  • Makes concurrency stupid simple
  • Looks like a blend of C and Python
  • FOSS project sponsored by Google
  • Started by heavyweights (gods?) like Rob Pike and Ken Thompson
  • Compiled, but in a good way ;-)

Hello, world!

            package main

            import "fmt"

            func main() {
              fmt.Println("Hello, world!")
            }
          

Why is Go cool?

Effortless Concurrency

"Don't communicate by sharing memory. Share memory by communicating."
  • 'go' keyword creates a 'goroutine' to run the supplied function
  • "channel" is a native compound data type - like a buffered queue with blocking capabilities
  • goroutines are multiplexed on OS threads by the runtime - you don't have to care how
  • no locks or mutexes to manage

Strong Typing AND Duck Typing

  • If a type implements an interface, it's regarded as being that kind of thing
  • Go isn't object-oriented -- think types and interfaces
  • A notion of OOP is somewhat possible

Named arguments, named return values

Return variables you declare with a name in function signatures will be available in function body

            func fooBar(numbers []float64) (processedNumbers []float64){
              // Do some stuff to numbers
              // fill the processedNumbers array
              // but no need to declare it, b/c it's in the signature
              return processedNumbers
            }
            

Return more than one value

            func caller(){
              someNums := []float64{1.2, 3.14, 2.71}
              result, err := calledFooBar(someNums)
              if err != nil {
                // do some error stuff
              }
              for _, x := range result {
                fmt.Println("The numbers are:", x)
              } 
            }
      
            func calledFooBar(numbers []float64) (ezNum int, err error){
              // Do some stuff to numbers
              return ezNum, err
            }
            

Great packages in stdlib

  • crypto: lots of standard hash functions, etc
  • os: process and file management, etc
  • net: low and high-level net (IPv4/6, TCP, UDP, DNS) functionality
  • encoding: range of different encoding capabilities (JSON, binary, etc)

Easy to get started!

Go includes a great deal of documentation, all of which you can see from the documentation server that comes with it:

            godoc -http:=8080
          

FIN!

(questions?)