All of the following information is based on go version go1.8.3 darwin/amd64.
(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)
androiddarwin
| package main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "runtime" | |
| "time" | |
| ) | |
| type Monitor struct { |
| func Socketpair() (net.Conn, net.Conn, error) { | |
| fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM, 0) | |
| if err != nil { | |
| return nil, nil, err | |
| } | |
| c1, err := fdToFileConn(fds[0]) | |
| if err != nil { | |
| return nil, nil, err | |
| } |
| package main | |
| import ( | |
| "log" | |
| "math/rand" | |
| "time" | |
| ) | |
| const ( | |
| size = 1000 |
| package main | |
| /* | |
| #cgo CFLAGS: -I/usr/local/include/pango-1.0 | |
| #cgo CFLAGS: -I/usr/local/include/glib-2.0 | |
| #cgo CFLAGS: -I/usr/local/include/cairo | |
| #cgo LDFLAGS: -L/usr/local/lib -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lglib-2.0 | |
| #include <pango/pangocairo.h> | |
| #include <stdio.h> | |
| #include <pthread.h> |
| // stacklog2 returns ⌊log_2(n)⌋. | |
| func stacklog2(n uintptr) int { | |
| log2 := 0 | |
| for n > 1 { | |
| n >>= 1 | |
| log2++ | |
| } | |
| return log2 | |
| } |
| FILENAME=$(basename $(pwd)) | |
| go test -run=. -bench=. -cpuprofile=cpu.out -benchmem -memprofile=mem.out -trace trace.out | |
| go tool pprof -pdf $FILENAME.test cpu.out > cpu.pdf && open cpu.pdf | |
| go tool pprof -pdf --alloc_space $FILENAME.test mem.out > alloc_space.pdf && open alloc_space.pdf | |
| go tool pprof -pdf --alloc_objects $FILENAME.test mem.out > alloc_objects.pdf && open alloc_objects.pdf | |
| go tool pprof -pdf --inuse_space $FILENAME.test mem.out > inuse_space.pdf && open inuse_space.pdf | |
| go tool pprof -pdf --inuse_objects $FILENAME.test mem.out > inuse_objects.pdf && open inuse_objects.pdf | |
| go tool trace trace.out | |
| go-torch $FILENAME.test cpu.out -f ${FILENAME}_cpu.svg && open ${FILENAME}_cpu.svg |
| #!/usr/bin/perl -w | |
| use strict; | |
| use warnings; | |
| # 单行注释 | |
| print('Hello, | |
| $world!\n'); | |
| my $world = "world"; | |
| print "Hello, |
| https://github.com/golang/go/issues/7560 | |
| https://github.com/golang/go/commit/2d1a9510edc59cad463029fdc8ac93e62247baad | |
| https://dave.cheney.net/2015/10/09/padding-is-hard |
| docker rm $(docker ps -a -q) |