The State of Go

Johnny Estilles

Manila, October 13, 2018

Johnny Estilles

Engineering Manager, Freelancer.com

@JohnnyEstilles

johnny@estilles.com

GoManilaPh

GoLang Developers Meetup Group

Why are we here?

25 September 2007

Go is Born

Ken Thompson

Rob Pike

Robert Griesemer

10 November 2009

Go Open Source Release

5 October 2011

Go 1 Proposal

March 28, 2012

Go 1 Release

Date Go Version
2013/05/13 1.1 Language + Other Changes
2013/12/01 1.2 Language + Other Changes
2014/06/18 1.3 No Language Changes
2014/12/10 1.4 Language + Other Changes
2015/08/19 1.5 Language + Other Changes
2016/02/17 1.6 No Language Changes
2016/08/15 1.7 Language + Other Changes
2017/02/16 1.8 Language + Other Changes
2017/08/24 1.9 Language + Other Changes
2018/02/16 1.10 No Language Changes

Go Releases

24 August 2018

Go 1.11 Release

Go 1.11

Go Modules

Go Modules

$ mkdir -p /tmp/scratchpad/hello
$ cd /tmp/scratchpad/hello

$ go mod init github.com/JohnnyEstilles/hello

go: creating new go.mod: module github.com/JohnnyEstilles/hello

Go Modules (hello.go)

package main

import (
    "fmt"
    "rsc.io/quote"
)

func main() {
    fmt.Println(quote.Hello())
}

Go Modules

$ go build 
$ ./hello

Hello, world.

Go Modules (go.mod)

module github.com/JohnnyEstilles/hello

require rsc.io/quote v1.5.2

Go 1.11

Web Assembly

Web Assembly

package main

import "fmt"

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

Web Assembly

$ GOOS=js GOARCH=wasm go build -o main.wasm

$ cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" .

Web Assembly

<html>
  <head>
    <meta charset="utf-8">
    <script src="wasm_exec.js"></script>
    <script>
      const go = new Go();
      WebAssembly
        .instantiateStreaming(fetch("main.wasm"), go.importObject)
        .then((result) => {
          go.run(result.instance);
        });
    </script>
  </head>
  <body></body>
</html>

28 August 2018

Go 2 Draft

Go 2 Draft

Error Handling

func CopyFile(src, dst string) error {
	r, err := os.Open(src)
	if err != nil {
		return fmt.Errorf("copy %s %s: %v", src, dst, err)
	}
	defer r.Close()

	w, err := os.Create(dst)
	if err != nil {
		return fmt.Errorf("copy %s %s: %v", src, dst, err)
	}

	if _, err := io.Copy(w, r); err != nil {
		w.Close()
		os.Remove(dst)
		return fmt.Errorf("copy %s %s: %v", src, dst, err)
	}

	if err := w.Close(); err != nil {
		os.Remove(dst)
		return fmt.Errorf("copy %s %s: %v", src, dst, err)
	}
}
func CopyFile(src, dst string) error {
	handle err {
		return fmt.Errorf("copy %s %s: %v", src, dst, err)
	}

	r := check os.Open(src)
	defer r.Close()

	w := check os.Create(dst)
	handle err {
		w.Close()
		os.Remove(dst) // (only if a check fails)
	}

	check io.Copy(w, r)
	check w.Close()
	return nil
}

Error Handling - Proposed Syntax

Go 2 Draft

Generics

// A list implementation based on an internal slice.
type List(type T) []T

// A keys function which returns all keys of a map in a type-safe way.
func Keys(type K, V)(m map[K]V) []K {
 ...
}

Generics - Proposed Syntax

Go 2 Draft Designs

Thank you!

@JohnnyEstilles

johnny@estilles.com

The State of GoLang (1.11)

By Johnny Estilles

The State of GoLang (1.11)

  • 232