ultimate-go
ultimate-go copied to clipboard
This repo contains my notes on working with Go and computer systems.
Motivation
This repo contains my notes on work with Go and computer systems
Table of Contents
-
Language Specification
-
Syntax
- Variables: Zero value concept | Initialization | Const
- Constant: Initialization | iota
- Conversions: Conversion
Struct: Declare_Initialize | Name And Anonymous type Field | Field Function| Iterate Field Name And Value | Selector and Promoted | Method Set
- Struct Tags: Wiki | Code | Tag-Doc
- Pointer:
- Passing by value | Escape analysis | Stack space
Function: Initialization | argument | multiple returns | named return
- Build-in types: Built-in types
- statement: statement | if else | for | switch | select | go
-
Data Structures
- Enum: Enum
- Array: CPU Cache | TLB | Initialization | Iteration | Type array | Contiguous memory allocation
- Slice: Initialization | Length vs Capacity | Reference Type | Appending | Slice of Slice | Map | Reduce | Filter | Include | All|Any
- Map: Initialization | Iteration | Deleting | Finding | Restriction
- Channel: Declare | Iteration | Exit | send statements |receive operations
-
Decoupling
- Method:
- Value and Pointer Receiver Call | wiki
- Value and Pointer Semantics
- Methods are just functions | Function variable
- closures
- Interface:
- Declaring |Type assertions| Concrete type vs Interface type| Polymorphic function
- Embedding:
- Declaring fields, NOT Embedding
- Embedding type | Inner type promotion
- Embedded type and Interface
- Outer and inner type implementing the same Interface
- Exporting:
- Exported identifier
- Accessing a value of an unexported identifier
- Unexported fields from an exported struct
- Method:
-
Dependency management Go Modules
-
Error Handling
- Default error values
- Error variables | best practices
- Type as context
- Wrapping Errors
-
Context
- Store and retrieve values from a context
- WithCancel
- WithDeadline
- WithTimeout
-
-
Concurrency LearnConcurrency
- Goroutine
- asynchronous network IO
- Channel
- Guideline
- ping_pong
- multiplexing
- waitgroup
- mutex
- worker_pool
- Select
- Goroutine
-
Diagnostics Profiling
- Diagnostics Diagnostics
- Profiling code
- Stack Trace: Review
- GoLand Debug: GoLand Debug | blog
-
Testing
- Testing:
- Basic Unit Test
- Web Server
- Mock | Mock Server
- Fuzzing
- Testing:
-
Design Pattern Design Patterns | javatpoint
- SOLID: SOLID
- Creational
- Simple Factory: wiki | code | best practices
- *Abstract factory: wiki | code | best practices
- *Builder: wiki | code1 | code2 | best practices orm query build | best practices es query build
- Factory method: wiki | code | best practices
- *Object Pool Pattern: wiki | code | best practices bilibili redis pool
- *Prototype: wiki | code | best practices
- *Singleton: wiki | code | best practices
- Structual
- Behavioral
- *Chain of responsibility: wiki | code | best practices
- Command: todo wiki | code | best practices
- *Interpreter: todowiki | code | best practices
- *Iterator: wiki | code | best practices
- Mediator: todowiki | code | best practices
- Memento: todowiki | code | best practices
- Observer: todowiki | code | best practices
- State: todowiki | code | best practices
- *Strategy: wiki | code | best practices
- Template method : todowiki | code | best practices
- Visitor: todowiki | code | best practices
- Composition:
Guideline
- Conversion:
- Interface Conversions | Type Assertion
- Runtime Type Assertion
Algorithms Algorithms
- Conversion:
- Data Structures
- Graph algorithms
- shortest path:
- Dijkstra | (wiki)
- Sorting:
- Topological Sort | (wiki)
- Maths algorithms
- Binary GCD algorithm | (wiki)
- Closest pairs | (wiki)
- FastPower | (wiki)
- Fibonacci | (wiki)
- Fisher-Yates Shuffle-yates | (wiki)
- Erastothenes Sieve | (wiki)
- Extented GCD algorithm | (wiki)
- Karatsuba's Multiplication | (wiki)
- Newton's Squarenewton-sqrt | (wiki)
- Permutations Count
- Strassen's matrixstrassen | (wiki)
- Sorting algorithms
- Bubble Sort | (wiki)
- Heap Sort | (mit notes) | (wiki)
- Quick Sort | (wiki)
- Merge Sort | (mit notes) | (wiki)
- Insertion Sort(mit notes) | (wiki)
- Shell Sort | (wiki)
- Selection Sort | (wiki)
- Searching algorithms
- Binary Search | wiki
-
Crypto
-
databases
-
Awesome Go
- bazel_cpp
- bazel go
- config
- beego
- go-redis
- freecache
- localcache |best practices
- gorm
- iris
- kafkaSarama
- mapstructure
- grpc
- grpc mock
- zipkin
- websocket |echo | chat
- consul | register |grpc-resolver
-
Docs
- elasticsearch
- kafka
- rabbitmq
- kubernetes
-
Interview
- When is
defercalled?It was called according the consuming sequence of stack. That is to say, the first
deferclause will be invoked as the last. deferandpanicwhich is run first?First
defer, thenpanic.- Difference between
new()andmake()?For
newfunction, it returns pointer. It is used when initiate struct.Makeis mostly used when initiate slice, map and channel. - Can
append()receive pointer as parameter?No.
- go run order,

- Can global variable declared with short declaration?
No.
- Difference between passing value and passing pointer as parameter of function?
When passing value, it will create a new copy. For pointer, it will pass the value itself.
str := "hello", str[1] = 'a'Is the string gonna modified?No. Because the string is a constant.
- Can we assign nil to
string?No. But we can assign nil to
*string - If
mapandrangeis executed by sequence?No.
- If two slice object can be compared with
==?No.
- Is there a difference between new() and “regular” allocation?
No. &Vector{} , new(Vector) is the same, one thing to note: new() is the only way to get a pointer to an unnamed integer or other basic type. You can write "p := new(int)" but you can't write "p := &int{0}".
- When is