emc dojo golang meetup cambridge
TRANSCRIPT
![Page 1: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/1.jpg)
Xuebin He
Xuebin He
Golang EMC Dojo
1
![Page 2: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/2.jpg)
Xuebin HeXuebin He
play.golang.org
github.com/kaleo211/golang-demo
![Page 3: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/3.jpg)
Xuebin He
Origins
3
![Page 4: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/4.jpg)
Xuebin He
❖ Created at Google in 2007
❖ Open Source in 2009
❖ First stable release in 2012
4
![Page 5: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/5.jpg)
Xuebin He 5
![Page 6: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/6.jpg)
Xuebin He
❖ C: syntax, control-flow, basic data types, call by value, pointers
❖ Oberon-2: packages, imports, method declarations
❖ Alef: concurrency, channel, garbage collection
6
![Page 7: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/7.jpg)
Xuebin HeXuebin He
package main
/* #include <stdio.h> #include <stdlib.h>
void myprint(char* s) { printf("%s\n", s); } */ import "C" import "unsafe"
func main() { cs := C.CString("Hello from stdio\n") C.myprint(cs) C.free(unsafe.Pointer(cs)) }
![Page 8: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/8.jpg)
Xuebin He
TIOBE for June 2016
Position Language Ratings
1 Java 20.794%
2 C 12.376%
3 C++ 6.199%
4 Python 3.900%
40 Go 0.209%
8
![Page 9: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/9.jpg)
Xuebin He
Why Go?
![Page 10: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/10.jpg)
Xuebin HeXuebin He
Fast Compilation Easy for OOP
Built-in Concurrency Pass by Reference
Readability Dependency Management
![Page 11: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/11.jpg)
Xuebin HeXuebin He
Fast Compilation Easy for OOP
Built-in Concurrency Pass by Reference
Readability Dependency Management
![Page 12: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/12.jpg)
Xuebin He
![Page 13: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/13.jpg)
Xuebin He
“Go provides a model for software construction that
makes dependency analysis easy and avoids much of
the overhead of C-style include files and libraries.”
![Page 14: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/14.jpg)
Xuebin HeXuebin He
Fast Compilation Easy for OOP
Built-in Concurrency Pass by Reference
Readability Dependency Management
![Page 15: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/15.jpg)
Xuebin HeXuebin He
![Page 16: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/16.jpg)
Xuebin He
![Page 17: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/17.jpg)
Xuebin He
“If you could do Java over again,
what would you change?”
![Page 18: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/18.jpg)
Xuebin He
“The real problem wasn't classes, but rather implementation inheritance.”
“I’d leave out classes.”
![Page 19: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/19.jpg)
Xuebin He
Is-a vs Has-a
Prius is a car that has the ability to run
Peter has the ability to run
Peter is a human that has the ability to run
![Page 20: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/20.jpg)
Xuebin He
Duck Typing
“If it looks like a duck and quacks like a duck, it’s a duck.”
![Page 21: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/21.jpg)
Xuebin HeXuebin He
![Page 22: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/22.jpg)
Xuebin HeXuebin He
Fast Compilation Easy for OOP
Built-in Concurrency Pass by Reference
Readability Dependency Management
![Page 23: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/23.jpg)
Xuebin HeXuebin He
Concurrency vs Parallelism
Dealing with things at once Doing things at once
Core0
Core1Core0
![Page 24: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/24.jpg)
Xuebin HeXuebin He
![Page 25: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/25.jpg)
Xuebin He
Goroutines vs Thread
The OS schedules threads to run against available processors
Go runtime schedules goroutines to run within a logical processor that is bound to a single OS thread
![Page 26: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/26.jpg)
Xuebin HeXuebin He
Go 1.6.2 (April 2016) 64-bit x86 CPU (A10-7850K 4GHz) | Number of goroutines: 100,000 | Per goroutine: | Memory: 4707.92 bytes | Time: 1.842097 µs
![Page 27: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/27.jpg)
Xuebin HeXuebin He
Fast Compilation Easy for OOP
Built-in Concurrency Pass by Reference
Readability Dependency Management
![Page 28: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/28.jpg)
Xuebin He
Pass by Value vs Pass by Reference
Performance
![Page 29: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/29.jpg)
Xuebin HeXuebin He
Pointer Arithmetic
Memory allocation
Segment Error
![Page 30: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/30.jpg)
Xuebin HeXuebin He
Fast Compilation Easy for OOP
Built-in Concurrency Pass by Reference
Readability Dependency Management
![Page 31: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/31.jpg)
Xuebin HeXuebin He
60+ companies
3,000,000 lines
![Page 32: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/32.jpg)
Xuebin He
VS
![Page 33: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/33.jpg)
Xuebin HeXuebin He
go fmt
![Page 34: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/34.jpg)
Xuebin HeXuebin He
Fast Compilation Easy for OOP
Built-in Concurrency Pass by Reference
Readability Dependency Management
![Page 35: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/35.jpg)
Xuebin HeXuebin He
gocode├── bin├── pkg└── src ├── github.com │ ├── Sirupsen │ │ └── logrus │ ├── kaleo211 │ │ └── golang-demo │ └── kisielk │ ├── errcheck │ └── gotool └── golang.org └── x ├── net └── oauth2
![Page 36: EMC Dojo Golang Meetup Cambridge](https://reader036.vdocument.in/reader036/viewer/2022062412/58ee78661a28ab62588b45a9/html5/thumbnails/36.jpg)
Xuebin HeXuebin He
go get github.com/kaleo211/golang-demo