diff --git a/.gitignore b/.gitignore index 79b5594..9007db7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ **/.DS_Store +Knowledge.textbundle \ No newline at end of file diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index a82cc9c..d01aff1 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,3 @@ The File format is in [MindNode](https://mindnode.com/) ## Preview - diff --git a/_coverpage.md b/_coverpage.md new file mode 100644 index 0000000..064aa5f --- /dev/null +++ b/_coverpage.md @@ -0,0 +1,12 @@ + + + + +# The IT things I learned + +> Never stop learning and digesting. + + + +[GitHub](https://github.com/wahyd4/knowledge-mind-mapping) +[Get Started](#knowledge-mind-mapping) \ No newline at end of file diff --git a/_sidebar.md b/_sidebar.md new file mode 100644 index 0000000..aef38f6 --- /dev/null +++ b/_sidebar.md @@ -0,0 +1,16 @@ + + +- [Home](/) +- [**Go**](categories/go.md) +- [Java](golang.md) +- [JavaScript](golang.md) +- [Ruby](golang.md) +- [Interview](golang.md) +- [Software Design](golang.md) +- [Message Queue](golang.md) +- [Database](golang.md) +- [Application](golang.md) +- [Web Scraping](golang.md) +- [Devops](golang.md) +- [Web](golang.md) +- [Success Team Work](golang.md) \ No newline at end of file diff --git a/categories/go.md b/categories/go.md new file mode 100644 index 0000000..6614a36 --- /dev/null +++ b/categories/go.md @@ -0,0 +1,160 @@ +## Language + +### pass pointer or value +- value: Variable must not be modified +- Variable is a large struct then prefer pointer +- Variable is a map or slice then prefer value +- Passing by value often is cheaper + +### struct + +- make + - make(T, args) -> T +- new + - new(T) -> *T +- a := T{} + +### Slice + +- Auto scale length + - new([]int) + - make([]int, 2, 5) + +### Go routine + +- you can run more goroutine vs thread +- go routine have a fater startup time than thread +- go routine come with built-in primitives to communicate safely by using channels + +### Closure + +### Channel + +- messages := make(chan string) + // _Send_ a value into a channel using the `channel <-` + go func() { messages <- "ping" }() + // channel. Here we'll receive the `"ping"` message + msg := <-messages + +- buffered channel + + - ch := make(chan Task, 3) + +### Sync + +- atomic +- Mutex + - sync.Mutex() + - mutex.Lock() + - mutx.Unlock() +- string literals + - \`aaa bbb ccc\` +- panic / recover + +## Frameworks + +### db + +- xorm +- gorm + +### web + +- beego +- mux +- gin +- go kit + - full stack micro service framework like spring boot + +### tools + +- profiler + - go-wrk(wrk) + - a http benchmark tool + - go-torch + - Stochastic flame graph profiler +- test + - github.com/stretchr/testify + +## Tips + +### slice + +- byte* array //actual data +- uintgo len +- uintgo cap + +### map + +- implement by hash table + +### Go has no generics + +- performance +- complexity +- If C++ and Java are about type hierarchies and the taxonomy of types, Go is about composition. +- How to solve + - use interface + - use type assertions + - use reflection + +### Modify item in range + +- use the array index instead of the value +```go + for _, e := range array { + e.field = "foo" + } + + for idx, _ := range array { + array[idx].field = "foo" + } +``` +### merge two array + +- a = append(a, b…) + - must add … to b, otherwise you can only add one item + +### error handling + +- error type assertion + - if serr, ok := err.(*json.SyntaxError); ok {} + +- better error handling + + - custom error type + - type appError struct { + Error error + Message string + Code int + } + + - concat error check + - if err1() != nil || err2() != nil {} + - some error constants + - errNotFound = errors.New("Item not found") + switch err { + case errNotFound: + } + +### date format + +- t := time.Now() + fmt.Println(t.String()) + fmt.Println(t.Format("2006-01-02 15:04:05")) + +- var _ InterfaceX = &InterfaceXImplementation{} + - make sure InterfaceX’s implementation works + +## commands + +### test + +- go test ./... + - run all tests in current directory and all of its subdirectories +- go test foo/... + - run all tests with import path prefixed with foo/: +- go test foo... + - run all tests import path prefixed with foo: +- go test ... + - run all tests in your $GOPATH: \ No newline at end of file diff --git a/cover.png b/cover.png new file mode 100644 index 0000000..930c764 Binary files /dev/null and b/cover.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..a6c38ea --- /dev/null +++ b/index.html @@ -0,0 +1,28 @@ + + + +
+ +