news 2026/5/7 20:34:32

工作日志- 不定期更新

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
工作日志- 不定期更新

1. protobuf中使用import引用其他proto文件,生成后在go语言的go modules中import 包名报错问题。

public.proto文件

//protoc --go_out=plugins=grpc:. public.proto syntax = "proto3"; package public; option go_package = "self/game-service/msg/public"; message AwardItem { int32 prop_id = 1; int64 prop_num = 2; }

third_s.proto 文件

syntax = "proto3"; package third; import "public.proto"; option go_package = "self/game-service/msg/third"; message ThirdTakeCornucopiaBonusResp { int32 code = 1; string message = 2; int32 take_cnt = 3; int32 take_cnt_max = 4; repeated public.AwardItem awards = 5; }

生成后,指定的go_package 就是我们go 代码中import的包名:

// Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.33.0 // protoc v5.26.0 // source: third_s.proto package third import ( protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" public "self/game-service/msg/public" sync "sync" ) // 其他代码 .....

由于import public "self/game-service/msg/public"在我们代码里面是能正常识别的,所以改动go_package即可,改动后生成:
.\protoc.exe --go_out=. --go-grpc_out=. *.proto
会在当前目录下生成:
./self/game-service/msg/public/public.pb.go
./self/game-service/msg/third_s/third_s.pb.go

然后拷贝生成后的文件到项目代码目录即可正常参加编译
xcopy .\self\game-service\msg\* ..\game-server\msg\ /e /y /h /r /q

2. Windows安装构建golang protobuf + grpc 环境记录

1)下载protoc编译器。 直接上github.com下载,
https://github.com/protocolbuffers/protobuf/tags
下载后解压,拷贝到指定目录,或设置环境变量path指向protoc目录下bin
cmd命令行执行 protoc -v 查看版本,可以识别命令表示成功。
2)## 安装 protoc-gen-go 插件
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
3)## 安装 protoc-gen-go-grpc 插件
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
4)写一个proto文件测试。
protoc --go_out=. --go-grpc_out=. ./test.proto
5)安装完成后,应该会有两个文件(可执行文件exe)在环境变量GOPATH指向位置的bin/目录下
protoc-gen-go-grpc.exe
protoc-gen-go.exe
如果没有需要去对应目录执行
go install .

如,我没有protoc-gen-go-grpc.exe,于是切换目录到
C:\Users\Administrator\go\pkg\mod\google.golang.org\grpc\cmd\protoc-gen-go-grpc@v1.3.0
在此目录打开cmd命令行,执行go install .

3. MySQL 以表T,创建新表T_xxx

# 创建T_tmp, 包含T的字段,索引等,使用LIKE create table IF NOT EXISTS T_tmp like T # 创建T_tmp1, 从表T复制字段,索引,数据。 create table T_tmp1 AS select * from T;

4. Linux(Ubuntu)系统安装Jenkins后执行shell脚本权限问题,更改root用户启动。

安装方式,sudo apt-get install

修改配置:
(1) vim /etc/default/jenkins,修改如下两行,保存退出

JENKINS_USER=$NAME JENKINS_USER=root #JENKINS_GROUP=$NAME JENKINS_GROUP=root

(2) 修改相关目录的用户组

chown -R root:root /var/lib/jenkins chown -R root:root /var/log/jenkins chown -R root:root /var/cache/jenkins

(3) 重启。systermctl restart jenkins.service
本以为以上修改就够了,而且搜索到的大部分文章信息都只是如此,但我一直启动失败,exited status = 1,于是继续解决这个问题,有了下面的步骤。
(4) 使用systemd功能(systemctl是systemd的其中一个命令)来启动,systemd相关的配置文件

/usr/lib/systemd/system 存放各类service服务 /lib/systemd/system/ 存放各类service服务 /etc/systemd/system/ 添加开机自启后,服务会被链接到此目录下

于是我在上面的这几个目录中,又找到了jenkins.service这个启动配置,修改其中

User=root # User=jenkins Group=root # Group=jenkins

修改后,再次重启jenkins,systemctl restart jenkins.service,失败,提示如下:

