Go, for fun and profit

WWC Belfast 

Rebecca Martin

 

Who am I? 

  • Junior developer at Flexera 
  • Mainly do backend development
  • Main languages I use are Go, Python
  • Also very interested in Rust and Elixir
  • Twitter: @laches1sm

What is Go/Golang 

  • Created by Google in 2009
  • Open source, anyone can contribute
  • The aim of Go is to `[make] it easy to build simple, reliable, and efficient software.`
  • Based on the C programming language, much like Java
  • Can be used for both backend and frontend work

Features of Go

  • Type inference - don't have to declare the type like in Java
  • `go get` - can get packages easily from Github etc
  • Easy to build - `go build`
package main

import(

"fmt"

)

func main(){

    x := 10
    fmt.Println(x)
    //don't have to declare an explicit type like int x

}

Features of Go

  • `go fmt` - formats your code to look neater, useful feature
  • Go enforces good coding practice through several features of the language
package main

import(

    "fmt"
    "log"
    "net/http"
    "encoding/json" // Go will refuse to compile this file because there is a unused import
)

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
}

func main() {
    http.HandleFunc("/", handler)
    log.Fatal(http.ListenAndServe(":8080", nil))
}

Features of Go

  • Go focuses on concurrency out of the box - allowing the system to carry on operating while slow operations carry on in the background
  • Garbage collection - so unlike languages like C++ memory allocation is sorted automatically 
  • Multiple returns are done in a easier fashion than Java

Live Demo

  • Now, for something I prepared earlier!

Resources for learning Go

  • Golang official website: https://golang.org/
  • Go Tour: https://tour.golang.org/welcome/1
  • Go Playground: https://play.golang.org/
  • WWC Belfast Go workshops
  • Code Co-Op
  • Belfast Gophers
  • Excercism 

deck

By laches1sm

deck

  • 636