Companies are using Go ▪ Gophers, gophers, and more gophers! ▪ More Go developer needed in the industry ▪ Beginner’s training is important! ▪ GopherCon2019 supported by:
Companies are using Go ▪ Gophers, gophers, and more gophers! ▪ More Go developer needed in the industry ▪ Beginner’s training is important! ▪ GopherCon2019 supported by:
Jay McGavren (Author of Head First Go) ▪ 4 years experience as a software development trainer ▪ Frequent conference speaker, an all-round mentor for dev. • Session ◦ Wed. 24th of July, 2019 - 9.00AM to 5.00PM (8 Hours)
Jay McGavren (Author of Head First Go) ▪ 4 years experience as a software development trainer ▪ Frequent conference speaker, an all-round mentor for dev. • Session ◦ Wed. 24th of July, 2019 - 9.00AM to 5.00PM (8 Hours) • 2 Software Engineers from Mercari Inc. Attended ◦ New Grad, Joined Mercari in April 2019 ▪ Mark Hahn ▪ Hunter Chen
Beginner ◦ Exercise and Hands-On Examples ▪ Teaching style ▪ How people learn Go • Take This Learning Experience and Share ◦ Interns, New Grads, Mentors & Mentees ▪ 1 day workshop for fast grasp to start with Go ▪ Then, they can start learning more advanced topics
◦ Compiles to native code ◦ Type-safe ◦ Garbage collected ◦ Concurrency built into the language • “Famous” Examples ◦ Docker: “Why did we decide to write Docker in Go” ◦ K8s: Go isn’t overly complex; feels of C w/ adv. Features is a great combo; Garbage collection
Package clause, imports, code ◦ main package, calling functions • Exercises with Each Topic ◦ A Short Program ◦ … ◦ … ◦ … ◦ … ◦ goroutines, channels, ...
bit of theory ◦ Post a link with exercise ◦ Visit the link and follow the instruction ▪ Add codes, fill in blanks, etc. ◦ Cheat-sheet given as hints • 2 Parts for Each Topic ◦ 1. Concepts in few sentences ▪ with Example codes ◦ 2. Exercise: Main Part of the Workshop !!!
Code: var length float64 = 1.2 var width int = 2 length = width // Can't assign an `int` value to a `float64` variable: • Compile Error cannot use width (type int) as type float64 in assignment
Code: var length float64 = 1.2 var width int = 2 // Can't do a math operation with a float64 and an int: fmt.Println("Area is", length*width) // Or a comparison: fmt.Println("length > width?", length > width)
Code: var length float64 = 1.2 var width int = 2 // But you can if you do type conversions! fmt.Println("Area is", length*float64(width)) fmt.Println("length > width?", length > float64(width)) • Output: Area is 2.4 length > width? false
can’t do math operations or comparisons ▪ between values of two different types. ◦ But, we can convert values ▪ From one type to another ▪ Using conversions ◦ A conversion takes the form: ▪ `targetType(valueToConvert)`
Problem: ◦ Pass-by-value ◦ Receiver parameters get a copy of the original value ◦ Modify receiver parameter? You are only changing “the copy” • To Fix: ◦ Change the type of the receiver parameter to a pointer func (c *Coordinates) Obfuscate() { c.Latitude = math.Round(c.Latitude) c.Longitude = math.Round(c.Longitude) }
a type's methods should use pointer receivers, // if any of them do. func (r *Rectangle) Area() float64 { return r.Length * r.Width } func (r *Rectangle) Perimeter() float64 { return (2 * r.Length) + (2 * r.Width) } // Make sure to use a pointer receiver, so you're modifying // the receiver itself and not a copy of it. func (r *Rectangle) Scale(factor float64) { // The receiver pointer is automatically dereferenced when accessing // the struct fields below. // Multiply Length by "factor" and assign the result back to the field. r.Length *= factor // Multiply Width by "factor" and assign the result back to the field. r.Width *= factor }
Can finish all approx. 3hr to 8hr (for new gophers) • Where to Go Next? ◦ `go test` ◦ Web development: `net/http` package ◦ Other Resources: ▪ How to Write Go Code - golang.org/doc/code ▪ Effective Go, Standard Library Docs, ▪ Books - the Go Programming Language, Head First Go
It’s growing in GitHub, companies, and schools • We Can Learn Go Basics in “ONE” Day ◦ Go is a simple language • We Could Also Encourage Your Friends to Try Go ◦ You can freely access the workshop’s material • Let’s Enjoy Go Programming :) ◦ Make things in Go !
Frederickson ◦ Article with Images • Presentation at GopherCon2019 by Jay McGavren ◦ GitHub Markdown Note • Credits for Gopher Images by Maria Letta ◦ GitHub Repo