Warning: The unit file, source configuration file or drop-ins of jenkins.service changed on disk. Run 'systemctl daemon-reload' to reload units. Job for jenkins.service failed because the control process exited with error code. See "systemctl status jenkins.service" and "journalctl -xeu jenkins.service" for details.

可以看到,磁盘上的启动配置修改了,需要重新加载,systemctl daemon-reload
重新加载后,再次重启jenkins,成功了。
ps -aux | grep jenkins 查看已经是root用户启动了

5 记录nginx配置下载服务器时,点击txt文件时,总是打开文件,不是下载

一开始的解决方案是添加特定头
add_header Content-Disposition "attachment";

但是,似乎不不行,点击目录下后缀为txt的文件,依然是在浏览器预览,点击后缀是log文件则是下载,对比后发现:

txt文件点击后,响应头content-type是text/plain
log文件点击后,响应头content-type响应头是application/octet-stream
于是把目录下所有的文件,响应头强制设置为application/octet-stream
原本,点击文件时会根据mime.types中的后缀设置content-type,所以在下载目录下需要重置

types {} default_type application/octet-stream;

以下是整个配置文件,记录参考。

server { listen 8001; server_name xxxxx; charset utf-8; error_log /var/log/nginx/fs/error.log; access_log /var/log/nginx/fs/acess.log; # 配置图片预览区域,该目录下的图片,点击在浏览器预览 location /images { root /opt/web/www/files; autoindex on; expires 30d; location ~* \.(jpg|jpeg|jfif)$ { add_header Content-Type "image/jpeg"; } location ~* \.(png)$ { add_header Content-Type "image/png"; } } # 设置文件下载区域,该目录下的文件,点击为默认下载 #location ~ ^/downloads/.+ { location /downloads { root /opt/web/www/files; autoindex on; # 索引 autoindex_exact_size on; # 显示文件大小 autoindex_localtime on; # 显示文件时间 expires 30d; # 设置文件扩展名匹配的type为空,默认是mime.types 设定的,然后在强制默认content-type 为 stream types {} default_type application/octet-stream; #if (!-d $request_filename) { # add_header Content-Disposition "attachment"; # force downloads #} #add_header Content-Disposition "attachment"; # force downloads } #location / { # root /opt/web/www/files; # autoindex on; # 索引 # autoindex_exact_size on; # 显示文件大小 # autoindex_localtime on; # 显示文件时间 #} }

6. nuxt3 pnpm install 后报错pinia缺失问题

Cannot resolve module "pinia/dist/pinia.mjs" (from: xxx, xxx\node_modules\@pinia\nuxt\dist\module.mjs)

解决办法 ,执行下面命令安装依赖:

npm install pinia @pinia/nuxt @nuxtjs/composition-api --legacy-peer-deps

7. nuxt3项目打包(pnpm build)后,运行 node ./output/server/index.mjs 浏览器输入 http://localhost:300, 报错 500 internal error
解决办法:在nuxt.confit.ts 中指定build 依赖

// 其他配置项目 build: { transpile: [/echarts/, 'tslib'], },

8. systemctl 启动配置(参考)

cat /usr/lib/systemd/system/etcd.service ###---------------------------------------------- [Unit] Description=EtcdServer After=network.target After=network-online.target Wants=network-online.target [Service] Type=notify WorkingDirectory=/data/app/etcd/ # User=etcd ExecStart=/data/app/etcd/etcd --config-file=/data/app/etcd/etcd.yml Restart=on-failure LimitNOFILE=65536 [Install] WantedBy=multi-user.target ###----------------------------------------------- # 使用命令启动etcd systemctl start etcd systemctl stop etcd systemctl restart etcd systemctl status etcd

9. Linux 系统查看磁盘占用,和哪一个文件夹占用最大

[root@ecs-seren-test ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 4.0M 0 4.0M 0% /dev tmpfs 3.7G 0 3.7G 0% /dev/shm tmpfs 1.5G 142M 1.4G 10% /run /dev/vda1 50G 50G 0 100% / /dev/vdb1 196G 1016M 185G 1% /data overlay 50G 50G 0 100% /var/lib/docker/rootfs/overlayfs/4b099d5a1abbb3653a9b1822cc53e04d165fee0343935a4a97c252f08bb0efdb overlay 50G 50G 0 100% /var/lib/docker/rootfs/overlayfs/128619b9413d8def71ad57cca739e5c9dbc3e15014f88cc3e98c1adc1091c946 overlay 50G 50G 0 100% /var/lib/docker/rootfs/overlayfs/13bf23459adb618ebdcfb5e12b6bbcc98b7e1cf5c0f1464ee365eba0ae0b6c56 [root@ecs-seren-test ~]# sudo du -sh /var/lib/* 2>/dev/null | sort -rh | head -20 45G /var/lib/docker 2.4G /var/lib/containerd 91M /var/lib/rpm 20M /var/lib/selinux 4.3M /var/lib/dnf 1.3M /var/lib/sss 236K /var/lib/cloud 208K /var/lib/systemd 68K /var/lib/authselect 44K /var/lib/alternatives 20K /var/lib/NetworkManager 16K /var/lib/tpm2-tss 8.0K /var/lib/rsyslog 8.0K /var/lib/rpm-state 8.0K /var/lib/logrotate 4.0K /var/lib/private 4.0K /var/lib/os-prober
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/7 20:34:11

HomeSpan入门教程:10分钟创建你的第一个HomeKit智能灯泡

HomeSpan入门教程:10分钟创建你的第一个HomeKit智能灯泡 【免费下载链接】HomeSpan HomeKit Library for the Arduino-ESP32 项目地址: https://gitcode.com/gh_mirrors/ho/HomeSpan HomeSpan是一款专为Arduino-ESP32设计的HomeKit库,它能帮助开发…

作者头像 李华
网站建设 2026/5/7 20:30:43

独立开发者如何通过Taotoken实现个人项目的低成本AI赋能

独立开发者如何通过Taotoken实现个人项目的低成本AI赋能 对于独立开发者、学生或小型项目团队而言,为应用添加智能交互功能常常面临两个现实挑战:一是直接接入主流大模型API的门槛与成本,二是面对众多模型时如何快速进行技术选型与实验。Tao…

作者头像 李华
网站建设 2026/5/7 20:28:24

Open UI5 源代码解析之1359:ListCardConfig.js

源代码仓库: https://github.com/SAP/openui5 源代码位置:src\sap.ui.integration\src\sap\ui\integration\designtime\cardEditor\config\ListCardConfig.js ListCardConfig.js 详细分析 文件定位与总体判断 ListCardConfig.js 位于 sap.ui.integration 模块下的 desig…

作者头像 李华
网站建设 2026/5/7 20:27:47

python系列【仅供参考】:JSON和JSON5的区别

JSON和JSON5的区别 JSON和JSON5的区别 JSON (JavaScript Object Notation) 特点 示例 JSON5 特点 示例 JSON vs JSON5 的对比 使用场景 总结 JSON和JSON5的区别 在鸿蒙系统 (HarmonyOS)开发中,JSON和JSON5是两种用于数据交换的格式。虽然它们有相似的用途,但在语法和特性上…

作者头像 李华
网站建设 2026/5/7 20:26:32

【PB案例学习笔记】-36PB连接SQLite数据库

写在前面 这是PB案例学习笔记系列文章的第33篇,该系列文章适合具有一定PB基础的读者。 通过一个个由浅入深的编程实战案例学习,提高编程技巧,以保证小伙伴们能应付公司的各种开发需求。 文章中设计到的源码,小凡都上传到了gite…

作者头像 李华
网站建设 2026/5/7 20:25:34

开源ChatGPT WebUI:自托管部署、核心功能与安全实践全解析

1. 项目概述:一个开源ChatGPT WebUI的诞生与价值最近在GitHub上看到一个名为“HemulGM/ChatGPT”的项目,点进去一看,发现这是一个基于Web的ChatGPT用户界面。作为一个长期关注AI应用落地的开发者,我立刻来了兴趣。这不仅仅是一个简…

作者头像 李华