golang 各种数据类型转换

golang 各种数据类型转换 Conversions are expressions of the form T(x) where T is a type and x is an expression that can be converted to type T. string > duration 1 2 d, e := time.ParseDuration("-1h") d, e := time.ParseDuration("1000ms") array > slice 1 2 arr := [3]int{1,2,3} sli := arr[:] hex > int, big.Int 1 2 3 4 5 6 // int n,

go file

go file 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 if srcFile, err = os.Open(localPath); err != nil { logger.Errorf("failed to read src file: %v", err) return } defer srcFile.Close() fileInfo, err := srcFile.Stat() fileSize := fileInfo.Size() // file size os.PathSeparator file, _ := os.Getwd() log.Println("current path:", file) file, _ = exec.LookPath(os.Args[0]) log.Println("exec path:",

openssl basic

openssl basic 查看私钥长度 1 openssl rsa -in id_rsa.pem -text -noout get cert 1 openssl s_client -connect site.com:636 </dev/null 2>/dev/null | openssl x509 -outform PEM > site.pem import cert into ca certs 1 sudo keytool -importcert -noprompt -alias site-`date "+%Y%m%d%H%M%S"` -file ./site.pem -keystore /usr/java/latest/lib/security/cacerts -storepass changeit 查看证书信息 pem 1 2 openssl x509 -noout -text -in ca.crt openssl x509 -noout -text -in

emacs elpa

emacs elpa https://elpa.emacs-china.org/index-en.html 1 2 3 4 5 emacs ~/.emacs (setq package-archives '(("gnu" . "http://elpa.emacs-china.org/gnu/") ("melpa" . "http://elpa.emacs-china.org/melpa/"))) M-x list-packages Type M-x list-packages to open the package list. Press ‘i’ to mark for installation, ‘u’ to unmark, and ‘x’ to perform the installation. Press ‘RET’ to read more about installing and using each package. https://www.emacswiki.org/emacs/InstallingPackages

nginx basic, command

nginx basic, command 1 2 3 4 5 6 7 8 9 # Do not run, just test the configuration file. sudo nginx -t nginx -s signal # stop — fast shutdown # quit — graceful shutdown # reload — reloading the configuration file # reopen — reopening the log files almalinux install nginx 1 2 3 sudo dnf update -y sudo dnf install nginx -y sudo systemctl enable --now

linux cut

linux cut 1 2 3 4 cut -d ',' -f 3 # 截取前24个字符 cut -c-24 http://www.cnblogs.com/dong008259/archive/2011/12/09/2282679.html cut是一个选取命令,就是将一段数据经过分析,取出我们想要的。一般来说,选取信息通常是针对&q

Guava Multimap

Guava Multimap 在日常的开发工作中,我们有的时候需要构造像Map<K, List>或者Map<K, Set>这样比较复杂的集合类型的

dnscrypt

dnscrypt Server 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68

swap

swap 查看 swap 使用情况, 没有输出的话就是没有启用 swap 1 2 3 4 swapon free -m cat /proc/swaps vmstat 1 5 1 2 3 4 NAME TYPE SIZE USED PRIO /dev/vda2 partition 1.9G 1.5G -1 # PRIO, Priority # /dev/vda2 是安装操作系统时划分的磁盘分区, 也

go regex, 正则

go regex, 正则 1 2 3 4 5 6 nodes := []string{"foo.bar-000.x", "foo.t0.bar","foo.bar"} reg := regexp.MustCompile(`foo\.(.[^\.]*)\.{0,1}.*`) for _, v := range nodes { result := reg.FindSubmatch([]byte(v)) fmt.Println("output: ", string(result[1])) } [^a-zA-Z ]+, 匹配所有不是小写大写字母和空格的字符 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 . 匹配任

angular basic

angular basic install angular install nodejs @see nodejs basic install yarn http://blog.wiloon.com/?p=11228 install angular cli yarn global add @angular/cli yarn add angular-in-memory-web-api –dev ng config -g cli.packageManager yarn add yarn global bin to $PATH angular command 创建工作区 ng new project0 创建组件 ng generate component heroes 创建组件 简写 ng g c heroes ng generate component hero -it 创建s

linux history

linux history 1 2 cat ~/.bash_history 缓存 history -r 读取历史文件并将其内容添加到历史记录中,即重置文件里的内容到内存中.

golang struct/结构体

golang struct/结构体 1 2 3 4 5 6 7 //定义一个struct type Student struct { id int name string address string age int } 匿名结构体 1 2 3 4 5 6 7 8 //匿名结构 person := struct { Name string Age int

五线谱, 钢琴

五线谱, 钢琴 拍号 4/4: 4分音符为一拍,每一小节有4拍, 可以用C表示 6/8: 8分音符为一拍,每一小节有6拍 连音线 延音线 https://zhidao.baidu.com/question/1769827496564950660.html 连音线是圆滑线和延音线的总称,即

golang list

golang list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 package main import ( "container/list" "fmt" ) func main() { l := list.New() //创建一

yarn basic

yarn basic commands 1 2 3 yarn serve # 打印 缓存 目录/路径 yarn cache dir Yarn 是什么? “Yarn 是由 Facebook、Google、Exponent 和 Tilde 联合推出了一个新的 JS 包管理工具

rename

rename 重命名 rename 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #files copy-sys-log-01 copy-sys-log-02 rename copy-sys-log-0 copy-app-log-0 copy-sys-log-0* 7000 7001 7002 rename 700 node-700 700* node-7000 node-7001 node-7002 rename + 正则 1 rename 's/\d{4}-\d{2}-\d{2}-//' *.md 批量重命名 1 find . -name '*.md' -exec rename 's/\d{4}-\d{2}-\d{2}-//' {} \; http://www.cnblogs.com/longdouhzt/archive/2012/04/30/2477282.html http://blog.51cto.com/jiemian/1846951