golang pprof 更多详细内容 package mainimport ( "log" "net/http" "net/http/pprof" "strings")func main() { mux := http.NewServeMux() pathPrefix := "/d/pprof/" mux.HandleFunc(pathPrefix, func(w http.ResponseWriter,...
ubuntu禁止ping操作(ICMP) 原来ping是可以禁止的,方法一、令ubuntu不响应pingecho 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all令Ubuntu响应pingecho0 > /proc/sys/net/ipv4/icmp_echo_ignore_all方法二、通过修改/etc/sysctl.conf文件即可实现,具体操作如下:...
部署 使用 acme.sh 给 Nginx 安装 Let’ s Encrypt 提供的免费 SSL 证书 原文传送最近 Apple 在强推 SSL 了,非 SSL 的网络请求无法通过审核,于是发现有好多的朋友都在给网站配置 HTTPS,同时他们也遇到了好多坑。其实有更简单的方式,使用Let's Encrypt,关于这个,这里就不多讲了,之前有人介绍过:https://ruby-china.org/topics/28471 https://ruby-china.org/topics/2...
golang http.FileServer 遇到的坑 上次写了一个2行实现一个静态服务器的 文章今天群里有个哥们是这么写居然返回的是404 见鬼了嘛?? http.handle("/js", http.FileServer(http.Dir("js")) http.ListenAndServe("8080", nil)大概的意思就是绑定 路由为 js 的时候访问这个js 文件夹 看了一下确实代码上面没什么毛病。但是路径怎么...
鼠标连点器 按照后台参数 单点 和 记录鼠标位置-多点 源码: package mainimport ( "fmt" "os" "strconv" "time" "github.com/go-vgo/robotgo")type point [2]intvar ( run = false mousePointList []point...
扫码登录 简单实现 简单原理是 服务器生成唯一的 key 附带到login 上用户扫描 二维码 并且访问服务器 服务器反馈登录 状态前端 页面 每隔一段时间扫描 服务器 当前的key是否扫描, 然后后续操作代码:package mainimport ( "fmt" "io" "math/rand" "net/http" "time" . "github.com/soekchl/.
Linux 密钥登录设置【转】 1. 制作密钥对首先在服务器上制作密钥对。首先用密码登录到你打算使用密钥登录的账户,然后执行以下命令:[root@host ~]$ ssh-keygen <== 建立密钥对Generating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa): <== 按 Ent...
MySQL 5.6 my.cnf配置优化 原地址[client]port = 3306 socket = /var/lib/mysql/mysql.sock[mysql]#这个配置段设置启动MySQL服务的条件;在这种情况下,no-auto-rehash确保这个服务启动得比较快。no-auto-rehash[mysqld]user = mysql port = 3306 socket = /var/lib/my
golang 简单的登录操作 http 主函数 main.go// testHtmlLogin project main.gopackage mainimport ( "fmt" "io/ioutil" "net/http" "os" . "github.com/soekchl/myUtils")var ( change = make(map[string][]byte))func init() {
golang 下载图片 想用golang下载图片,因为golang和其他语言相比较不用在复制那么多其他的文件。package mainimport ( "bytes" "fmt" "io" "io/ioutil" "net/http" "os" "strings")func getImg(url string) (n int64, err error) { path := strin
golang 中 锁的错误的用法会导致死锁。 package mainimport ( "sync" "time" . "github.com/soekchl/myUtils")var mux sync.RWMutexfunc tt() { Notice() mux.Lock() // 3 Notice() defer mux.Unlock() time.Sleep(time.Second * 5)}f
Bit 数组 // An IntSet is a set of small non-negative integers.// Its zero value represents the empty set.type IntSet struct { words []uint64}// Has reports whether the set contains the non-negative value
golang if-else 和 switch-fallthrough 比较 经过比较 if 时间更快!package mainimport ( "fmt" "math/rand" "time")func main() { n := 100000000 st := time.Now() test1(n) fmt.Println(time.Since(st)) st = time.Now() test2(n) fmt.Print
golang websocket 服务器 package mainimport ( "fmt" "log" "net/http" "github.com/soekchl/websocket")func main() { fmt.Println("Start app") http.Handle("/", websocket.Handler(Echo)) if err := http.ListenAndServe("
golang 真正的高并发用法 查找素数 在原作者的代码上 附上了一些注释方便看懂package mainimport ( "fmt")func main() { sieve()}func generate(ch chan<- int) { for i := 2; ; i++ { ch <- i // Send 'i' to channel 'ch'. }}func filter(src <-c
Golang 协程控制关闭 部分代码参考:https://zhuanlan.zhihu.com/p/26695984 这边文章的的package mainimport ( "context" "fmt" "time")func main() { ctx := context.Background() ctx, cancel := context.WithCancel(ctx) go P
Windows 安装 解压版本 MySql 1、首先去下载mysql 安装包https://dev.mysql.com/downloads/mysql/选择适合自己系统的版本2、添加path目录D:\mysql\bin添加到path里3、增加my.ini进入到数据库目录(D:\mysql) 创建 my.ini 文档填写以下内容注意替换 basedir 和 datadir,替换称自己的目录[...