electron 解决socket端口被占用问题 启动socket服务,自动尝试可用接口
原理是本地写一个config.json,把初始端口放进去,每次启动electron的socket服务时如果发现端口被占用,就更新config.json里的端口号加1,并保存到config.json,然后退出并重启electron,直到找到可用的端口 {"port":1081} const { app, BrowserWindow, protocol, dialog } = require("electron");const path = require("path");const { Menu } = require("electron");const myMenu = require("./src/menu.js");const WebSocket = require("ws");const fs = require("fs");//wss通讯服务 let wss = {...
Electron Auto WebSocket Port Retry
Auto-increment and retry WebSocket server port in Electron when the current port is in use.
JS飞入飞出动画 加速动画 换入换出效果
JS飞入飞出动画 加速动画 换入换出效果 * @param elem {HTMLElement} 执行动画的HTML元素 * @param params {JSON} 动画执行过过程中需要修改的HTML属性 * @param duration {Number} 可选,动画执行时间,单位毫秒 * @param easing {String} 可选,动画执行的方式,缓入easeIn、缓出easeOut
JS Fly In Out Animation
Fly-in / fly-out JavaScript animation with easing implementation and demo.
Go Struct Field Reordering Optimization
Improve performance and reduce memory usage by reordering struct fields for better alignment.
Go排序结构体struct中字段提升性能,降低内存使用率
将第一个struct改写为第二种可以通过排序结构体struct中字段提升性能,降低内存使用率 type BadStruct struct { age uint8 IdCardNumber uint64 DateOfBirth uint16}type GoodStruct struct { age uint8 DateOfBirth uint16 IdCardNumber uint64}
go ioutil包1.16起弃用 使用io包代替
20 年 10 月份,Go 掌舵人 Russ Cox 已经有废弃 ioutil 包的提案[1],废弃原因是:io/ioutil, like most things with util in the name, has turned out to be a poorly defined and hard to understand collection of things. 后续的几次代码提交也证实了这一点,从 Go 1.16 开始会废弃 io/ioutil 包,相关的功能会挪到 io 包或 os 包 相关连接 https://github.com/go-critic/go-critic/issues/1019 例如 ioutil.NopCloser方法, 改为io.NopCloser方法即可