Posts List

hugo markdown文章新窗口打开超链接

一、通过js修改链接a标签 target <script type="text/javascript"> function addaTarget(id) { var aTags = document.getElementById(id).getElementsByTagName("a"); for (i = 0; i < aTags.length; i++) { var aTags_item = aTags[i]; aTags_item.target = "_blank"; } } addaTarget("post-content-id"); </script> 二、通过Hugo Markdown Render Hooks 可在超链接添加title标签 [Text](https://www.gohugo.io "Title") 增加下面模板文件 layouts/_default/_markup/render-link.html <a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{

Golang 监听文件变化(非轮询)

Golang 监听文件变化(非轮询) 最近研究openresty(nginx+lua),由于这货热更有点麻烦,所以就写就用golang写了一个文件监听的程序,监听到配置文件或lua文件更改就重启

Golang正则查找与替换

Golang正则查找与替换 package main; import ( "regexp" "fmt" "strings" ) func main() { //1、过正则来判断字符串是否匹配 if ok, _ := regexp.Match("^[0-9a-zA-Z_]+$", []byte("hello")); ok { fmt.Println("ok"); } //上面的例子也可以通过MatchString实现 if ok, _ := regexp.MatchString("^[0-9a-zA-Z_]+$", "hello"); ok { fmt.Println("ok"); } //2、

Golang操作笔记

Golang 判断字符串中是否包含其他某字符 import ( "fmt" "strings" ) func main() { fmt.Println(strings.Contains("widuu", "wi")) //true fmt.Println(strings.Contains("wi", "widuu")) //false } Golang 判断字符串中是否包含 chars 中的任何一个字符 func main() { b := strings.ContainsAny("Hello,世界!

Git 代理设置

本地开启代理后,GIt也需要设置代理,才能正常通过代理网络 设置如下(可复制): git config --global http.proxy http://127.0.0.1:1087 git config --global https.proxy https://127.0.0.1:1080 git config --global http.proxy 'socks5://127.0.0.1:1080' git config --global https.proxy 'socks5://127.0.0.1:1080' 取消 git config --global --unset http.proxy git config --global --unset https.proxy