main
🆕 Add macOS application packaging support with custom Dock icon integration and build documentation.
♻️ Refactor main.go by extracting window configuration and environment variable handling into dedicated files.
🆕 Add macOS application packaging support with custom Dock icon integration and build documentation.
🆕 Add macOS application packaging support with custom Dock icon integration and build documentation.
🆕 Add macOS application packaging support with custom Dock icon integration and build documentation.
🆕 Add macOS application packaging support with custom Dock icon integration and build documentation.
🆕 Add macOS application packaging support with custom Dock icon integration and build documentation.
♻️ Refactor main.go by extracting window configuration and environment variable handling into dedicated files.
secure-editor-go
Secure Editor in golang
go mod tidy
go build
打包为 macOS 应用(让 Dock 显示 LOGO)
在 macOS 上,独立的命令行二进制在 Dock 中只会显示通用图标,app.SetIcon / window.SetIcon 无法改变 Dock 图标。要让 Dock 显示 logo.jpeg,需要将程序打包成 .app 应用包并附带 .icns 图标:
./build.sh # 编译并生成 secure-editor-go.app(含由 logo.jpeg 转换的 logo.icns)
./build.sh --binary-only # 仅编译裸二进制
运行(仍以命令行参数方式调用包内可执行文件):
./secure-editor-go.app/Contents/MacOS/secure-editor-go <file> aes-256-gcm <key> <nonce>
build.sh 使用 macOS 自带的 sips 与 iconutil 把 logo.jpeg 生成多尺寸的 logo.icns,再按 Info.plist 组装 .app 包。重新打包后若 Dock 图标未刷新,可执行:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f secure-editor-go.app
killall Dock
功能特性
- AES-256-GCM 加解密:以
aes-256-gcm算法解密文件内容并在编辑器中展示,保存时重新加密写回(保留原文件权限位)。 - 只读模式:通过
READONLY=true环境变量启用,此时编辑区只读且保留灰色背景,不显示保存按钮。 - 退出码语义:
0:点击 Save 成功保存后退出。2:关闭但不保存(点击 Exit 或关闭窗口)。
- 编辑区背景:可编辑时编辑区使用白色背景;只读时保留灰色背景。
- 窗口大小记忆:窗口尺寸在关闭时记录到
~/.cache/secure-editor-go-config.json,下次启动自动恢复。若记录的尺寸大于桌面可用区域,则自动缩小到不超出桌面,避免遮挡。 - 等宽(程序员)字体:启用后编辑区使用 Fyne 内置的等宽字体,便于查看代码与对齐。取值来源(环境变量优先,文件兜底,值需
trim):- 环境变量
TINY_ENCRYPT_ENABLE_FIXED_PITCH - 文件
~/.config/envs/TINY_ENCRYPT_ENABLE_FIXED_PITCH - 接受的值(不区分大小写):
true、on、yes、1;其余值视为关闭。
- 环境变量
用法
./secure-editor-go <fileName> aes-256-gcm <keyHex> <nonceHex>
./secure-editor-go version
keyHex:32 字节(64 位十六进制)密钥。nonceHex:12 字节(24 位十六进制)nonce。
示例:
# 普通编辑
TINY_ENCRYPT_ENABLE_FIXED_PITCH=1 ./secure-editor-go note.txt aes-256-gcm <key> <nonce>
# 只读查看
READONLY=true ./secure-editor-go note.txt aes-256-gcm <key> <nonce>
Description
Languages
Go
78.4%
Shell
21.6%