Blog
Blog copied to clipboard
h2O's Blog
kibana server is not ready yet ================================ ### 场景 在本地安装了 `kibana`,配置连接服务器A上的 `Elasticsearch`,结果一直报 `kibana server is not ready yet` ### 方案 需要手动删除 `kibana` 相关的索引 登录服务器A ```bash $ curl -X DELETE http://localhost:9200/.kibana*...
zip 包解压乱码 ============== ### 场景 使用 `golang` `zip` 包解压时,文件名含有中文会出现乱码. ### 原因 因为压缩包是在 `windows` 平台压缩的,压缩软件 `winrar` 会使用本地编码方式进行压缩,所以含有中文的文件名是 `gbk` 格式的, 而 `golang` 字符串是使用 `utf-8` 格式,从而出现乱码. ### 解决 通过标识位识别 `gbk` 编码,若是则转换为 `utf-8` >...
pprof ====== ### 基本使用 查看堆栈调用信息 ```bash $ go tool pprof http://localhost:6060/debug/pprof/heap ``` 查看协程信息 ```bash $ go tool pprof http://localhost:6060/debug/pprof/goroutine ``` 查看30s内的 CPU 信息 ```bash $ go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30 ```...
nginx 转发 redis ================== ### 场景 本地开发,需要连接测试环境的 `redis`,但 `redis` 是内网的,不对外网开放. ### 方案 利用 `nginx` 进行反向代理,把请求转发到内网的 `redis` 上. 找到测试环境的一台 `nginx`,配置反向代理. 修改 `nginx.conf` ``` http { ... } # 注意跟 http 同级...
slice 的问题 ============= ### 场景 ```golang package main import "fmt" type cities []string func main() { Nepal := cities{"Kathmandu", "Pokhara", "Lumbini"} Nepal.add() Nepal.print() } func (c cities) print() { for...
Docker v2ray 客户端 ==================== ### 场景 `Arch Linux` 环境使用 `Docker` 搭建 `v2ray` 客户端 ### 方案 先拉取 `v2ray` 镜像 ```bash $ docker pull v2fly/v2fly-core ``` 配置文件 `config.json` ``` { "inbounds": [...
获取图片尺寸大小问题 ===================== ### 场景 `Golang` 使用 `Gin` 框架,获取上传图片大小的时候,报 `image: unknown format` ### 方案 摘录部分代码如下 ```golang func uploadOpcategoryImage(c *bm.Context) { ... file, header, err := c.Request.FormFile("file") if err != nil {...
nohup python 脚本,重定向输出,日志内容为空 =========================================== 在服务器,开启了一个`守护进程`,执行 `python` 脚本,并且输出重定向到日志记录 ``` $ nohup python xxx.py > log & ``` 执行一段时间,查看日志 ``` $ tail -f log ``` 发现, 内容为空. 脚本里有用到 `sys.stdout.write()` 和 `print()` 输出的,但是日志并没有记录到内容....
mysql 8.0 重置 root 密码 ========================= ### 场景 `mysql 8.0` 安装之后,忘记了 `root` 密码,需要重置. ### 方案 编辑 `my.cnf` ``` $ vi /etc/my.cnf ``` 在 `[mysqld]` 下添加 `skip-grant-tables` ``` [mysqld] skip-grant-tables ```...
vim-go no ParseGoHandle for file ================================= ### 场景 项目使用 `govendor` 管理的,并且不在 `GOPATH` 下,使用 `vim-go` 的 `gd` 报错:`vim-go: no ParseGoHandle for file`. ### 原因 主要跟 `go` 的版本有关. 系统 `go` 的版本为 ```bash...