- 1. Golang
- 2. Introduction to Golang
- 2.1. Features
- 2.2. Why Golang?
- 2.3. Go Designed by
- 2.4. Open Souce
- 2.5. Platforms
- 2.6. Major Open Source Projects
- 2.7. Install Golang
- 2.8. Show Installed Version of Golang
- 2.9. Editor/IDE for Golang
- 2.10. Hello World
- 2.11. Build Hello World exe
- 2.12. Source of examples
- 2.13. Separate directories! - main redeclared in this block
- 2.14. Exercise: Hello World
- 3. Basics
- 3.1. Hello Foo - Println
- 3.2. Hello Bar - Printf
- 3.3. Hello Bar - Printf %v
- 3.4. Enforce variables types
- 3.5. Basic Types
- 3.6. Show inferred variable type - Printf %T
- 3.7. Show type of variable - reflect.TypeOf
- 3.8. get variable type - %T or reflect.TypeOf
- 3.9. Variable declaration (var)
- 3.10. Default values of variables
- 3.11. Scan input strings from STDIN
- 3.12. if else statement
- 3.13. Converting string to integer - strconv, Atoi
- 3.14. Error Handling
- 3.15. Converting string to integer with error handling - strconv, Itoa
- 3.16. Converting string to float - strconv, ParseFloat
- 3.17. Converting integer to string - strconv, Itoa
- 3.18. Scan STDIN convert to number
- 3.19. Comments
- 3.20. Exercise: circle STDIN
- 3.21. Exercise: rectangular STDIN
- 3.22. Exercise: calculator STDIN
- 3.23. Solution: circle STDIN
- 3.24. Solution: circle STDIN with math
- 3.25. Solution: rectangular STDIN
- 3.26. Solution: calculator STDIN
- 3.27. Solution: calculator STDIN switch
- 4. CLI
- 4.1. Args - (argv) command line arguments
- 4.2. Exit early with exit code
- 4.3. Exercise: rectangular
- 4.4. Exercise: calculator
- 4.5. Solution: rectangular CLI
- 4.6. TODO: Solution: calculator CLI
- 4.7. TODO: Solution: calculator (switch)
- 5. Skeleton
- 5.1. empty file
- 5.2. Only package main
- 5.3. Other package name
- 5.4. Skeleton file
- 6. Numbers
- 6.1. Integer-based operations
- 6.2. Floating-point based operations
- 6.3. Precision
- 6.4. Mixed operations
- 6.5. int8
- 6.6. uint8
- 6.7. Bytes
- 6.8. Byte is uint8
- 6.9. uint16
- 6.10. uint32
- 6.11. Converting values to other types - float32, int, string
- 6.12. Complex numbers
- 6.13. binary - octal - hex
- 6.14. Random
- 6.15. Random with seed
- 6.16. Exercise: One-dimensional spacefight - level 1
- 6.17. Solution: One-dimensiona spacefight - level 1
- 7. Boolean - Logical operators
- 7.1. Boolean values - bool, true, false
- 7.2. Boolean truth table
- 8. Loops
- 8.1. 3-part for loop
- 8.2. while-like for loop
- 8.3. infinite loop
- 8.4. break out from loop
- 8.5. continue
- 8.6. loop on two variables
- 8.7. break out from internal loop (labels)
- 8.8. Exercise: One-dimensional spacefight
- 8.9. Exercise: FizzBuzz
- 8.10. Solution: One-dimensional spacefight - multiple guesses till hit
- 8.11. Solution: One-dimensional spacefight - allow x
- 8.12. Solution: One-dimensional spacefight - allow m
- 8.13. Solution: FizzBuzz
- 9. Strings
- 9.1. Single and double quotes
- 9.2. Runes
- 9.3. Strings
- 9.4. Change string
- 9.5. Strings and Runes
- 9.6. Length of string
- 9.7. iterate over characters in a string
- 9.8. String Contains, HasPrefix, HasSuffix
- 9.9. Split
- 9.10. Join
- 9.11. Split on whitespaces
- 9.12. Newlines
- 9.13. Read line from stdin (keyboard)
- 9.14. Read line from stdin (keyboard) with error handling
- 9.15. Trim line - remove trailing newline from string
- 9.16. Strings and bytes
- 9.17. Scan in a loop
- 9.18. Compare strings
- 9.19. Raw strings
- 9.20. Multiline strings
- 9.21. Exercise: how long is this string?
- 9.22. Exercise: which string is longer?
- 9.23. Exercise: which string is ahead in ABC?
- 9.24. Exercise: which string is ahead - menu
- 9.25. Exercise: Hide substring
- 9.26. Solution: how long is this string?
- 9.27. Solution: which string is longer?
- 9.28. Solution: which string is ahead in ABC?
- 9.29. Solution: which string is ahead - menu
- 9.30. Solution: Hide substring
- 10. Arrays
- 10.1. Arrays
- 10.2. Array index out of range - compile time
- 10.3. Array index out of range - run time
- 10.4. Array change value
- 10.5. Arrays automatic length
- 10.6. Array: empty and fill
- 10.7. Empty array of strings
- 10.8. Array assignment (copy)
- 10.9. Array assignment (pointer)
- 10.10. Matrix (two dimensional array)
- 10.11. For loop on array - iterate over array
- 10.12. for loop on values of array (no index)
- 10.13. Arrays conclusion
- 10.14. Exercise: Language Selector
- 10.15. Exercise: count digits
- 10.16. Exercise: count digits from string
- 10.17. Exercise: Report statistics
- 10.18. Solution: Language Selector
- 10.19. Solution: count digits
- 10.20. Solution: count digits from string
- 10.21. Solution: Report statistics
- 11. Variables
- 11.1. Variable Declarations
- 11.2. Variables - Naming
- 11.3. Declare multiple variables in one line
- 11.4. Variables cannot be redefined (no new variables on left side of :=)
- 11.5. At least one new variable on the left side of :=
- 11.6. Use the same err on the left hand side
- 11.7. Package variable
- 11.8. Shadowing package variable
- 11.9. Variable scope
- 12. Constants
- 12.1. Constants
- 12.2. Constants cannot be changed
- 12.3. Shadowing constants
- 12.4. Constant blocks
- 12.5. iota
- 12.6. iota skipping 0
- 12.7. const powers of 2
- 13. Functions
- 13.1. Hello World function
- 13.2. Hello You function (passing parameter)
- 13.3. Function with multiple parameters
- 13.4. Function with return value
- 13.5. Multiple return values
- 13.6. Returning an error from a functions
- 13.7. Named return parameters
- 13.8. Passing a function as a parameter - Callback function
- 13.9. Callback function with one parameter
- 13.10. Anonymous functions
- 13.11. Anonymous functions assigned to name
- 13.12. Numbers are passed by value
- 13.13. Function Overloading - Multiple function with the same name
- 13.14. Defer
- 13.15. Defer early returns
- 13.16. Deferred cd in a function
- 13.17. Defer in if-statements
- 13.18. Defer and parameters
- 13.19. Exercise: Fibonacci
- 13.20. Exercise: Defer remove temporary directory
- 13.21. Exercise: FizzBuzz in function
- 13.22. Exercise: ROT13
- 13.23. Solution: FizzBuzz in function
- 13.24. Solution: ROT13
- 14. Slices
- 14.1. Slice of an array
- 14.2. Slice
- 14.3. Change value in slice
- 14.4. Slice Assign
- 14.5. Slice of a slice
- 14.6. Append to a slice
- 14.7. Slice append
- 14.8. Remove last element of slice (pop)
- 14.9. Remove first element of slice (shift, pop(0))
- 14.10. Pre-allocate capacity for slice with make
- 14.11. For loop in slice - iterate over slice
- 14.12. for loop on values of slice (no index)
- 14.13. Merge two slices
- 14.14. Find element in array or slice
- 14.15. Remove element of slice
- 14.16. Weird merge slices
- 14.17. Sort slice
- 14.18. Are values sorted?
- 14.19. Sort strings by length
- 14.20. Sort strings by length and then abc order
- 14.21. Search in slice
- 14.22. Variadic function (arbitrary number of parameters)
- 14.23. Defer and slice
- 14.24. Exercise: count words
- 14.25. Exercise: Create a list of words from sentences
- 14.26. Exercise: Create a unique list of values
- 14.27. Exercise: Reverse Polish Calculator
- 14.28. Exercise: DNA Sequencing
- 14.29. Solution: count words
- 14.30. Solution: Create a list of words from sentences
- 14.31. Solution: Create a unique list of values
- 14.32. Solution: Reverse Polish Calculator
- 14.33. Solution: DNA Sequencing
- 14.34. Solution: DNA Sequencing with in place filter
- 15. Files
- 15.1. Read file line-by-line with Scanner
- 15.2. Read file line by line with Reader
- 15.3. Read file as one string (slurp)
- 15.4. Write to file
- 15.5. Write number to file
- 15.6. Append to file
- 15.7. Reading CSV file
- 15.8. Exercise: Sum of numbers in a file
- 15.9. Exercise: Count number of digitis
- 15.10. Exercise: ROT13 on file
- 15.11. Exercise: Selector with list of items from a file
- 15.12. TODO: Solution: Sum of numbers in a file
- 16. Maps
- 16.1. Map (hash, dictionary)
- 16.2. Empty Map
- 16.3. Empty Map with make
- 16.4. Map type defintion without container
- 16.5. Create map with data in it already
- 16.6. Delete Map element
- 16.7. Size of map (len)
- 16.8. Access map element (that does not exist)
- 16.9. Map element exists
- 16.10. Increment map elements
- 16.11. Iterate over elements of map
- 16.12. Keys of a map
- 16.13. Sort map
- 16.14. Sort map by value
- 16.15. map of slices
- 16.16. Mixed map
- 16.17. Exercise: count characters
- 16.18. Exercise: count characters - sort by frequency
- 16.19. Exercise: count words
- 16.20. Exercise: count words from file
- 16.21. Solution: count characters
- 16.22. Solution: count characters - sort by frequency
- 16.23. Solution: count words
- 16.24. Solution: count words from file
- 17. Testing
- 17.1. Testing in Go
- 17.2. Testing modules
- 17.3. Simple example with testing
- 17.4. Test with failure
- 17.5. Run selected test functions
- 17.6. Exercise: Test Anagram
- 17.7. Exercise: Test Calculator
- 17.8. Exercise: statistics
- 17.9. Solution: Test Anagram
- 17.10. Solution: Test Calculator
- 17.11. Solution: statistics
- 18. Struct
- 18.1. Struct and type
- 18.2. Struct with partial information (default values)
- 18.3. Slice of structs
- 18.4. Anonymous struct
- 18.5. Struct in a struct
- 18.6. composition via embedding instead of inheritance
- 18.7. Tags and introspection (reflect)
- 18.8. use cleanenv
- 18.9. methods
- 18.10. method of int
- 18.11. map keys method
- 18.12. method gets copy of struct
- 18.13. method pass pointer of struct
- 18.14. Exercise: read-csv-struct
- 18.15. Exercise: implement 2D point and move
- 18.16. Exercise: implement 3D point and move
- 18.17. Exercise: implement wc
- 18.18. Solution: implement wc
- 19. Logging
- 19.1. Simple Logging
- 19.2. Logging Fatal errors
- 19.3. Logging to a file - rewrite
- 19.4. Logging to a file - append
- 19.5. Logging the filename
- 19.6. Logging flags
- 19.7. Logging: Set Prefix
- 19.8. Turn logging on/off
- 19.9. TODO: log levels?
- 19.10. TODO: log function names
- 19.11. TODO: logrotation
- 20. Time
- 20.1. Monolitic vs Wallclock time
- 20.2. Time example
- 20.3. Nanoseconds
- 20.4. sleep and elapsed time
- 20.5. Time format
- 20.6. Date Arithmetic
- 21. Pointers
- 21.1. Integer assignment is copying (not pointer)
- 21.2. Pointer to integer
- 21.3. Array Pointer
- 21.4. Slice Pointer and copy slice
- 22. Panic (Exception handling)
- 22.1. Panic
- 22.2. We Panic
- 22.3. Turn error into panic when port is used
- 22.4. Panic after defer
- 22.5. Recover (and re-panic)
- 22.6. Recover from deep panic
- 22.7. Convert panic to returned error
- 22.8. Exercise: read several files
- 22.9. Solution: read several files
- 23. Goroutine
- 23.1. Without goroutine
- 23.2. goroutine example
- 23.3. goroutine not finished yet
- 23.4. goroutine no wait
- 23.5. Global waitgroup for goroutines
- 23.6. Wait for goroutines
- 23.7. Return data from goroutines
- 23.8. Counter - shared variable
- 23.9. Mutex
- 23.10. Channels
- 23.11. Channels are blocking
- 23.12. Channel capacity - buffered channel
- 23.13. Channel with loop
- 23.14. Pipeline map
- 23.15. Pipeline filter
- 23.16. TODO: Pipelines
- 23.17. Fibonacci goroutine
- 23.18. Loop from a channel
- 23.19. Select channel
- 23.20. Delayed start
- 23.21. Job pool
- 23.22. Check for race conditions
- 23.23. Stand alone web application
- 23.24. Maximum processes
- 23.25. Exercise: Collect data from urls
- 23.26. Exercise: Process multiple CSV files
- 23.27. Exercise: counter with lock
- 23.28. Exercise: Fibonacci in parallel
- 23.29. Solution: Collect data from urls
- 24. Functions 2
- 24.1. Numbers passed by reference
- 24.2. Array passed by value or by reference
- 24.3. TODO: pass by value, pass by reference
- 24.4. Variable declaration outside of functions
- 24.5. Exercise: Fibonacci series
- 24.6. Exercise: Permutations
- 24.7. Exercise: 100 doors
- 24.8. Solution: Fibonacci series
- 24.9. Solution: Fibonacci recursive
- 24.10. Solution: single counter
- 24.11. Solution: Permutations
- 24.12. Solution: 100 doors
- 24.13. TODO return array
- 25. Bitwise
- 25.1. bitwise operators
- 25.2. bitwise left shift
- 25.3. bitwise not
- 25.4. bitwise clear bit - AND NOT
- 26. Formatting
- 26.1. Println
- 26.2. Sprintln
- 26.3. Sprintf
- 26.4. Padding and alignment
- 27. Filesystem
- 27.1. os.stat information about a file or directory (file exists)
- 27.2. List Directory
- 27.3. Get Current Working Directory (cwd)
- 27.4. Create Temporary Directory
- 27.5. Traverse directory tree
- 27.6. Join parts of a directory or filepath
- 28. Regular Expressions (Regexes, Regexp)
- 28.1. Regexp
- 28.2. Regexp
- 28.3. Regex nomatch
- 28.4. Regex Markua include
- 28.5. Exercise: Parse ini file
- 28.6. Exercise: parse hours log file and give report
- 28.7. Solution: Parse ini file
- 28.8. Solution: parse hours log file and give report
- 29. Flow Control
- 29.1. if-statements
- 29.2. if, else, else if
- 29.3. if with initializer
- 29.4. Comparision Operators
- 29.5. Short circuit
- 29.6. switch
- 29.7. type switch
- 30. JSON
- 30.1. JSON round trip
- 31. Web client
- 31.1. http get request
- 31.2. URL parsing
- 31.3. TODO Checking links of a web site
- 31.4. TODO fteching youtube playlist
- 31.5. HTTP GET failure
- 32. HTTP Server
- 32.1. HTTP Hello World
- 32.2. HTTP Echo GET
- 32.3. HTTP Echo POST
- 32.4. text/template
- 32.5. text/template with map
- 32.6. text/template with struct
- 32.7. text/template in file
- 32.8. text/template if
- 32.9. text/template loop
- 32.10. html/template
- 32.11. HTTP Hello World templates
- 33. External programs
- 33.1. Find executable (which where)
- 33.2. Run external programs
- 33.3. Run external program in the background
- 33.4. Capture the outout of an external program
- 34. Distribution
- 34.1. Corss Compilation
- 34.2. Packages
- 34.3. Cross compile
- 34.4. Environment variables
- 34.5. Install packages
- 34.6. Include and distribute external files
- 34.7. go workspace layout
- 34.8. Directory of 3rd party packages
- 34.9. Semantic versioning
- 34.10. go install
- 35. Command line arguments (Flag)
- 35.1. Flag
- 35.2. Flags as pointers
- 35.3. Flags as variables
- 36. Appendix
- 36.1. Some advanced topics
- 36.2. Resources
- 36.3. Caller filename
- 36.4. os.Executable
- 36.5. Solution: rectangular (STDIN) Reader
- 36.6. Scan int
- 36.7. Function assignment
- 36.8. Overwriting built-in functions
- 36.9. TODO: stack
- 36.10. queue
- 36.11. Left over
- 36.12. Open Web browser
- 36.13. Unicode
- 36.14. golang create io.reader from string
- 36.15. Parse HTML Token by token
- 36.16. Parse HTML extract tags and attributes
- 37. Other
- 37.1. Print to STDERR or STDOUT
- 37.2. Companies using Golang in Israel