├── go.mod
├── hello
└── hello.go
├── goodbye
└── goodbye.go
├── app.go
├── .pre-commit-config.yaml
├── .gitignore
└── README.md
/go.mod:
--------------------------------------------------------------------------------
1 | module hello-go
2 |
3 | go 1.14
4 |
--------------------------------------------------------------------------------
/hello/hello.go:
--------------------------------------------------------------------------------
1 | package hello
2 |
3 | import (
4 | "fmt"
5 | )
6 |
7 | func SayHello() {
8 | fmt.Println("Hello golang!")
9 | }
10 |
--------------------------------------------------------------------------------
/goodbye/goodbye.go:
--------------------------------------------------------------------------------
1 | package goodbye
2 |
3 | import (
4 | "fmt"
5 | )
6 |
7 | func SayGoodbye() {
8 | fmt.Println("Goodbye golang!")
9 | }
10 |
--------------------------------------------------------------------------------
/app.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "hello-go/goodbye"
5 | "hello-go/hello"
6 | )
7 |
8 | func main() {
9 | hello.SayHello()
10 | goodbye.SayGoodbye()
11 | }
12 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pre-commit/pre-commit-hooks
3 | rev: v4.0.1
4 | hooks:
5 | - id: check-merge-conflict
6 | - id: check-yaml
7 | - id: end-of-file-fixer
8 | - id: trailing-whitespace
9 | args: [ --markdown-linebreak-ext=md ]
10 |
11 | - repo: local
12 | hooks:
13 | - id: go-fmt
14 | name: go fmt
15 | entry: gofmt -w -s --
16 | language: golang
17 | types: [ go ]
18 | - id: go-imports
19 | name: go imports
20 | entry: goimports --
21 | language: golang
22 | types: [ go ]
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | bin/
3 | pkg/
4 |
5 | # Dependency directories (remove the comment below to include it)
6 | vendor/
7 |
8 | ### JetBrains template
9 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
10 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
11 |
12 | # User-specific stuff
13 | .idea/**/workspace.xml
14 | .idea/**/tasks.xml
15 | .idea/**/usage.statistics.xml
16 | .idea/**/dictionaries
17 | .idea/**/shelf
18 |
19 | # Generated files
20 | .idea/**/contentModel.xml
21 |
22 | # Sensitive or high-churn files
23 | .idea/**/dataSources/
24 | .idea/**/dataSources.ids
25 | .idea/**/dataSources.local.xml
26 | .idea/**/sqlDataSources.xml
27 | .idea/**/dynamic.xml
28 | .idea/**/uiDesigner.xml
29 | .idea/**/dbnavigator.xml
30 |
31 | # Gradle
32 | .idea/**/gradle.xml
33 | .idea/**/libraries
34 |
35 | # Gradle and Maven with auto-import
36 | # When using Gradle or Maven with auto-import, you should exclude module files,
37 | # since they will be recreated, and may cause churn. Uncomment if using
38 | # auto-import.
39 | # .idea/artifacts
40 | # .idea/compiler.xml
41 | # .idea/modules.xml
42 | # .idea/*.iml
43 | # .idea/modules
44 | # *.iml
45 | # *.ipr
46 |
47 | # CMake
48 | cmake-build-*/
49 |
50 | # Mongo Explorer plugin
51 | .idea/**/mongoSettings.xml
52 |
53 | # File-based project format
54 | *.iws
55 |
56 | # IntelliJ
57 | out/
58 |
59 | # mpeltonen/sbt-idea plugin
60 | .idea_modules/
61 |
62 | # JIRA plugin
63 | atlassian-ide-plugin.xml
64 |
65 | # Cursive Clojure plugin
66 | .idea/replstate.xml
67 |
68 | # Crashlytics plugin (for Android Studio and IntelliJ)
69 | com_crashlytics_export_strings.xml
70 | crashlytics.properties
71 | crashlytics-build.properties
72 | fabric.properties
73 |
74 | # Editor-based Rest Client
75 | .idea/httpRequests
76 |
77 | # Android studio 3.1+ serialized cache file
78 | .idea/caches/build_file_checksums.ser
79 |
80 | ### Go template
81 | # Binaries for programs and plugins
82 | *.exe
83 | *.exe~
84 | *.dll
85 | *.so
86 | *.dylib
87 |
88 | # Test binary, built with `go test -c`
89 | *.test
90 |
91 | # Output of the go coverage tool, specifically when used with LiteIDE
92 | *.out
93 |
94 | # Dependency directories (remove the comment below to include it)
95 | # vendor/
96 |
97 | ### XilinxISE template
98 | # intermediate build files
99 | *.bgn
100 | *.bit
101 | *.bld
102 | *.cmd_log
103 | *.drc
104 | *.ll
105 | *.lso
106 | *.msd
107 | *.msk
108 | *.ncd
109 | *.ngc
110 | *.ngd
111 | *.ngr
112 | *.pad
113 | *.par
114 | *.pcf
115 | *.prj
116 | *.ptwx
117 | *.rbb
118 | *.rbd
119 | *.stx
120 | *.syr
121 | *.twr
122 | *.twx
123 | *.unroutes
124 | *.ut
125 | *.xpi
126 | *.xst
127 | *_bitgen.xwbt
128 | *_envsettings.html
129 | *_map.map
130 | *_map.mrp
131 | *_map.ngm
132 | *_map.xrpt
133 | *_ngdbuild.xrpt
134 | *_pad.csv
135 | *_pad.txt
136 | *_par.xrpt
137 | *_summary.html
138 | *_summary.xml
139 | *_usage.xml
140 | *_xst.xrpt
141 |
142 | # iMPACT generated files
143 | _impactbatch.log
144 | impact.xsl
145 | impact_impact.xwbt
146 | ise_impact.cmd
147 | webtalk_impact.xml
148 |
149 | # Core Generator generated files
150 | xaw2verilog.log
151 |
152 | # project-wide generated files
153 | *.gise
154 | par_usage_statistics.html
155 | usage_statistics_webtalk.html
156 | webtalk.log
157 | webtalk_pn.xml
158 |
159 | # generated folders
160 | iseconfig/
161 | xlnx_auto_0_xdb/
162 | xst/
163 | _ngo/
164 | _xmsgs/
165 |
166 | ### Example user template template
167 | ### Example user template
168 |
169 | # IntelliJ project files
170 | .idea
171 | *.iml
172 | out
173 | gen
174 |
175 | # Mac OS X files
176 | .DS_Store
177 |
178 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
179 | .glide/
180 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Go Learn
2 |
3 | 一个学习Go的仓库;
4 |
5 | ### 说明
6 |
7 | | **项目名称** | **更新日期** | **说明** |
8 | | ------------------------------------------------------------ | ------------ | ------------------------------------------------------------ |
9 | | [context](https://github.com/JasonkayZK/Go_Learn/tree/context) | 2021-01-22 | Go Context并发编程 |
10 | | [go-get](https://github.com/JasonkayZK/Go_Learn/tree/go-get) | 2021-01-22 | 使用go-get获取远程包的例子 |
11 | | [go-init-map](https://github.com/JasonkayZK/Go_Learn/tree/go-init-map) | 2021-01-22 | 展示init()函数在Go中的特性 |
12 | | [go-mod-demo](https://github.com/JasonkayZK/Go_Learn/tree/go-mod-demo) | 2021-01-22 | 一个go-mod的例子 |
13 | | [go-restful-xorm](https://github.com/JasonkayZK/Go_Learn/tree/go-restful-xorm) | 2021-01-22 | 使用[Gin-Gonic](https://github.com/gin-gonic/gin)、[XORM](https://github.com/go-xorm/xorm)和MySQL构建RESTful API例子 |
14 | | [golang-project-layout](https://github.com/JasonkayZK/Go_Learn/tree/golang-project-layout) | 2021-01-22 | Google官方的Go项目标准模板 |
15 | | [graphql](https://github.com/JasonkayZK/Go_Learn/tree/graphql) | 2021-01-22 | 使用Go + MySQL构建的GraphQL API |
16 | | [grpc-demo](https://github.com/JasonkayZK/Go_Learn/tree/grpc-demo) | 2021-01-22 | 一个gRPC例子 |
17 | | [grpc-sql-demo](https://github.com/JasonkayZK/Go_Learn/tree/grpc-sql-demo) | 2021-01-22 | 一个gRPC和MySQL结合的例子 |
18 | | [nil](https://github.com/JasonkayZK/Go_Learn/tree/nil) | 2021-01-22 | 谈谈Go中的Nil,文章[《在Golang中使用nil调用方法》](https://jasonkayzk.github.io/2020/09/23/%E5%9C%A8Golang%E4%B8%AD%E4%BD%BF%E7%94%A8nil%E8%B0%83%E7%94%A8%E6%96%B9%E6%B3%95/)源码 |
19 | | [prime](https://github.com/JasonkayZK/Go_Learn/tree/prime) | 2021-01-22 | 文章[《Golang并发素数筛-并发真的会快吗?》](https://jasonkayzk.github.io/2020/06/25/golang%E5%B9%B6%E5%8F%91%E7%B4%A0%E6%95%B0%E7%AD%9B-%E5%B9%B6%E5%8F%91%E7%9C%9F%E7%9A%84%E4%BC%9A%E5%BF%AB%E5%90%97%EF%BC%9F/)源码 |
20 | | [progress-bar](https://github.com/JasonkayZK/Go_Learn/tree/progress-bar) | 2021-01-22 | 文章[《Golang中的进度条使用》](https://jasonkayzk.github.io/2020/09/29/Golang中的进度条使用/)源码 |
21 | | [protobuf_grpc_demo](https://github.com/JasonkayZK/Go_Learn/tree/protobuf_grpc_demo) | 2021-01-22 | Protobuf + gRPC使用例子 |
22 | | [slice](https://github.com/JasonkayZK/Go_Learn/tree/slice) | 2021-01-22 | 文章[《Golang中Slice底层实现》](https://jasonkayzk.github.io/2020/10/04/%E3%80%90%E8%BD%AC%E3%80%91Golang%E4%B8%ADSlice%E5%BA%95%E5%B1%82%E5%AE%9E%E7%8E%B0/)源码 |
23 | | [websocket](https://github.com/JasonkayZK/Go_Learn/tree/websocket) | 2021-01-22 | Go中使用WebSocket例子
文章[《使用golang构建简单的websocket应用》](https://jasonkayzk.github.io/2020/10/28/使用golang构建简单的websocket应用/)源码 |
24 | | [id-validator-demo](https://github.com/JasonkayZK/Go_Learn/tree/id-validator-demo) | 2021-02-14 | Go的中国身份证号校验库[guanguans/id-validator](https://github.com/guanguans/id-validator)示例代码
文章[《Go的中国身份证号校验库》](https://jasonkayzk.github.io/2021/02/14/Go的中国身份证号校验库/)源码 |
25 | | [go-mysql-server-demo](https://github.com/JasonkayZK/Go_Learn/tree/go-mysql-server-demo) | 2021-02-15 | [go-mysql-server](https://github.com/dolthub/go-mysql-server)使用案例
文章[《使用纯Go实现的MySQL数据库》](https://jasonkayzk.github.io/2021/02/14/使用纯Go实现的MySQL数据库/)源码 |
26 | | [sse](https://github.com/JasonkayZK/Go_Learn/tree/sse) | 2021-03-05 | Go中使用SSE(服务端事件推送)例子
文章[《使用Go实现服务端事件推送SSE》](https://jasonkayzk.github.io/2021/03/05/使用Go实现服务端事件推送SSE/)源码 |
27 | | [goleak-demo](https://github.com/JasonkayZK/Go_Learn/tree/goleak-demo) | 2021-04-21 | Go中使用[uber-go/goleak](https://github.com/uber-go/goleak)进行Goroutine泄露检测的例子;
文章[《使用Uber开源的goleak库进行goroutine泄露检测》](https://jasonkayzk.github.io/2021/04/21/使用Uber开源的goleak库进行goroutine泄露检测/)源码 |
28 | | [go-elk-demo](https://github.com/JasonkayZK/Go_Learn/tree/go-elk-demo) | 2021-05-16 | Go中集成ELK的例子;
文章[《在Go中集成ELK服务》](https://jasonkayzk.github.io/2021/05/16/在Go中集成ELK服务/)源码 |
29 | | [easegress-demo](https://github.com/JasonkayZK/Go_Learn/tree/easegress-demo) | 2021-06-13 | 一个展示流量编排系统[easegress](https://github.com/megaease/easegress)基本使用的例子;
文章[《流量编排系统Easegress初探》](https://jasonkayzk.github.io/2021/06/13/流量编排系统Easegress初探/)源码 |
30 | | [distributed-id-generator-mysql](https://github.com/JasonkayZK/Go_Learn/tree/distributed-id-generator-mysql) | 2021-06-20 | 一个仅使用MySQL实现高性能分布式ID生成器的例子;
文章[《在Go中仅使用MySQL实现高性能分布式ID生成器》](https://jasonkayzk.github.io/2021/06/20/在Go中仅使用MySQL实现高性能分布式ID生成器/)源码 |
31 | | [map-reduce](https://github.com/JasonkayZK/Go_Learn/tree/map-reduce) | 2021-06-27 | MIT 6.824 Lab-1 MapReduce 实现;
文章 [《mit-6-824-lab1-MapReduce总结》](https://jasonkayzk.github.io/2022/10/08/mit-6-824-lab1-MapReduce总结/) |
32 | | [raft](https://github.com/JasonkayZK/Go_Learn/tree/raft)
**Not Finihed Yet!** | 2021-06-27 | |
33 | | [receiver](https://github.com/JasonkayZK/Go_Learn/tree/receiver) | 2021-06-28 | 深入探讨了Go中方法实现的值接收器和引用接收器以及他们和Interface的联系;
文章[《一文看懂Go方法中的值接收器和引用接收器》](https://jasonkayzk.github.io/2021/06/28/一文看懂Go方法中的值接收器和引用接收器/)源码 |
34 | | [go-v1.17-rc-generic](https://github.com/JasonkayZK/Go_Learn/tree/go-v1.17-rc-generic) | 2021-07-19 | 在Docker中体验Golang的泛型
文章[《在Docker中体验Go1-17中的泛型》](https://jasonkayzk.github.io/2021/07/05/在Docker中体验Go1-17中的泛型/)源码 |
35 | | [add-panic-log](https://github.com/JasonkayZK/Go_Learn/tree/add-panic-log) | 2021-09-26 | 为Panic后的Goroutine获取堆栈信息
文章[《在Golang发生Panic后打印出堆栈信息》](https://jasonkayzk.github.io/2021/09/26/%E5%9C%A8Golang%E5%8F%91%E7%94%9FPanic%E5%90%8E%E6%89%93%E5%8D%B0%E5%87%BA%E5%A0%86%E6%A0%88%E4%BF%A1%E6%81%AF/)源码 |
36 | | [goroutine-limit](https://github.com/JasonkayZK/Go_Learn/tree/goroutine-limit) | 2021-10-22 | 记录一些多个异步任务限制开启Goroutine数量的方法
文章[《控制Goroutine数量的方法》](https://jasonkayzk.github.io/2021/10/22/控制Goroutine数量的方法/)源码 |
37 | | [go-memory-model](https://github.com/JasonkayZK/Go_Learn/tree/go-memory-model) | 2022-10-27 | 官方文档:[《The Go Memory Model》](https://go.dev/ref/mem) 案例;
文章翻译:[《【翻译】Go内存模型》](https://jasonkayzk.github.io/2022/10/26/【翻译】Go内存模型/) |
38 | | | | |
39 | | | | |
40 |
--------------------------------------------------------------------------------