4. Creators
Rob Pike
• Worked at Bell
Labs and Google
• co-creator of
UTF-8
Ken Thompson
• Designed and
implemented the
original Unix
Robert Griesemer
• Worked on
Google's V8
JavaScript engine
G
e
t
G
o
i
n
g
5
14. Basic Types
• bool
• string
• int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64
• rune // alias for int32 that represents a Unicode code point
• float32, float64
• complex64, complex128
G
e
t
G
o
i
n
g
15
23. Exercise 1
Euler 1
1) If we list all the natural numbers below 10 that are multiples of 3
or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
2) The Math.Sin values for 2 is positive and the value for 5 is
negative. Print the sum of the positive sine values from the input
between 0 and 10.
If you get done, try Euler 2 (https://projecteuler.net/problem=2)
G
e
t
G
o
i
n
g
24
45. Exercise 2
Create a GIF
Using the image/gif and image/color packages, create a gif of a
checker board.
Using the same libraries, create an animated gif of a sine wave.
G
e
t
G
o
i
n
g
47
55. Exercise 3
Create a GIF Concurrently
Modify your code that creates a sine wave gif to create the file
concurrently while the user enters the output file name.
G
e
t
G
o
i
n
g
57
65. Exercise 4
Web Services
Create a webservice that returns the sine of a given number.
Create a webservice that returns your sine wave GIF
G
e
t
G
o
i
n
g
67
I’m not a go expert
Open C:\Projects\exploration\GO\MIDOTNET\TextEntryWithTimeout
I’m not a go expert
You are probably very good at your job. You write good code.
But you may run into a situation where your services aren’t fast enough. You need a faster platform.
That is where Go comes in. You can use go to build services that are fast and easy to maintain.
This enables you to build software for your users that meets their needs and makes them successful.
Batteries included, fast
Modernize systems programming
Concurrency
Garbage Collection
“The three of us got together and decided that we hated C++.” – Thompson
First planned while waiting for C++ program to compile ('07)
First stable released in '12
CLI go mod init, mod tidy, go fmt, go build, go run, go test
VS Code, Go Land
Unit test runner, package manger, and formatter are built in
CLI and VS Code
No parens, no semi-colons
Func, for, if
(no do or while loops)
Generics only added recently
In go, if the function name is capitalized, it is visible outside the module
The return type can be a tuple, or 2 values
VS CODE
If you get do
Slices are a powerful abstraction on top of arrays
Go has pointers but doesn’t allow pointer arithmatic
The size is part of the type
Slices store data in an underlying array
The low end of the range is inclusive, the high end is exclusive
Go has structural-typing
The programmer doesn’t have to declare and a struct is a reader, it just needs to implement the io.Reader and io.ByteReader inerfaces
If you get do
Goroutine
Managed by go runtime
Channel
Select
Allow goroutine to read from channel(s)
Channel
Select
Allow goroutine to read from channel(s)
Go’s select lets you wait on multiple channel operations.
Channel
Select
Allow goroutine to read from channel(s)
If you get do
defer statements delay the execution of the function or method or an anonymous method until the nearby functions returns
Defer is used to ensure that a function call is performed later in a program’s execution, usually for purposes of cleanup. defer is often used where e.g. ensure and finally would be used in other languages.