Gorm: 声明模型(1) 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2025/03/17/gorm-model-declaration/ 1. 数组字段 https://gorm.io/zh_CN/docs/models.html 如果表中有 slice 字段, 则需要使用 type 指定类型。 1 2 3 4 5 6 package dao type DemoTable struct { Users []string `gorm:"type:text[]"` // This is a slice of strings IDs []int `gorm:"type:int[]"` // This is a slice of integers } 2. 索引 https://gorm.io/zh_CN/docs/indexes.html 2.1 唯一作引 唯一索引有两种形式, uniqueIndex index:[name],unique : 自定义索引名字 1 2 3 4 5 type User struct { Name string `gorm:"index"` // 索引 Name4 string `gorm:"uniqueIndex"` // 唯一索引……
阅读全文
AI 加强版的命令行客户端 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2025/03/04/ai-powered-terminals/ 都 2025 年了, 谁还没有一个 AI 加强版的命令行客户端。 1. 神器 Warp warp 算的上一款真正意义上的 AI 客户端了, 可以直接通过 自然语言 (甚至不用关键字切换)处理工作。 除此外, 还能根据需求 推荐相关命令, 并执行, 还支持 输出结果的上下文分析, 直接……
阅读全文
Typescript NPM 制包/发包问题解析 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2025/03/01/intro-of-npm-package-publish/ NPM 发包 npm 发包必须要注册一个 npm registry 的账号。 包名全局唯一 访问 https://www.npmjs.com/ 并注册一个账号 本地登录 1 $ npm login 发布 1 $ npm publsh 包的定义 在 package.json 中管理 包的定义 1 2 3 4 5 6 7 8 9 10 11 { "name": "ioredis-client", // 包名 "version": "1.0.7", // 版本 "main": "dist/index.js", // 默认入口文件。 指定后, 可以直接使用包名。 "types":……
阅读全文
(6) 静态前端网站容器化 - 【源码解读】 使用 gin FS 模式为什么无限 301 重定向了? 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2025/02/09/gin-static-fs-301-redirect/ 为了解决 BrowserRouter 模式下的, History API Fallback 问题。 我们在后端服务器做了一些兼容配置。 (4) 静态前端容器化 - 单页面应用(SAP) History API Fallback - 刷新 404 但是由于 gin 对于 StaticFS() 和 FileFromFS() 两个方法的实现问题, 造成了无限 301……
阅读全文
(5) 静态前端网站容器化 - 容器篇 - 自定义 HTTP Server 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2025/02/09/static-sap-dockerize-customize-httpserve/ 众所周知, 我们在容器化 静态网站 的时候为了实现 一次编译, 处处运行 的目标, 在 index.html 中插入了一个变量 __CONFIG__, 在启动的时候进行替换为正式后端的地址。 可以参考 (2) Vue3 / React 静态网站项目容器化 - 实战案例 (3) 静……
阅读全文
(4) 静态前端容器化 - 单页面应用(SAP) History API Fallback - 刷新 404 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2025/02/09/static-sap-history-api-fallback-issue/ 当单页面(SAP)页面使用了路由之后(例如 React-Router), 刷新页面就可能造成 404 问题。 问题主要原因是出在 BrowserRouter, 例如 地址 http://localhost:3000/login BrowserRouter 依赖于浏览器的 History API 来管理路由。例……
阅读全文
(3) 静态前端网站容器化 - 容器篇 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2024/12/16/static-website-container-image/ 相关连接 (1) 静态前端网站容器化 - 理论篇 (2) Vue3 / React 静态网站项目容器化 - 实战案例 对于容器的选择, 其实没什么多数说的, 普通的 nginx 就可以了, 或者类似 caddy 这些都行。 如果由于某些权限问题, 选择了 nginxinc/nginx-unprivileged - docker-hub 则需要注意, /usr/share/nginx/html 权限归于 root 启动用……
阅读全文
Python Select Interpreter in Vscode 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2024/12/02/python-select-interpreter-in-vscode/ python 中提供了两种方式执行运行版本 选择默认 Python 版本 Mac Command + Shift + P -> Python: Select Interpreter 配置默认版本 打开 settings.json 1 "python.defaultInterpreterPath": "/usr/bin/python3", 或在 settings 中搜索 python default Interpreter Path 创建虚拟环境 .venv 或 .conda Mac Command + Shift + P -> Python: Create Environment 选择 .venv 或 .conda 管理虚拟环境 更多参考 VsCode 官方文档 Create Environment……
阅读全文
Python: 关于 Package 和 Module 快速入门 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/2024/11/29/python-package-module-quick-start/ 什么是 包 (Package) 如果一个目录中有 __init__.py , 那这个目录就是 包 Package 什么是 模块 (Module) xxx.py 文件就是模块 怎么引用自定义包 把 包路径 使用 sys.path.append(xxx) 添加后, 就可以使用 1 2 3 4 5 6 7 8 9 10 11 # import {Package} from x.Package import Module print(f"Module.Attribute") from x.Package.Module import Attribute print(f"{Attribute}") # 别名 from x.Package.Module import Attribute as attr print(f"{attr}") 不能使用 连续的 . 结构 1 2 import x.Package……
阅读全文
Docker Set Up Client Only 建议点击 查看原文 查看最新内容。 原文链接: https://typonotes.com/posts/PostDate/PostName/ 如果只想使用 docker / docker-compose 等命令工具控制远端服务上的 docker-engine。 MacOS 下载 docker-cli https://docs.docker.com/engine/install/binaries/#install-client-binaries-on-macos 1 wget -c https://download.docker.com/mac/static/stable/aarch64/docker-27.3.1.tgz 下载 docker-compose https://github.com/docker/compose/releases 1 wget -c https://github.com/docker/compose/releases/download/v2.30.3/docker-compose-darwin-aarch64 Usage 1 2 3 export DOCKER_HOST=ssh://remote-host docker ps……
阅读全文