go-runtime之pprof子包

elf.go

1
2
3
// elfBuildID returns the GNU build ID of the named ELF binary,
// without introducing a dependency on debug/elf and its dependencies.
func elfBuildID(file string) (string, error)

返回ELF二进制文件的GNU build ID

阅读更多

go-runtime之debug子包

garbage.go

  1. gc 状态
    1
    2
    3
    4
    5
    6
    7
    8
    9
    // gc状态集包含了最近的gc信息
    type GCStats struct {
    LastGC time.Time // 上次gc时间
    NumGC int64 // gc次数
    PauseTotal time.Duration // 所有gc的总暂停时间
    Pause []time.Duration // gc暂时时间历史记录,最近的在最前
    PauseEnd []time.Time // gc暂停结束时间记录,最近的在最前
    PauseQuantiles []time.Duration //
    }

阅读更多

go-runtime之cgo子包

asm_{$GOARCH}.s

1
2
3
4
5
6
7
// Called by C code generated by cmd/cgo.
// func crosscall2(fn func(a unsafe.Pointer, n int32, ctxt uintptr), a unsafe.Pointer, n int32, ctxt uintptr)
// Saves C callee-saved registers and calls fn with three arguments.
#ifndef GOOS_windows
TEXT crosscall2(SB),NOSPLIT,$0x50-0 /* keeps stack pointer 32-byte aligned */
#else
TEXT crosscall2(SB),NOSPLIT,$0x110-0 /* also need to save xmm6 - xmm15 */

参考 asm_amd64.s
翻译一下: 被cmd/cgo生成的C代码crosscall2函数调用.C代码会保存在寄存器中幷被调用.
从名字上看:大概是跨语言调用

阅读更多

go-runtime包

go runtime子包结构(v1.11)

  • cgo
  • debug
  • internal
    • atomic 大概是一些汇编代码和声明/定义了原子操作(不同平台的支持不一样)
    • sys 定义了不同系统的参数值
  • msan
  • pprof
  • race
    • 追踪基础
  • testdata
  • trace

阅读更多

定时任务 crontab

crontab

  1. 以下内容转载自 https://www.cnblogs.com/intval/p/5763929.html
  2. 主要是为了纪念犯了2次的错误,也就是下文的使用注意事项. 在执行性定时脚本的时候有时使用到其他命令要source xx_profile.

阅读更多

一些好用的东西

golang包

阅读更多

go-命令

go命令

翻译一遍^_^

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
build       compile packages and dependencies
clean remove object files
doc show documentation for package or symbol
env print Go environment information
fix run go tool fix on packages
fmt run gofmt on package sources
generate generate Go files by processing source
get download and install packages and dependencies
install compile and install packages and dependencies
list list packages
run compile and run Go program
test test packages
tool run specified go tool
version print Go version
vet run go tool vet on packages

// Additional help topics:
c calling between Go and C
buildmode description of build modes
filetype file types
gopath GOPATH environment variable
importpath import path syntax
packages description of package lists
testflag description of testing flags
testfunc description of testing functions

阅读更多

pyenv 安装

pyenv 安装过程

  1. 参考: https://github.com/pyenv/pyenv
  2. 参考: https://github.com/pyenv/pyenv/wiki

阅读更多

docker安装

正式环境不能像开发环境一样随意..

网桥

1
2
3
4
5
6
7
8
9
10
cat >> /etc/sysctl.conf<<EOF
net.ipv4.ip_forward=1
net.bridge.bridge-nf-call-iptables=1
net.ipv4.neigh.default.gc_thresh1=4096
net.ipv4.neigh.default.gc_thresh2=6144
net.ipv4.neigh.default.gc_thresh3=8192
EOF

# 这个其实是重启命令
init 6

阅读更多

sh字符串截取

sh字符串截取

*的位置,代表删除侧边

  1. #号截取,* 删除从左边满足条件的第一组字符及其左边字符,保留右边字符。
    1
    2
    3
    var=http://www.aaa.com/123.htm.
    echo ${var#*//} # www.aaa.com/123.htm.
    echo ${var#*/} # /www.aaa.com/123.htm.

阅读更多