rust 计算运行耗时代码模板

rust 计算运行耗时代码模板

fn main() { use std::time::Instant; let now = Instant::now(); //计算耗时 //===================================================== //===================================================== //计算耗时 let duration = now.elapsed(); let s = duration.as_secs(); let mut ms = durat...

Rust 2023-03-03 AM 1153℃ 0条
rust url 编码解码

rust url 编码解码

use urlencoding::decode; use urlencoding::encode; fn main() { let encoded = encode("https://docs.rs/urlencoding/2.1.0/urlencoding/"); println!("编码后:{}", encoded); let decoded = decode(&encoded).expect("UTF-8"); println!("解码后:{}", decod...

Rust 2023-03-03 AM 1169℃ 0条
C++ Windows锁屏+息屏

C++ Windows锁屏+息屏

#include <Windows.h> #pragma comment(linker,"/subsystem:\"Windows\" /entry:\"main\"") int main() { while (true) { if ((GetAsyncKeyState(VK_LWIN) & 0x8000) && (GetAsyncKeyState('O') & 0x8000)) { LockWorkStati...

C/C++ 2023-03-01 PM 1047℃ 0条
js过滤特殊字符

js过滤特殊字符

// 过滤所有特殊字符 var stripscript = function(s) { var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?↵\r\n]"); var rs = ""; for (var i = 0; i < s.length; i++) { rs = rs + s.substr(i, 1).replace(pattern, '');...

前端 2023-02-25 PM 1012℃ 0条
goland 实现 http post

goland 实现 http post

package main import ( "fmt" "strings" "io/ioutil" "net/http" ) func httpPost() { resp, err := http.Post("http://www.xxxx.com/api/httpdclient2/","application/x-www-form-urlencoded", strings.NewReader("id=test&am...

Goland 2023-02-23 PM 1307℃ 0条
linux goland 配置国内镜像

linux goland 配置国内镜像

linux 用户按一下操作# 控制台中输入一下命令 $ go env -w GO111MODULE=on $ go env -w GOPROXY=https://goproxy.cn,direct # 查看go所有相关配置 $ go env # 修改 ~/.profile $ echo "export GO111MODULE=on" >> ~/.profile $ echo "export GOPROXY=https://goproxy.cn" >> ~/.profile # 重启配置, 如果是在vscode中下载辅助工具失...

Goland 2023-02-23 PM 1435℃ 0条
golang引用第三方包的报错:no required module provides package

golang引用第三方包的报错:no required module provides package

关于golang第三方包的引用报错:no required module provides package : go.mod file not found in current directory or any parent directory;需要倒入包:go get github.com/denisenkom/go-mssqldb go get github.com/mattn/go-adodb 全部无反应,着手去分析问题到底出在哪里?命令:go env 先排除 go env 里面:GO111MODULE (我的是GO111MODULE="on",导致下载失败)执行:go env ...

Goland 2023-02-23 PM 1324℃ 0条
goland 下载安装

goland 下载安装

官方地址:https://golang.google.cn/doc/install根据不同的系统进行下载。二、下面演示在linux系统下安装2.1 删除 /usr/local/go 目录, 根据官方说法,如果之前有安装过go,那么需要将该位置的go目录删除掉$ rm -rf /usr/local/go 2.2 解压并安装切换到 golang.tar.gz 存放目录, 已经在跟目录就执行 cd Downloads/$ cd /Download 解压golang到 /usr/local 下$ sudo tar -C /usr/local -xzf go1.14.3.linux-amd64.t...

Goland 2023-02-23 PM 1233℃ 0条
go 延时触发

go 延时触发

package main import ( "time" ) func main() { println(`开始延时`) // 延迟:时间 * 秒(单位) time.Sleep(5 * time.Second) // 延迟:时间 * 分钟(单位) time.Sleep(1 * time.Minute) // 延迟:时间 * 小时(单位) time.Sleep(1 * time.Hour) println(`延时结束`) }

Goland 2023-02-22 PM 1582℃ 0条
go string 转 16进制

go string 转 16进制

package main import ( "encoding/hex" ) func main() { // 转换的用的 byte数据 byte_data := []byte(`测试数据`) // 将 byte 装换为 16进制的字符串 hex_string_data := hex.EncodeToString(byte_data) // byte 转 16进制 的结果 println("字符串转16进制:"+hex_string_data) /* ====== 分割线 ====...

Goland 2023-02-22 PM 1351℃ 0条
linux debain 宝塔 找不到命令reboot和shutdown

linux debain 宝塔 找不到命令reboot和shutdown

debain linux 找不到命令reboot和shutdown问题解决方案whereis reboot # 找到reboot的文件路径 whereis shutdown # 找到shutdown的文件路径 添加到环境变量里面,nano /etc/profile,添加下面两行export PATH=$PATH:/usr/sbin/reboot export PATH=$PATH:/usr/sbin/shutdown 生效profile命令 ,source /etc/profile好了,已经可以使用shutdown和reboot命令了。转载来源:https://blog.csdn.ne...

linux 2023-02-08 AM 1755℃ 0条