- Author, Head First Ruby and Head First Go
- 4 years experience as online software development instructor
- See my recent courses at
https://teamtreehouse.com
https://tour.golang.org
(We'll repeat that link at the end.)
- C-like syntax
- Compiles to native code
- Type-safe
- Garbage collected
- Concurrency built into language
- "'go build' will embed everything you need. (No more 'install this in order to run my stuff'.)"
- "Extensive standard library and data types."
- "Strong duck typing."
—Jérôme Petazzoni, "Docker and Go: why did we decide to write Docker in Go?"
::: notes
https://www.slideshare.net/jpetazzo/docker-and-go-why-did-we-decide-to-write-docker-in-go
:::
- "Code in Go isn't overly complex. People don't create FactoryFactory objects."
- "Something with the feel of C with more advanced features like anonymous functions is a great combo."
- "Garbage Collection: We all know how to clean up after our selves but it is so nice to not have to worry about it."
—Joe Beda, "Kubernetes + Go = Crazy Delicious"
- A system utility
- A web app or service
- Something else entirely
- I don't know yet
- Automatically fixes code style
- Acts as community's style guide
- No more arguing tabs vs. spaces!
Before
package main
import "fmt"
func main() {
repeatLine("hello", 3 )
}
func repeatLine( line string ,times int) {
for i := 0; i < times; i++ {
fmt.Println(line)
}
}
$ go fmt repeat.go
After
package main
import "fmt"
func main() {
repeatLine("hello", 3)
}
func repeatLine(line string, times int) {
for i := 0; i < times; i++ {
fmt.Println(line)
}
}
- Compiles a Go source file and runs it
- No executable is saved
$ go run repeat.go
hello
hello
hello
- Compiles Go source file(s) into an executable
$ go build repeat.go
$ ls -l
total 2064
-rwxr-xr-x 1 jay staff 2106512 May 1 21:13 repeat
-rw-r--r-- 1 jay staff 166 May 1 21:13 repeat.go
$ ./