diff --git a/index.html b/index.html index 3088160..3d869d2 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,7 @@ - + @@ -24,10 +24,11 @@ .goplay { background-color: rgb(255, 255, 255); width: 900px; height: 550px; max-height: none; max-width: none; } .reveal dt { font-family:Inconsolata,Monospace; font-weight:900; text-align: left; float: left;} .reveal dd { font-weight:normal; text-align: right;} - .reveal code { font-family: Courier,Monospace; text-transform:none; letter-spacing: 0;} + .reveal code { font-family: Courier,Monospace; text-transform:none; letter-spacing: 0; } .reveal blockquote { box-shadow:none; } .reveal pre { box-shadow:none; } - .reveal section img { border:0px; box-shadow:none; } + .reveal pre code { max-height: 750px; font-size: 36px; line-height: normal; } + .reveal section img { border:0px; box-shadow:none; line-height: 120%; } @@ -52,8 +53,8 @@
-
+
type RandReader struct {}
@@ -422,7 +344,7 @@ RandReader
Type
-
+
import "math/rand"
type RandReader struct {
@@ -438,7 +360,7 @@ NewRandReader()
Function
Creates a RandReader and initializes it
-
+
func NewRandReader() *RandReader {
source := rand.NewSource(time.Now().UnixNano())
return &RandReader{rand.New(source)}
@@ -451,7 +373,7 @@ Attach the Read
Function
Supplying a Read([]byte) int, error
function makes it match the io.Reader
interface
-
+
import "encoding/binary"
// Contains a bug that does not fill the provided array
@@ -470,17 +392,6 @@ Attach the Read
Function
Goroutines
-
- Sidenote: Concurrency vs Parallelism
-
- -
- Concurrency: Composition of independently executing processes
-
- -
- Parallelism: Simultaneous execution of optionally related computations.
-
-
-
Sidenote: Concurrency vs Parallelism
@@ -490,11 +401,11 @@ Sidenote: Concurrency vs Parallelism
-- Andrew Gerrand
-
-
- Sidenote: Concurrency vs Parallelism
More Information: Rob Pike on Concurrency vs Parallelism
http://vimeo.com/49718712
+
@@ -511,7 +422,7 @@ Call a standard function
Call a function variable
-
+
f := func() {time.Sleep(100 * time.Hours())}
go f()
@@ -520,7 +431,7 @@ Call a function variable
Call an anonymous function
-
+
go func() {time.Sleep(100 * time.Hours())}()
@@ -531,7 +442,7 @@ Goroutine Gotchas
- Goroutines do not block the main thread from exiting.
- You must manage concurrent access. See
sync.Mutex
- - There is no one to return a value to. (Use channels)
+ - There is no one to return a value to. (Use channels.)
@@ -547,23 +458,25 @@ Channels
http://blog.golang.org/pipelines
-
- Make a Channel
-
+
+
+Make a Channel
+
var ch chan int
ch = make(chan int)
-
-
+
+
+
Size a Channel
-
+
ch := make(chan int, 10)
- Send To a Channel
-
+Send To a Channel
+
ch := make(chan int, 1)
ch <- 1
ch <- 2
@@ -571,15 +484,15 @@ Send To a Channel
- Recieve From a Channel
-
+Recieve From a Channel
+
c := <-ch
- Recieve From a Channel with range
-
+Recieve From a Channel with range
+
ch := make(chan int, 10)
ch <- 1
ch <- 2
@@ -592,8 +505,8 @@ Recieve From a Channel with range
- Recieve From a Channel with select
-
+Recieve From a Channel with select
+
ch := make(chan int, 10)
done := make(chan bool)
ch <- 1
@@ -613,7 +526,7 @@ Recieve From a Channel with select
Return a Channel
-
+
func generate(nums ...int) <-chan int {
out := make(chan int)
go func() {
@@ -628,7 +541,7 @@ Return a Channel
Pass a Channel
-
+
func sq(in <-chan int) <-chan int {
out := make(chan int)
go func() {
@@ -643,7 +556,7 @@ Pass a Channel
A Pipeline of Channels
-
+
func square(in <-chan int) <-chan int {}
func generate(nums ...int) <-chan int {}
@@ -657,71 +570,120 @@ A Pipeline of Channels
-
-
- Extra! HTTP Service
-
-
- The Key is an Interface
-
-type Handler interface {
- ServeHTTP(ResponseWriter, *Request)
-}
-
-
- Simplest Server
-
-package main
-import (
- "fmt"
- "net/http"
-)
+
+
+ Common Toolchain, Common Practices
+
+
+ go clean
+ go get
+ go fmt
+ go test
+ go build
+
+
+
-func handler(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
-}
+
+ go clean
+
+ - Removes object files from package source directories.
+
+
+go clean [packages]
+go clean github.com/goraft/raft
+
+
-func main() {
- http.ListenAndServe(":8080", handler)
-}
-
-
+
+ go get
+
+ - Downloads and installs packages and their dependencies.
+
+
+go get [-u] [packages]
+go get code.google.com/p/gcfg
+go get -u github.com/goraft/raft
+
+
-
- Introducing ServeMux
-
-package main
-import (
- "fmt"
- "net/http"
-)
+
+ go fmt
+
+ - Reformats the packages listed to the golang standard.
+ - Many editors run
go fmt
on save.
+
+
+go fmt [-n] [-x] [packages]
+
+
-func handler(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:])
-}
+
+ go build
+
+ - Compiles the packages named by the import paths, along with their dependencies.
+ - Does not install the resulting binaries.
+
+
+go build [-o output] [build flags] [packages]
+go build ./...
+
+
-func main() {
- mux := http.NewServeMux()
- mux.HandleFunc("/hi",handler)
- mux.Handle("",http.NotFoundHandler())
- http.ListenAndServe(":8080", mux)
-}
+
+ go test
+
+- Recompiles each package along with any files with names matching
*_test.go
.
+
+go test [-c] [-i] [build/test flags] [packages] [flags for test binary]
+go test ./...
+go test github.com/goraft/raft
-
+Prints a summary of test results.
+
+ok archive/tar 0.011s
+FAIL archive/zip 0.022s
+ok compress/gzip 0.033s
+...
+
+
Can contain test functions, benchmark functions, and example functions.
+
+
+
+
+
+ go install
+
+ - Compiles and installs packages and their dependencies.
+
+
+go install [build flags] [packages]
+go install github.com/crosbymichael/skydock
+
+
+
+
+ Top Three Hints
+
+ - Don't think in traditional objects. Add behavior (interfaces) instead.
+ - Try the standard library first.
Especially "net/http".
+ - Learn to love channels.
+
Resources
- - http://golang.org/doc/effective_go.html
- - http://golang.org/ref/spec
- - http://blog.golang.org/
- - http://www.reddit.com/r/golang
- - http://golang.org/doc/faq
- - https://groups.google.com/forum/#!forum/Golang-nuts
+ - http://golang.org/doc/effective_go.html
+ - http://golang.org/ref/spec
+ - http://blog.golang.org/
+ - http://www.reddit.com/r/golang
+ - http://golang.org/doc/faq
+ - https://groups.google.com/forum/#!forum/Golang-nuts
@@ -761,8 +723,12 @@ We are hiring!
history: true,
center: true,
- width: 960,
- height: 700,
+ width: 1800,
+ height: 1000,
+
+ // Bounds for smallest/largest possible scale to apply to content
+ minScale: 0.2,
+ maxScale: 1.0,
theme: Reveal.getQueryHash().theme || 'solarized', // available themes are in /css/theme
transition: Reveal.getQueryHash().transition || 'default', // default/cube/page/concave/zoom/linear/fade/none