Golang
2020-06-26
1. 环境配置与基础语法
- 目标:搭建开发环境,掌握基本语法和编程逻辑。
- 内容:
- 安装 Go 版本(推荐 Go 1.21+)及 IDE(如 VS Code + Go 插件、IntelliJ IDEA)。
- 变量与数据类型(整型、浮点型、布尔型、字符串、数组、切片、字典)。
- 运算符(算术、关系、逻辑、位运算)。
- 流程控制(
if-else
、for
、switch
、goto
)。
- 函数与方法(函数定义、参数传递、返回值、闭包)。
- 练习:
- 编写计算器、斐波那契数列生成器。
- 实现一个简易的 Todo List 管理工具。
2. 面向对象与结构体
- 目标:理解 Golang 的 OOP 模型。
- 内容:
- 结构体(
struct
)的定义与初始化。
- 方法(Method)的绑定(值接收者 vs 指针接收者)。
- 接口(
interface
)与类型断言。
- 组合(Composition)代替继承。
- 练习:
- 设计一个动物 kingdom,包含不同动物的行为(如
Dog
吠叫、Bird
飞翔)。
- 实现一个简单的电商商品库存管理系统。
3. 并发与 Goroutine
- 目标:掌握 Golang 的并发编程模型。
- 内容:
- Goroutine 的启动与停止(
go func()
)。
- Channel 的使用(阻塞、非阻塞、缓冲区)。
select
语句实现多路复用。
sync.Mutex
和 atomic
包(锁与原子操作)。
- 练习:
- 实现一个多线程的 Web 服务器,处理并发请求。
- 模拟生产者-消费者问题,使用 Channel 通信。
4. 标准库实战
- 目标:熟悉 Golang 核心库,快速开发实际应用。
- 内容:
- 网络编程:
net/http
(REST API)、net/url
(URL 解析)。
- 数据处理:
encoding/json
/xml
(序列化/反序列化)、sort
/math
(常用算法)。
- 文件 I/O:
os
/path/filepath
(文件操作)、io/ioutil
(批量读写)。
- 模板引擎:
html/template
(生成动态 HTML)。
- 项目:
- 构建一个 RESTful API(用户管理、文章发布)。
- 开发一个命令行工具(如文件压缩/解压、天气查询)。
5. 微服务与框架
- 目标:掌握企业级开发模式与流行框架。
- 内容:
- 微服务架构(服务拆分、API 网关、配置中心)。
- 使用框架:
Gin
(轻量级 HTTP 框架)、Echo
、Beego
。
- 分布式工具:
etcd
(键值存储)、Consul
(服务发现)。
- 容器化与 Docker(部署 Go 应用)。
- 项目:
- 设计一个电商系统,包含用户服务、订单服务、支付服务。
- 实现一个实时聊天室(WebSocket + Goroutine)。
6. 数据库与 ORM
- 目标:连接数据库并高效操作。
- 内容:
- SQL 数据库驱动(
database/sql
+ PostgreSQL/MySQL)。
- ORM 工具:
GORM
、sqlx
。
- NoSQL 支持(
MongoDB
+ mgo
包)。
- 项目:
- 开发一个博客系统(支持 MySQL 存储、标签分类)。
- 实现一个用户登录注册系统(JWT 认证 + Redis 会话)。
7. 工程化实践
8. 性能与调优
- 目标:提升代码性能与稳定性。
- 内容:
- 性能分析工具:
pprof
、trace
。
- 优化技巧:减少内存分配、利用缓存、并发优化。
- 错误处理与日志(
log
包、zap
日志库)。
- 实战:
- 分析高并发场景下的性能瓶颈(如百万级请求处理)。
- 重构代码,优化响应时间与资源占用。
Swift
2020-06-25
ObjectiveC
2020-06-24
Linux 日志
2020-06-23
查看这个进程打开了哪写文件
-> % ps -ef | grep rsyslogd | grep -Fv grep
syslog 1068 1 0 1月06 ? 00:00:03 /usr/sbin/rsyslogd -n -iNONE
-> % sudo ls -l /proc/1068/fd
总计 0
lr-x------ 1 root root 64 1月 8 16:54 0 -> /dev/null
l-wx------ 1 root root 64 1月 8 16:54 1 -> /dev/null
l-wx------ 1 root root 64 1月 8 16:54 10 -> /var/log/kern.log
l-wx------ 1 root root 64 1月 8 16:54 11 -> /var/log/auth.log
l-wx------ 1 root root 64 1月 8 16:54 2 -> /dev/null
lrwx------ 1 root root 64 1月 6 09:46 3 -> 'socket:[13299]'
lr-x------ 1 root root 64 1月 8 16:54 4 -> /dev/urandom
lrwx------ 1 root root 64 1月 8 16:54 5 -> 'socket:[27825]'
lrwx------ 1 root root 64 1月 8 16:54 6 -> 'socket:[27831]'
lr-x------ 1 root root 64 1月 8 16:54 7 -> /proc/kmsg
lrwx------ 1 root root 64 1月 8 16:54 8 -> 'socket:[22468]'
l-wx------ 1 root root 64 1月 8 16:54 9 -> /var/log/syslog
查看哪些进程打开了这个文件
-> % sudo find /proc/*/fd -ls | grep /var/log/syslog
2551982 0 l-wx------ 1 root root 64 1月 8 16:50 /proc/1068/fd/9 -> /var/log/syslog
-> % ps -fq 1068
UID PID PPID C STIME TTY TIME CMD
syslog 1068 1 0 1月06 ? 00:00:03 /usr/sbin/rsyslogd -n -iNONE
b2a
2020-06-21
uu 编码是加州大学伯克利分校 1980 年为在邮件中传输二进制文件而设计的一种 B2T(Binary-To-Text)/ B2A(Binary-To-Ascii)编码。
九十年代,MIME 被设计出来并成为国际标准之后,uu 编码就正式退出了历史舞台。
uu 代表 Unix-to-Unix Copy,表示将一个文件从一个 Unix 系统传输到另一个 Unix 系统。
Git
2020-06-12
搜索提交信息
git log --grep=fix: --oneline --after='2018-07-01' --author=markjour
搜索历史文件
git grep -C3 sign_position $(git rev-list --all)
搜索 diff 内容
git log -G'前置'
git log -G'前置' -p | grep '前置' -C5
git log -G'前置' --oneline --name-status
-S<string> --pickaxe-regex
和 -G<regex>
作用相近,
不过 -S
只会列出搜索内容增删的相关信息,也就是所在行修改了,但是搜索内容没有变化的会忽略
终端 在线服务
2020-06-07
https://github.com/chubin/wttr.in

curl wttr.in/wuhan
curl wttr.in/wuhan?lang=zh
curl wttr.in/jiangxia?lang=zh
# 指定日期
curl wttr.in/jiangxia@2020-06-07?lang=zh
View options:
0 # only current weather
1 # current weather + today's forecast
2 # current weather + today's + tomorrow's forecast
A # ignore User-Agent and force ANSI output format (terminal)
F # do not show the "Follow" line
n # narrow version (only day and night)
q # quiet version (no "Weather report" text)
Q # superquiet version (no "Weather report", no city name)
T # switch terminal sequences off (no colors)
指定 view:
# 只看今天的天气
# 不显示颜色
curl "wttr.in/jiangxia?0T&lang=zh"
Python GUI
2020-05-29
gooey
可以快速实现命令行 GUI 化。
Windows
2020-05-27
- 虚拟内存相关
pagefile.sys
:Windows 的交换(SWAP)文件。默认在 C 盘根目录,和内存一样大,可以在“高级系统设置”中更改其位置和大小。
hiberfil.sys
:休眠模式系统状态转储文件。一般也会有几个 G。
swapfile.sys
:Win10 引入,作用和 pagefile.sys 相同,但他的大小可以自动调整。
desktop.ini
:文件夹配置文件(隐藏文件),用于自定义文件夹的外观和行为。
thumbs.db
:缩略图缓存文件(隐藏文件),用于加快文件夹中图像文件的显示速度。
ntuser.dat
:用户配置文件(隐藏文件),包含了用户的注册表设置和个人偏好。
boot.ini
:启动配置文件,用于指定启动选项和操作系统位置。
CentOS Docker
2020-05-24
# sudo yum remove docker \
# docker-client \
# docker-client-latest \
# docker-common \
# docker-latest \
# docker-latest-logrotate \
# docker-logrotate \
# docker-engine
# 检查是否有旧的安装
yum list installed | grep docker
sudo yum remove ...
sudo yum install -y yum-utils
# 使用国内镜像
# sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum list docker-ce --showduplicates | sort -r
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
参考:https://docs.docker.com/engine/install/centos/