Go 指南(二)
Go 指南流程控制
for.go
Go 只有一种循环结构:for 循环。
基本的 for 循环由三部分组成,它们用分号隔开:
初始化语句:在第一次迭代前执行
条件表达式:在每次迭代前求值
后置语句:在每次迭代的结尾执行
初始化语句通常为一句短变量声明,该变量声明仅在 for 语句的作用域中可见。
一旦条件表达式的布尔值为 false,循环迭代就会终止。
注意:和 C、Java、JavaScript 之类的语言不同,Go 的 for 语句后面的三个构成部分外没有小括号, 大括号 { } 则是必须的。
1234567891011package mainimport "fmt"func main() { sum := 0 for i := 0; i < 10; i++ { sum += i } fmt.Println(sum)}
初始化语句和后置语句是可选的。
1234567891011package mainimport "fmt"func main() { sum ...
基于Docker的Redis集群搭建
镜像版本redis:5.0.12
拉取镜像1docker pull redis:5.0.12
准备挂载路径12345678910111213141516mkdir -p /data/redis_63{79..81}/{conf,data}vim /data/redis_6379/conf/redis.conf bind 0.0.0.0 port 6379 daemonize no pidfile "/var/run/redis_6379.pid" logfile "" dir "./" masterauth redis_1.35 requirepass redis_1.35 appendonly yes cluster-enabled yes cluster-config-file nodes_6379.conf cluster-node-timeout 15000sed 's/6379/6380/g' /data/redis_6379/conf/redis.con ...
cpu各状态说明
CPU运行状态 解释user 进程执行用户态代码耗费的CPU时间。nice 在优先级高的用户级别执行时CPU占用率的百分比。system 内核执行系统调用所使用的CPU时间。idle CPU空闲并且系统没有未完成的磁盘I / O请求的时间百分比。iowait CPU等待I/O输入输出的时间irq CPU用于维护硬件中断所花费的时间百分比。softirq CPU用于服务软件中断所花费的时间百分比。steal 在虚拟化环境中运行的其他操作系统所花费的时间guest CPU用于运行虚拟处理器的时间百分比。dpc 服务延迟过程调用所花费的时间interrupt 服务硬件中断所花费的时间
文件打包传输命令
打包tar
-c --create create a new archive,创建一个新的包
-x --extract, --get extract files from an archive, 打开打包文件
-t --list list the contents of an archive,列出包的目录
-r --append append files to the end of an archive
-f --file=ARCHIVE use archive file or device ARCHIVE 指定打包文件名
-j --bzip2
-J --xz
-z --gzip
tar -cf etc.tar /etc #压缩/etc目录
tar -cvf etc.tar /etc #v,显示过程
tar -tf etc.tar #列出/etc目录的内容
touc ...
nginx与tomcat之间https通信配置方式
nginx与tomcat之间https通信配置方式123456789 <Engine name="Catalina" defaultHost="localhost" jvmRoute = "jvm-jspt1"> <Valve className="org.apache.catalina.valves.RemoteIpValve" remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto" protocolHeaderHttpsValue="https"/>需要注意; remoteIpHeader="X-Forwarded-For" protocolHeader="X-Forwarded-Proto& ...