Hello There!
I work for Archetype Consulting
Solutions Architect by Day
Computer Scientist the rest of the time
Golang Enthusiast.
Why Go?
Easy to learn
Built for the Web
Community Oriented by Design
High level & Low level Capabilites
Small & Simple, yet Complete
What Can Go Do?
- Websites (yes JavaScript will still be involved)
- Mobile Applications
- Systems Programming
- ...
History of Go
- Originated as an experiment at Google by Robert Griesemer, Rob Pike & Ken Thompson
- Goal: Development speed of Python with the performance and safety of C or C++
- Created at Google in 2007
Design Principles I
Regular & Simple
- Few Keywords
- if, range, for, else ... (21 more)
- Main Primitive Types
- boolean, numerics (uint0x, int0x, float0x, complex0x), strings
- Main Non-Primitive Types
- arrays, slices, maps, structs, pointers, functions, interfaces, channels, method sets
- Statically Typed
- reduces runtime type errors
- Compiler enforced variables and imports (YAGNI)
- Dyanamic Features
- Fast Compilation
- Garbage Collection & Cross Plaftform
Design Principles II
Design Abstractly, Code Instinctively
- Composition over Inheritance
- No Inheritance; Less planning, Better Extensibility
- Program to interfaces, not implementations
- Interface programming is a staple and is fundamentally simple.
- Polymorphism
- Interface Methods, Embedded Structs (Subtyping) & Identifier Promotion (Overriding)
Design Principles III
Page Light, Style Consistent
Encourages code that is easier to read and maintain
- Style can be enforced by the language
-
Gofmt tool to format your code, Godoc tool to document your code
- Documentation generated by the language
-
Godoc tool to create documentation based on simple commenting rules
Design Principles III Continued
Page Light, Style Consistent
Dynamic & Concise Syntax
// This sample program demonstrates a simple web server.
package main
import (
"net/http"
)
func main() {
fs := http.FileServer(http.Dir("/home/me/mywebsite/static/"))
http.Handle("/", fs)
http.ListenAndServe(":3000", nil)
}
Lightening Lessons in Basic Go
Hello World!
Go to play.golang.org
<a href="https://play.golang.org/p/ZGmpjak_7O">see this code in play.golang.org</a>
Variables
Go to play.golang.org
<a href="https://play.golang.org/p/j9Mfsz_o8C">see this code in play.golang.org</a>
Arrays
Go to play.golang.org
<a href="https://play.golang.org/p/v8b6B1s7Wj">see this code in play.golang.org</a>
Slices
Go to play.golang.org
<a href="https://play.golang.org/p/WPGa7jtg4M">see this code in play.golang.org</a>
Structs
Go to play.golang.org
<a href="https://play.golang.org/p/KP5cjk1Sl1">see this code in play.golang.org</a>
Out of Scope Topics
(Future Talks?)
Pointers
Maps
Multi-Dimensional Structures
Go Types In Depth
Packaging, Project Structure & Tooling
OOP: Composition, Interfaces, Polymorphism...
Concurrency
Cgo
Gotchas
...
Go Intro
An Introduction to Golang (Go)
Samer AbuNasser / @snassr_