See also, http://libraryofalexandria.io/cgo/
cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.
So, Here collect materials.
| # | |
| # Wide-open CORS config for nginx | |
| # | |
| location / { | |
| if ($request_method = 'OPTIONS') { | |
| add_header 'Access-Control-Allow-Origin' '*'; | |
| add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; | |
| # | |
| # Custom headers and headers various browsers *should* be OK with but aren't | |
| # |
| 1. GOCACHE=off , go 1.11这个环境变量会被去除 | |
| 2. -count=1 | |
| 3. go clean -cache | |
| 4. -a 重编译 | |
| 5. -gcflags="all=-a" 重编译 |
| package main | |
| import ( | |
| "crypto/tls" | |
| "fmt" | |
| "net/http" | |
| "golang.org/x/crypto/acme/autocert" | |
| ) |
See also, http://libraryofalexandria.io/cgo/
cgo has a lot of trap.
but Not "C" pkg also directory in $GOROOT/src. IDE's(vim) Goto command not works.
So, Here collect materials.
| 1 普通匹配,遵循最长匹配规则,假设一个请求匹配到了两个普通规则,则选择匹配长度大的那个 | |
| 例如: | |
| location /{ | |
| [matches] | |
| } | |
| location /test{ | |
| [matches] | |
| } | |
| 2 精确匹配 | |
| location = /{ |
| http { | |
| include mime.types; | |
| default_type application/octet-stream; | |
| sendfile on; | |
| keepalive_timeout 65; | |
| upstream myappget { | |
| server 127.0.0.1:3000; |
| // v2 of the great example of SSE in go by @ismasan. | |
| // includes fixes: | |
| // * infinite loop ending in panic | |
| // * closing a client twice | |
| // * potentially blocked listen() from closing a connection during multiplex step. | |
| package main | |
| import ( | |
| "fmt" | |
| "log" |
| // v2 of the great example of SSE in go by @ismasan. | |
| // includes fixes: | |
| // * infinite loop ending in panic | |
| // * closing a client twice | |
| // * potentially blocked listen() from closing a connection during multiplex step. | |
| package main | |
| import ( | |
| "fmt" | |
| "log" |
| out, err := exec.Command("bash", "-c", "ps cax | grep myapp").Output() |
| package main | |
| import ( | |
| "fmt" | |
| "syscall" | |
| ) | |
| type DiskStatus struct { | |
| All uint64 `json:"all"` | |
| Used uint64 `json:"used"` |