From a2d528b818cbd7f730b17ec81476ac2ebcc36b8f Mon Sep 17 00:00:00 2001 From: Teiva Harsanyi <934784+teivah@users.noreply.github.com> Date: Fri, 29 Sep 2023 01:39:48 +0200 Subject: [PATCH] Polishing --- docs/20-slice.md | 2 + docs/28-maps-memory-leaks.md | 2 + docs/56-concurrency-faster.md | 2 + docs/89-benchmarks.md | 2 + docs/9-generics.md | 2 + docs/98-profiling-execution-tracing.md | 2 + docs/book.md | 19 +- docs/chapter-1.md | 2 + docs/external.md | 5 + docs/jobs.md | 1 + docs/zh.md | 12 +- mkdocs.yml | 12 +- overrides/main.html | 4 + site/20-slice/index.html | 73 +- site/28-maps-memory-leaks/index.html | 73 +- site/404.html | 73 +- site/56-concurrency-faster/index.html | 73 +- site/89-benchmarks/index.html | 73 +- site/9-generics/index.html | 73 +- .../98-profiling-execution-tracing/index.html | 75 +- site/book/index.html | 93 +- site/chapter-1/index.html | 77 +- site/external/index.html | 77 +- site/index.html | 69 +- site/jobs/index.html | 73 +- site/search/search_index.json | 2 +- site/sitemap.xml | 24 +- site/sitemap.xml.gz | Bin 320 -> 320 bytes site/zh/index.html | 989 +----------------- 29 files changed, 497 insertions(+), 1487 deletions(-) diff --git a/docs/20-slice.md b/docs/20-slice.md index 560f23d..6967111 100644 --- a/docs/20-slice.md +++ b/docs/20-slice.md @@ -1,6 +1,8 @@ --- title: Not understanding slice length and capacity (#20) comments: true +hide: +- toc --- # Not understanding slice length and capacity diff --git a/docs/28-maps-memory-leaks.md b/docs/28-maps-memory-leaks.md index 2248acd..865c236 100644 --- a/docs/28-maps-memory-leaks.md +++ b/docs/28-maps-memory-leaks.md @@ -1,6 +1,8 @@ --- title: Maps and memory leaks (#28) comments: true +hide: +- toc --- # Maps and memory leaks diff --git a/docs/56-concurrency-faster.md b/docs/56-concurrency-faster.md index 8a2328d..2ba5018 100644 --- a/docs/56-concurrency-faster.md +++ b/docs/56-concurrency-faster.md @@ -1,6 +1,8 @@ --- title: Thinking concurrency is always faster (#56) comments: true +hide: +- toc --- # Thinking concurrency is always faster diff --git a/docs/89-benchmarks.md b/docs/89-benchmarks.md index dce0d76..d3e90fc 100644 --- a/docs/89-benchmarks.md +++ b/docs/89-benchmarks.md @@ -1,6 +1,8 @@ --- title: Writing inaccurate benchmarks (#89) comments: true +hide: +- toc --- # Writing inaccurate benchmarks diff --git a/docs/9-generics.md b/docs/9-generics.md index aee1fff..960f6a6 100644 --- a/docs/9-generics.md +++ b/docs/9-generics.md @@ -1,6 +1,8 @@ --- title: Being confused about when to use generics (#9) comments: true +hide: +- toc --- # Being confused about when to use generics diff --git a/docs/98-profiling-execution-tracing.md b/docs/98-profiling-execution-tracing.md index f0d3f4a..7cf98d3 100644 --- a/docs/98-profiling-execution-tracing.md +++ b/docs/98-profiling-execution-tracing.md @@ -1,6 +1,8 @@ --- title: Not using Go diagnostics tooling (#98) comments: true +hide: +- toc --- # Not using Go diagnostics tooling diff --git a/docs/book.md b/docs/book.md index 6bfa141..b0fc5b1 100644 --- a/docs/book.md +++ b/docs/book.md @@ -1,3 +1,8 @@ +--- +hide: +- toc +--- + # 100 Go Mistakes and How to Avoid Them Community space of 📖 _100 Go Mistakes and How to Avoid Them_, published by Manning in 2022. @@ -29,20 +34,14 @@ Read a summary of the 100 mistakes [here](https://100go.co). Not having this will be the **101st mistake** a Go programmer could make.
- ![](img/ratings-manning.png) ![](img/ratings-goodreads.png){width="300"} ![](img/ratings-amazon.png){width="300"} + ![](img/ratings-manning.png)
Manning, Goodreads, and Amazon reviews: 4.7/5 avg rating
## Where to Buy? -
- ![](img/cover-en.jpg){width="200"} - ![](img/cover-jp.jpg){width="200"} -
English and Japanese front covers
-
- * _100 Go Mistakes and How to Avoid Them_ (🇬🇧 edition: paper, digital, or audiobook) * [Manning](https://www.manning.com/books/100-go-mistakes-and-how-to-avoid-them) (make sure to use my personal discount code for -35%: `au35har`) * [O’Reilly](https://www.oreilly.com/library/view/100-go-mistakes/9781617299599/) @@ -51,6 +50,12 @@ Read a summary of the 100 mistakes [here](https://100go.co). * _Go言語100Tips 開発者にありがちな間違いへの対処法_ (🇯🇵 edition: paper or digital) * Amazon: [.co.jp](https://www.amazon.co.jp/exec/obidos/ASIN/4295017531/) +
+ ![](img/cover-en.jpg){width="200"} + ![](img/cover-jp.jpg){width="200"} +
English and Japanese covers
+
+ ## About the Author [Teiva Harsanyi](http://teivah.io) is a senior software engineer at Google. He has worked in various domains, including insurance, transportation, and safety-critical industries like air traffic management. He is passionate about Go and how to design and implement reliable systems. diff --git a/docs/chapter-1.md b/docs/chapter-1.md index f7b8547..0bd88e4 100644 --- a/docs/chapter-1.md +++ b/docs/chapter-1.md @@ -1,5 +1,7 @@ --- title: Read the First Chapter +hide: +- toc --- # Go: Simple to learn but hard to master diff --git a/docs/external.md b/docs/external.md index e0c0fb8..16f2424 100644 --- a/docs/external.md +++ b/docs/external.md @@ -1,3 +1,8 @@ +--- +hide: +- toc +--- + # External Resources ## English diff --git a/docs/jobs.md b/docs/jobs.md index 2a0d290..644a9ac 100644 --- a/docs/jobs.md +++ b/docs/jobs.md @@ -1,6 +1,7 @@ --- hide: - navigation + - toc --- # Go Jobs diff --git a/docs/zh.md b/docs/zh.md index 2edf7bf..3ddc139 100644 --- a/docs/zh.md +++ b/docs/zh.md @@ -39,7 +39,7 @@ comments: true 只有在需要接受或返回任意类型时,才使用 `any`,例如 `json.Marshal`。其他情况下,因为 `any` 不提供有意义的信息,可能会导致编译时问题,如允许调用者调用方法处理任意类型数据。 -### [困惑何时该用范型](https://teivah.medium.com/when-to-use-generics-in-go-36d49c1aeda) (#9) +### [困惑何时该用范型](https://100go.co/9-generics/) (#9) 使用泛型,可以通过类型参数分离具体的数据类型和行为,避免写很多重复度很高的代码。然而,不要过早地使用泛型、类型参数,只有在你看到真正需要时才使用。否则,它们会引入不必要的抽象和复杂性。 @@ -87,7 +87,7 @@ comments: true 在进行加法或减法时,将具有相似数量级的操作分成同一组以提高精度 (过早指数对齐丢失精度)。此外,在进行加法和减法之前,应先进行乘法和除法 (加减法误差会被乘除放大)。 -### [不理解slice的长度和容量](https://teivah.medium.com/slice-length-vs-capacity-in-go-af71a754b7d8) (#20) +### [不理解slice的长度和容量](https://100go.co/20-slice/) (#20) 理解slice的长度和容量的区别,是一个Go开发者的核心知识点之一。slice的长度指的是slice已经存储的元素的数量,而容量指的是slice当前底层开辟的数组最多能容纳的元素的数量。 @@ -121,7 +121,7 @@ comments: true 见 [#21](#inefficient-slice-initialization-21). -### [map和内存泄漏](https://teivah.medium.com/maps-and-memory-leaks-in-go-a85ebe6e7e69) (#28) +### [map和内存泄漏](https://100go.co/28-maps-memory-leaks/) (#28) 一个map的buckets占用的内存只会增长,不会缩减。因此,如果它导致了一些内存占用的问题,你需要尝试不同的选项来解决,比如重新创建一个map代替原来的(原来的map会被GC掉),或者map[keyType]valueType中的valueType使用指针代替长度固定的数组或者sliceHeader来缓解过多的内存占用。 @@ -251,7 +251,7 @@ Wrapping(包装)错误允许您标记错误、提供额外的上下文信息 理解并发(concurrency)、并行(parallelism)之间的本质区别是Go开发人员必须要掌握的。并发是关于结构设计上的,并行是关于具体执行上的。 -### [认为并发总是更快](https://teivah.medium.com/concurrency-isnt-always-faster-in-go-de325168907c) (#56) +### [认为并发总是更快](https://100go.co/56-concurrency-faster/) (#56) 要成为一名熟练的开发人员,您必须意识到并非所有场景下都是并发的方案更快。对于任务中的最小工作负载部分,对它们进行并行化处理并不一定就有明显收益或者比串行化方案更快。对串行化、并发方案进行benchmark测试,是验证假设的好办法。 @@ -441,7 +441,7 @@ Go 的上下文(context)也是 Go 并发编程的基石之一。上下文允 这个 `iotest` 包有助于编写 io.Reader 并测试应用程序是否能够容忍错误。 -### [不正确的基准测试](https://teivah.medium.com/how-to-write-accurate-benchmarks-in-go-4266d7dd1a95) (#89) +### [不正确的基准测试](https://100go.co/89-benchmarks/) (#89) * 不要重置或者暂停timer @@ -533,7 +533,7 @@ Go 的上下文(context)也是 Go 并发编程的基石之一。上下文允 使用快速路径的内联技术来更加有效地减少调用函数的摊销时间。 -### [不使用Go问题诊断工具](https://medium.com/@teivah/profiling-and-execution-tracing-in-go-a5e646970f5b) (#98) +### [不使用Go问题诊断工具](https://100go.co/98-profiling-execution-tracing/) (#98) 了解Go profilng工具、执行时tracer来辅助判断一个应用程序是否正常,以及列出需要优化的部分。 diff --git a/mkdocs.yml b/mkdocs.yml index 0c6c531..2991d97 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -16,6 +16,9 @@ theme: - search.share - search.suggest - content.code.copy + - navigation.expand + - navigation.instant + - navigation.sections palette: # Palette toggle for light mode - scheme: default @@ -23,12 +26,14 @@ theme: icon: material/brightness-7 name: Switch to dark mode primary: cyan + accent: pink # Palette toggle for dark mode - scheme: slate toggle: icon: material/brightness-4 name: Switch to light mode primary: blue grey + accent: blue repo_url: https://github.com/teivah/100-go-mistakes plugins: - search @@ -41,17 +46,15 @@ extra: provider: google property: G-HMY1HYDM93 alternate: - - name: English + - name: 🇬🇧 English link: / lang: en - - name: Chinese (Simplified) + - name: 🇨🇳 Chinese (Simplified) link: /zh/ lang: zh social: - icon: fontawesome/brands/twitter link: https://twitter.com/teivah - - icon: fontawesome/brands/medium - link: http://blog.teivah.io extra_css: - stylesheets/extra.css nav: @@ -68,7 +71,6 @@ nav: - 56-concurrency-faster.md - 89-benchmarks.md - 98-profiling-execution-tracing.md - - zh.md - ❤️ Go Jobs: - jobs.md markdown_extensions: diff --git a/overrides/main.html b/overrides/main.html index 92a5176..37cf47f 100644 --- a/overrides/main.html +++ b/overrides/main.html @@ -3,3 +3,7 @@ {% block htmltitle %} 100 Go Mistakes {% endblock %} + +{% block announce %} +This repo is open to Hacktoberfest! 🎉 If you want to participate, please have a look at the open issues. +{% endblock %} \ No newline at end of file diff --git a/site/20-slice/index.html b/site/20-slice/index.html index 71fd6ee..dea3dd3 100644 --- a/site/20-slice/index.html +++ b/site/20-slice/index.html @@ -112,7 +112,7 @@ - + @@ -131,6 +131,16 @@
+ +
@@ -172,7 +182,7 @@ - +