net/http 包的基本用法
· 阅读需 1 分钟
基本用法:
- 创建 HTTP 服务器
- 处理 HTTP 请求,POST、GET
- 定义路由和处理器函数
- 启动服务器监听端口
基本用法:
- 创建 HTTP 服务器
- 处理 HTTP 请求,POST、GET
- 定义路由和处理器函数
- 启动服务器监听端口
--since
语法YYYY-MM-DD
Month Day, Year
YYYY-MM-DD HH:mm:ss
N year/months/weeks/days/hours/minutes/seconds ago
yesterday/today
--until
--before
结合
--since
即 >=
--until
, 即 <
从今天开始,过去 1 个月的提交
git log --since="1 month ago"
一行显示
git log --since="2025-06-01" --until="2025-07-01" --oneline
自定义输出
# %h commit hash 的缩写
# %an 作者
# %ar 提交的相对时间
# %s 提交信息
git log --since="1 month ago" --pretty=format:"%h - %an, %ar : %s"
图形化显示
git log --since="1 month ago" --graph --oneline
自动检测并更新 docker image
version: "3"
services:
watchtower:
image: containrrr/watchtower
volumes:
- /var/run/docker.sock:/var/run/docker.sock
command: --interval 3600 # 每小时检查一次更新
async function createUser(user) {
if (!validateUserInput(user)) {
throw new Error('u105');
}
const rules = [/[a-z]{1,}/, /[A-Z]{1,}/, /[0-9]{1,}/, /\W{1,}/];
if (user.password.length >= 8 && rules.every((rule) => rule.test(user.password))) {
if (await userService.getUserByEmail(user.email)) {
throw new Error('u212');
}
} else {
throw new Error('u201');
}
user.password = await hashPassword(user.password);
return userService.create(user);
}
const err = {
userValidationFailed: 'u105',
userExists: 'u212',
invalidPassword: 'u201',
};
function isPasswordValid(password) {
const rules = [/[a-z]{1,}/, /[A-Z]{1,}/, /[0-9]{1,}/, /\W{1,}/];
return password.length >= 8 && rules.every((rule) => rule.test(password));
}
async function createUser(user) {
if (!validateUserInput(user)) {
throw new Error(err.userValidationFailed);
}
if (isPasswordValid(user.password)) {
if (await userService.getUserByEmail(user.email)) {
throw new Error(err.userExists);
}
} else {
throw new Error(err.invalidPassword);
}
user.password = await hashPassword(user.password);
return userService.create(user);
}
function throwError(error) {
throw new Error(error);
}
async function createUser(user) {
validateUserInput(user) || throwError(err.userValidationFailed);
isPasswordValid(user.password) || throwError(err.invalidPassword);
!(await userService.getUserByEmail(user.email)) || throwError(err.userExists);
user.password = await hashPassword(user.password);
return userService.create(user);
}
Name:名称,简明扼要的标题。
Tags:标签,分类
Context:背景,错误发生的具体环境或情境。
Problem:问题,对错误本身的描述。
Impacts:影响,可能导致的后果。
Lessons learned:经验总结,从这次错误中学到了什么。
Correction plan: 改进方案,今后如何避免重蹈覆辙。
Latest occurrence:最近发送,上次犯这个错误的时间。
Repetition: 重复次数,这个错误发送的概率。
saveBatch
批量新增优化rewriteBatchedStatements=true
InsertBatchSomeColumn