使用Go后端的家庭财务管理平台
Family Finance Management Platform built with Go.
- 用户账户系统(中英双语切换,默认中文)
- 支持创建个人或共享钱包,记录家庭每个人/集体收支流水,可选择基准货币
- 每一笔收支均可挂靠特定类别,同一钱包里的钱可划归多类归属,收支更有序
- 钱包余额可按类别分类,并支持手动调整余额时自动生成记录
- 支持多币种及汇率换算,允许负余额以便家庭活动等场景
-
安装并启动 MySQL,创建数据库与表:直接导入
init_db.sql -
运行环境变量(3条)写入
/etc/default/famoney并设置权限:sudo tee /etc/default/famoney >/dev/null <<'EOF' DB_USER=your_db_user_here DB_PASSWORD=your_db_password_here EXRATE_API=your_api_value_here EOF sudo chmod 600 /etc/default/famoney
DB_USER与DB_PASSWORD为MySQL数据库的用户名及密码。EXRATE_API为汇率公开数据平台的API,请访问 https://www.exchangerate-api.com/ 申请获取,每年有1500次免费访问次数,本平台的汇率需依赖此API获取。systemd 服务应包含
EnvironmentFile=/etc/default/famoney。
go mod tidy
go build访问 http://localhost:8295/famoney/ 查看页面。
此处Go后端本地监听端口,可在main.go中修改,可搜索并全局替换为您的偏好端口。
-
获取代码并编译
git clone https://your.repo/Famoney.git cd Famoney go build -
创建 systemd 服务
/etc/systemd/system/famoney.service[Unit] Description=Famoney service After=network.target [Service] ExecStart=/usr/local/bin/famoney WorkingDirectory=/var/www/Famoney EnvironmentFile=/etc/default/famoney Restart=always [Install] WantedBy=multi-user.target
将编译后的
famoney二进制复制到/usr/local/bin/,代码放到/var/www/Famoney。sudo systemctl daemon-reload sudo systemctl enable --now famoney -
配置 Nginx
/etc/nginx/sites-available/famoney.confserver { listen 80; server_name example.com; location /famoney/ { proxy_pass http://127.0.0.1:8295; proxy_set_header Host $host; } }
启用配置并重载:
sudo ln -s /etc/nginx/sites-available/famoney.conf /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginx
完成以上步骤后,通过 http://example.com/famoney/ 访问网站。