├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── Bug_report.md
│ ├── Feature_request.md
│ └── Question.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── website.yml
├── .gitignore
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.en-us.md
├── README.md
├── book
├── NOTES
├── PLANS
├── assets
│ ├── alipay.jpg
│ ├── bench-perflock.png
│ ├── bench-significant.png
│ ├── benchstat-rbtree-correct.png
│ ├── benchstat-rbtree-wrong.png
│ ├── book.png
│ ├── boot.png
│ ├── cgo-go-c.png
│ ├── chan.png
│ ├── cover-cn-v2.png
│ ├── cover-cn-v3.png
│ ├── cover-cn.png
│ ├── cover.png
│ ├── defer-link.png
│ ├── defer-perf.png
│ ├── errors-branch.png
│ ├── errors-chan.png
│ ├── g-status.png
│ ├── gc-blueprint.png
│ ├── gc-mutator.png
│ ├── gc-pacing.png
│ ├── gc-phase.png
│ ├── gc-wb-dijkstra.png
│ ├── gc-wb-yuasa.png
│ ├── gc1.png
│ ├── gc2.png
│ ├── gc3.png
│ ├── header.png
│ ├── header.svg
│ ├── map-syncmap.png
│ ├── map-write-performance.png
│ ├── mem-struct.png
│ ├── p-status.png
│ ├── proc-stack.png
│ ├── raw
│ │ ├── bench.graffle
│ │ ├── book.graffle
│ │ ├── boot.graffle
│ │ ├── chan.graffle
│ │ ├── cover-cn-v2.afphoto
│ │ ├── cover-cn.afphoto
│ │ ├── cover.afphoto
│ │ ├── defer.graffle
│ │ ├── errors.graffle
│ │ ├── gc-picture.graffle
│ │ ├── gc-vis.graffle
│ │ ├── gc.graffle
│ │ │ ├── data.plist
│ │ │ ├── image2.png
│ │ │ ├── image3.png
│ │ │ ├── image4.png
│ │ │ ├── image5.png
│ │ │ └── preview.jpeg
│ │ ├── header-2.afdesign
│ │ ├── header.afdesign
│ │ ├── mem.graffle
│ │ ├── sched-numa.graffle
│ │ ├── sched.graffle
│ │ ├── signal-handler.graffle
│ │ ├── stack.graffle
│ │ ├── timers.graffle
│ │ └── warning.afphoto
│ ├── sched-init.png
│ ├── sched-numa.png
│ ├── schedule.png
│ ├── signal-handler.png
│ ├── timers.png
│ ├── warning.png
│ └── wechat.jpg
├── backlog
│ ├── bib.md
│ ├── ch01proc
│ │ ├── asm.md
│ │ ├── compile.md
│ │ ├── cpu.md
│ │ ├── go.md
│ │ ├── os.md
│ │ ├── readme.md
│ │ └── stack.md
│ ├── ch02parallel
│ │ ├── cache.md
│ │ ├── consensus.md
│ │ ├── csp.md
│ │ ├── define.md
│ │ ├── distributed.md
│ │ ├── locks.md
│ │ ├── perfs.md
│ │ └── readme.md
│ ├── ch03scheduling
│ │ ├── interrupt.md
│ │ ├── queue.md
│ │ ├── readme.md
│ │ ├── single.md
│ │ ├── stochastic.md
│ │ └── theory.md
│ ├── ch04memory
│ │ ├── alloc.md
│ │ ├── barrier.md
│ │ ├── cms.md
│ │ ├── readme.md
│ │ └── unifiedgc.md
│ ├── ch10abi
│ │ ├── callconv.md
│ │ ├── cgo.md
│ │ ├── readme.md
│ │ ├── syscallpkg.md
│ │ ├── syscallrt.md
│ │ └── wasm.md
│ ├── ch14linker
│ │ ├── init.md
│ │ ├── link.md
│ │ ├── obj.md
│ │ ├── plugin.md
│ │ └── readme.md
│ ├── ch16net
│ │ ├── fd.md
│ │ ├── readme.md
│ │ └── routers.md
│ ├── cycle.md
│ ├── init.md
│ ├── scavenge.md
│ └── sched
│ │ ├── basic.md
│ │ ├── calls.md
│ │ ├── exec.md
│ │ ├── history.md
│ │ ├── init.md
│ │ └── sync.md
└── zh-cn
│ ├── donate.md
│ ├── finalwords.md
│ ├── glossary.md
│ ├── part1basic
│ ├── ch01basic
│ │ ├── asm.md
│ │ ├── csp.md
│ │ ├── go.md
│ │ ├── history.md
│ │ └── readme.md
│ ├── ch02life
│ │ ├── boot.md
│ │ ├── cmd.md
│ │ ├── compile.md
│ │ ├── main.md
│ │ └── readme.md
│ ├── ch03lang
│ │ ├── alias.md
│ │ ├── chan.md
│ │ ├── defer.md
│ │ ├── func.md
│ │ ├── interface.md
│ │ ├── map.md
│ │ ├── panic.md
│ │ ├── readme.md
│ │ ├── ref.md
│ │ ├── slice.md
│ │ └── type.md
│ ├── ch04errors
│ │ ├── context.md
│ │ ├── future.md
│ │ ├── inspect.md
│ │ ├── readme.md
│ │ ├── ref.md
│ │ ├── semantics.md
│ │ └── value.md
│ ├── ch05sync
│ │ ├── atomic.md
│ │ ├── basic.md
│ │ ├── cond.md
│ │ ├── context.md
│ │ ├── map.md
│ │ ├── mem.md
│ │ ├── mutex.md
│ │ ├── pool.md
│ │ ├── readme.md
│ │ ├── ref.md
│ │ └── waitgroup.md
│ └── readme.md
│ ├── part2runtime
│ ├── ch06sched
│ │ ├── model.md
│ │ ├── mpg.md
│ │ ├── numa.md
│ │ ├── poller.md
│ │ ├── preemption.md
│ │ ├── readme.md
│ │ ├── ref.md
│ │ ├── schedule.md
│ │ ├── signal.md
│ │ ├── stack.md
│ │ ├── steal.md
│ │ ├── sysmon.md
│ │ ├── thread.md
│ │ └── timer.md
│ ├── ch07alloc
│ │ ├── basic.md
│ │ ├── component.md
│ │ ├── history.md
│ │ ├── init.md
│ │ ├── largealloc.md
│ │ ├── mstats.md
│ │ ├── pagealloc.md
│ │ ├── readme.md
│ │ ├── smallalloc.md
│ │ └── tinyalloc.md
│ ├── ch08GC
│ │ ├── barrier.md
│ │ ├── basic.md
│ │ ├── finalizer.md
│ │ ├── generational.md
│ │ ├── history.md
│ │ ├── mark.md
│ │ ├── pacing.md
│ │ ├── readme.md
│ │ ├── ref.md
│ │ ├── roc.md
│ │ ├── safe.md
│ │ ├── sweep.md
│ │ ├── termination.md
│ │ └── unifiedgc.md
│ └── readme.md
│ ├── part3tools
│ ├── ch09analysis
│ │ ├── deadlock.md
│ │ ├── gopls.md
│ │ ├── metric.md
│ │ ├── perf.md
│ │ ├── race.md
│ │ ├── readme.md
│ │ ├── testing.md
│ │ └── trace.md
│ ├── ch10deps
│ │ ├── challenges.md
│ │ ├── fight.md
│ │ ├── minimum.md
│ │ ├── readme.md
│ │ └── semantics.md
│ ├── ch11compile
│ │ ├── asm.md
│ │ ├── bootstrap.md
│ │ ├── callconv.md
│ │ ├── cgo.md
│ │ ├── escape.md
│ │ ├── future.md
│ │ ├── link.md
│ │ ├── optimize.md
│ │ ├── parse.md
│ │ ├── readme.md
│ │ ├── ssa.md
│ │ └── unsafe.md
│ ├── ch12generics
│ │ ├── checker.md
│ │ ├── contracts.md
│ │ ├── future.md
│ │ ├── history.md
│ │ ├── readme.md
│ │ └── ref.md
│ └── readme.md
│ └── preface.md
├── demo
├── ch05boot
│ ├── Makefile
│ ├── main.go
│ ├── main1.go
│ └── main2.go
├── ch06sched
│ ├── exec
│ │ └── main.go
│ ├── init
│ │ └── main.go
│ ├── peer
│ │ ├── Makefile
│ │ ├── main.S
│ │ └── main.go
│ └── preemption
│ │ ├── main
│ │ └── main.go
├── ch07mem
│ ├── Makefile
│ ├── alloc
│ │ ├── Makefile
│ │ ├── alloc.S
│ │ └── alloc.go
│ ├── arenahint
│ │ └── mallocinit.go
│ ├── main.S
│ ├── main.go
│ ├── memorder
│ │ └── main.go
│ ├── memorder_test.go
│ └── mstats
│ │ └── main.go
├── ch08GC
│ ├── evil
│ │ ├── cpu.prof
│ │ ├── evil_test.go
│ │ └── mem.prof
│ ├── leak
│ │ └── main.go
│ ├── pause
│ │ └── main.go
│ ├── stw
│ │ └── main.go
│ └── trigger
│ │ └── main.go
├── ch09lang
│ ├── chan
│ │ ├── Makefile
│ │ ├── chan.S
│ │ └── chan.go
│ ├── defer
│ │ ├── Makefile
│ │ ├── defer.go
│ │ ├── defer_test.go
│ │ ├── go1.13.txt
│ │ ├── go1.14.txt
│ │ └── semantics
│ │ │ └── main.go
│ ├── go
│ │ ├── Makefile
│ │ ├── main.S
│ │ └── main.go
│ ├── interface
│ │ ├── assertion
│ │ │ ├── Makefile
│ │ │ └── main.go
│ │ ├── eface
│ │ │ ├── Makefile
│ │ │ ├── main1.go
│ │ │ └── main2.go
│ │ ├── iface
│ │ │ ├── Makefile
│ │ │ ├── main1.go
│ │ │ ├── main2.go
│ │ │ └── ssa.go
│ │ └── receiver
│ │ │ ├── Makefile
│ │ │ ├── main1.go
│ │ │ ├── main2.go
│ │ │ ├── main3.go
│ │ │ └── main4.go
│ ├── map
│ │ ├── Makefile
│ │ ├── main.S
│ │ └── main.go
│ └── panic
│ │ ├── Makefile
│ │ ├── main.S
│ │ ├── main.go
│ │ └── main2.go
├── ch10abi
│ └── cgo
│ │ ├── Makefile
│ │ ├── ccallgo
│ │ ├── Makefile
│ │ ├── gofunc
│ │ │ ├── hello.go
│ │ │ └── hello.h
│ │ ├── main
│ │ └── main.c
│ │ └── main.go
├── ch13gc
│ ├── compile
│ │ ├── main.go
│ │ ├── packa
│ │ │ └── a.go
│ │ └── packb
│ │ │ └── b.go
│ └── unsafe
│ │ ├── Makefile
│ │ ├── main.S
│ │ └── main.go
├── ch15sync
│ ├── atomic
│ │ ├── Makefile
│ │ ├── main.S
│ │ └── main.go
│ └── sync
│ │ ├── cond
│ │ └── cond.go
│ │ ├── map
│ │ ├── bench.txt
│ │ ├── map_test.go
│ │ └── old
│ │ │ ├── map.go
│ │ │ ├── map_test.go
│ │ │ └── old.txt
│ │ └── waigroup
│ │ ├── Makefile
│ │ └── waitgroup.go
└── ch2parallel
│ └── cache
│ ├── main_test.go
│ ├── new.txt
│ └── old.txt
├── gosrc
├── cmd
│ ├── cgo
│ │ ├── ast.go
│ │ ├── doc.go
│ │ ├── gcc.go
│ │ ├── godefs.go
│ │ ├── main.go
│ │ ├── out.go
│ │ ├── util.go
│ │ └── zdefaultcc.go
│ ├── compile
│ │ ├── README.md
│ │ ├── doc.go
│ │ ├── internal
│ │ │ ├── amd64
│ │ │ │ ├── galign.go
│ │ │ │ ├── ggen.go
│ │ │ │ └── ssa.go
│ │ │ ├── gc
│ │ │ │ ├── alg.go
│ │ │ │ ├── align.go
│ │ │ │ ├── bexport.go
│ │ │ │ ├── bimport.go
│ │ │ │ ├── bitset.go
│ │ │ │ ├── bootstrap.go
│ │ │ │ ├── builtin.go
│ │ │ │ ├── builtin
│ │ │ │ │ └── runtime.go
│ │ │ │ ├── bv.go
│ │ │ │ ├── class_string.go
│ │ │ │ ├── closure.go
│ │ │ │ ├── const.go
│ │ │ │ ├── dcl.go
│ │ │ │ ├── dump.go
│ │ │ │ ├── dwinl.go
│ │ │ │ ├── esc.go
│ │ │ │ ├── escape.go
│ │ │ │ ├── export.go
│ │ │ │ ├── fmt.go
│ │ │ │ ├── gen.go
│ │ │ │ ├── go.go
│ │ │ │ ├── gsubr.go
│ │ │ │ ├── iexport.go
│ │ │ │ ├── iimport.go
│ │ │ │ ├── init.go
│ │ │ │ ├── initorder.go
│ │ │ │ ├── inl.go
│ │ │ │ ├── lex.go
│ │ │ │ ├── main.go
│ │ │ │ ├── mapfile_mmap.go
│ │ │ │ ├── mapfile_read.go
│ │ │ │ ├── mkbuiltin.go
│ │ │ │ ├── mpfloat.go
│ │ │ │ ├── mpint.go
│ │ │ │ ├── noder.go
│ │ │ │ ├── obj.go
│ │ │ │ ├── op_string.go
│ │ │ │ ├── order.go
│ │ │ │ ├── pgen.go
│ │ │ │ ├── phi.go
│ │ │ │ ├── plive.go
│ │ │ │ ├── pprof.go
│ │ │ │ ├── racewalk.go
│ │ │ │ ├── range.go
│ │ │ │ ├── reflect.go
│ │ │ │ ├── scc.go
│ │ │ │ ├── scope.go
│ │ │ │ ├── select.go
│ │ │ │ ├── sinit.go
│ │ │ │ ├── ssa.go
│ │ │ │ ├── subr.go
│ │ │ │ ├── swt.go
│ │ │ │ ├── syntax.go
│ │ │ │ ├── timings.go
│ │ │ │ ├── trace.go
│ │ │ │ ├── typecheck.go
│ │ │ │ ├── types.go
│ │ │ │ ├── types_acc.go
│ │ │ │ ├── universe.go
│ │ │ │ ├── unsafe.go
│ │ │ │ ├── util.go
│ │ │ │ └── walk.go
│ │ │ ├── ssa
│ │ │ │ ├── README.md
│ │ │ │ ├── TODO
│ │ │ │ ├── biasedsparsemap.go
│ │ │ │ ├── block.go
│ │ │ │ ├── branchelim.go
│ │ │ │ ├── cache.go
│ │ │ │ ├── check.go
│ │ │ │ ├── checkbce.go
│ │ │ │ ├── compile.go
│ │ │ │ ├── config.go
│ │ │ │ ├── copyelim.go
│ │ │ │ ├── critical.go
│ │ │ │ ├── cse.go
│ │ │ │ ├── deadcode.go
│ │ │ │ ├── deadstore.go
│ │ │ │ ├── debug.go
│ │ │ │ ├── decompose.go
│ │ │ │ ├── dom.go
│ │ │ │ ├── flagalloc.go
│ │ │ │ ├── func.go
│ │ │ │ ├── fuse.go
│ │ │ │ ├── gen
│ │ │ │ │ ├── AMD64.rules
│ │ │ │ │ ├── AMD64Ops.go
│ │ │ │ │ ├── AMD64splitload.rules
│ │ │ │ │ ├── README
│ │ │ │ │ ├── Wasm.rules
│ │ │ │ │ ├── WasmOps.go
│ │ │ │ │ ├── generic.rules
│ │ │ │ │ ├── genericOps.go
│ │ │ │ │ ├── main.go
│ │ │ │ │ └── rulegen.go
│ │ │ │ ├── html.go
│ │ │ │ ├── id.go
│ │ │ │ ├── layout.go
│ │ │ │ ├── lca.go
│ │ │ │ ├── likelyadjust.go
│ │ │ │ ├── location.go
│ │ │ │ ├── loopbce.go
│ │ │ │ ├── loopreschedchecks.go
│ │ │ │ ├── looprotate.go
│ │ │ │ ├── lower.go
│ │ │ │ ├── magic.go
│ │ │ │ ├── nilcheck.go
│ │ │ │ ├── numberlines.go
│ │ │ │ ├── op.go
│ │ │ │ ├── opGen.go
│ │ │ │ ├── opt.go
│ │ │ │ ├── phielim.go
│ │ │ │ ├── phiopt.go
│ │ │ │ ├── poset.go
│ │ │ │ ├── print.go
│ │ │ │ ├── prove.go
│ │ │ │ ├── redblack32.go
│ │ │ │ ├── regalloc.go
│ │ │ │ ├── rewrite.go
│ │ │ │ ├── rewriteAMD64.go
│ │ │ │ ├── rewriteAMD64splitload.go
│ │ │ │ ├── rewriteWasm.go
│ │ │ │ ├── rewritegeneric.go
│ │ │ │ ├── schedule.go
│ │ │ │ ├── shortcircuit.go
│ │ │ │ ├── softfloat.go
│ │ │ │ ├── sparsemap.go
│ │ │ │ ├── sparseset.go
│ │ │ │ ├── sparsetree.go
│ │ │ │ ├── sparsetreemap.go
│ │ │ │ ├── stackalloc.go
│ │ │ │ ├── stackframe.go
│ │ │ │ ├── tighten.go
│ │ │ │ ├── trim.go
│ │ │ │ ├── value.go
│ │ │ │ ├── writebarrier.go
│ │ │ │ ├── xposmap.go
│ │ │ │ └── zcse.go
│ │ │ ├── syntax
│ │ │ │ ├── branches.go
│ │ │ │ ├── dumper.go
│ │ │ │ ├── nodes.go
│ │ │ │ ├── operator_string.go
│ │ │ │ ├── parser.go
│ │ │ │ ├── pos.go
│ │ │ │ ├── printer.go
│ │ │ │ ├── scanner.go
│ │ │ │ ├── source.go
│ │ │ │ ├── syntax.go
│ │ │ │ ├── token_string.go
│ │ │ │ └── tokens.go
│ │ │ ├── types
│ │ │ │ ├── etype_string.go
│ │ │ │ ├── identity.go
│ │ │ │ ├── pkg.go
│ │ │ │ ├── scope.go
│ │ │ │ ├── sym.go
│ │ │ │ ├── type.go
│ │ │ │ └── utils.go
│ │ │ ├── wasm
│ │ │ │ └── ssa.go
│ │ │ └── x86
│ │ │ │ ├── 387.go
│ │ │ │ ├── galign.go
│ │ │ │ ├── ggen.go
│ │ │ │ └── ssa.go
│ │ └── main.go
│ ├── go
│ │ ├── alldocs.go
│ │ ├── go11.go
│ │ ├── internal
│ │ │ ├── auth
│ │ │ │ ├── auth.go
│ │ │ │ └── netrc.go
│ │ │ ├── base
│ │ │ │ ├── base.go
│ │ │ │ ├── env.go
│ │ │ │ ├── flag.go
│ │ │ │ ├── goflags.go
│ │ │ │ ├── path.go
│ │ │ │ ├── signal.go
│ │ │ │ ├── signal_unix.go
│ │ │ │ └── tool.go
│ │ │ ├── cache
│ │ │ │ ├── cache.go
│ │ │ │ ├── default.go
│ │ │ │ └── hash.go
│ │ │ ├── cfg
│ │ │ │ ├── cfg.go
│ │ │ │ ├── zdefaultcc.go
│ │ │ │ └── zosarch.go
│ │ │ ├── cmdflag
│ │ │ │ └── flag.go
│ │ │ ├── generate
│ │ │ │ └── generate.go
│ │ │ ├── get
│ │ │ │ ├── discovery.go
│ │ │ │ ├── get.go
│ │ │ │ ├── path.go
│ │ │ │ └── vcs.go
│ │ │ ├── imports
│ │ │ │ ├── build.go
│ │ │ │ ├── read.go
│ │ │ │ ├── scan.go
│ │ │ │ └── tags.go
│ │ │ ├── load
│ │ │ │ ├── flag.go
│ │ │ │ ├── path.go
│ │ │ │ ├── pkg.go
│ │ │ │ ├── search.go
│ │ │ │ └── test.go
│ │ │ ├── lockedfile
│ │ │ │ ├── internal
│ │ │ │ │ └── filelock
│ │ │ │ │ │ ├── filelock.go
│ │ │ │ │ │ └── filelock_unix.go
│ │ │ │ ├── lockedfile.go
│ │ │ │ ├── lockedfile_filelock.go
│ │ │ │ └── mutex.go
│ │ │ ├── modcmd
│ │ │ │ ├── download.go
│ │ │ │ ├── edit.go
│ │ │ │ ├── graph.go
│ │ │ │ ├── init.go
│ │ │ │ ├── mod.go
│ │ │ │ ├── tidy.go
│ │ │ │ ├── vendor.go
│ │ │ │ ├── verify.go
│ │ │ │ └── why.go
│ │ │ ├── modconv
│ │ │ │ ├── convert.go
│ │ │ │ ├── dep.go
│ │ │ │ ├── glide.go
│ │ │ │ ├── glock.go
│ │ │ │ ├── godeps.go
│ │ │ │ ├── modconv.go
│ │ │ │ ├── tsv.go
│ │ │ │ ├── vconf.go
│ │ │ │ ├── vjson.go
│ │ │ │ ├── vmanifest.go
│ │ │ │ └── vyml.go
│ │ │ ├── modfetch
│ │ │ │ ├── bootstrap.go
│ │ │ │ ├── cache.go
│ │ │ │ ├── codehost
│ │ │ │ │ ├── codehost.go
│ │ │ │ │ ├── git.go
│ │ │ │ │ ├── git_test.go
│ │ │ │ │ ├── shell.go
│ │ │ │ │ ├── svn.go
│ │ │ │ │ └── vcs.go
│ │ │ │ ├── coderepo.go
│ │ │ │ ├── fetch.go
│ │ │ │ ├── insecure.go
│ │ │ │ ├── key.go
│ │ │ │ ├── proxy.go
│ │ │ │ ├── pseudo.go
│ │ │ │ ├── repo.go
│ │ │ │ └── sumdb.go
│ │ │ ├── modget
│ │ │ │ └── get.go
│ │ │ ├── modinfo
│ │ │ │ └── info.go
│ │ │ ├── modload
│ │ │ │ ├── build.go
│ │ │ │ ├── help.go
│ │ │ │ ├── import.go
│ │ │ │ ├── init.go
│ │ │ │ ├── list.go
│ │ │ │ ├── load.go
│ │ │ │ ├── query.go
│ │ │ │ ├── search.go
│ │ │ │ ├── stat_openfile.go
│ │ │ │ ├── stat_unix.go
│ │ │ │ └── testgo.go
│ │ │ ├── mvs
│ │ │ │ ├── mvs.go
│ │ │ │ └── mvs_test.go
│ │ │ ├── par
│ │ │ │ ├── work.go
│ │ │ │ └── work_test.go
│ │ │ ├── renameio
│ │ │ │ └── renameio.go
│ │ │ ├── robustio
│ │ │ │ ├── robustio.go
│ │ │ │ ├── robustio_darwin.go
│ │ │ │ ├── robustio_flaky.go
│ │ │ │ └── robustio_other.go
│ │ │ ├── run
│ │ │ │ └── run.go
│ │ │ ├── search
│ │ │ │ └── search.go
│ │ │ ├── str
│ │ │ │ ├── path.go
│ │ │ │ └── str.go
│ │ │ ├── tool
│ │ │ │ └── tool.go
│ │ │ ├── vet
│ │ │ │ ├── vet.go
│ │ │ │ └── vetflag.go
│ │ │ ├── web
│ │ │ │ ├── api.go
│ │ │ │ ├── bootstrap.go
│ │ │ │ ├── http.go
│ │ │ │ ├── url.go
│ │ │ │ ├── url_other.go
│ │ │ │ └── url_windows.go
│ │ │ └── work
│ │ │ │ ├── action.go
│ │ │ │ ├── build.go
│ │ │ │ ├── buildid.go
│ │ │ │ ├── exec.go
│ │ │ │ ├── gc.go
│ │ │ │ ├── gccgo.go
│ │ │ │ ├── init.go
│ │ │ │ ├── security.go
│ │ │ │ └── testgo.go
│ │ ├── main.go
│ │ └── mkalldocs.sh
│ └── internal
│ │ └── obj
│ │ ├── abi_string.go
│ │ ├── addrtype_string.go
│ │ ├── data.go
│ │ ├── dwarf.go
│ │ ├── go.go
│ │ ├── inl.go
│ │ ├── ld.go
│ │ ├── line.go
│ │ ├── link.go
│ │ ├── objfile.go
│ │ ├── objfile2.go
│ │ ├── pass.go
│ │ ├── pcln.go
│ │ ├── plist.go
│ │ ├── stringer.go
│ │ ├── sym.go
│ │ ├── textflag.go
│ │ ├── util.go
│ │ └── x86
│ │ ├── a.out.go
│ │ ├── aenum.go
│ │ ├── anames.go
│ │ ├── asm6.go
│ │ ├── avx_optabs.go
│ │ ├── evex.go
│ │ ├── list6.go
│ │ ├── obj6.go
│ │ └── ytab.go
├── context
│ └── context.go
├── errors
│ ├── errors.go
│ └── wrap.go
├── fmt
│ ├── errors.go
│ └── print.go
├── internal
│ └── cpu
│ │ ├── cpu.go
│ │ ├── cpu_amd64.go
│ │ ├── cpu_x86.go
│ │ └── cpu_x86.s
├── os
│ └── signal
│ │ ├── doc.go
│ │ ├── sig.s
│ │ ├── signal.go
│ │ └── signal_unix.go
├── plugin
│ ├── plugin.go
│ ├── plugin_dlopen.go
│ └── plugin_stubs.go
├── reflect
│ ├── asm_amd64.s
│ ├── asm_wasm.s
│ ├── deepequal.go
│ ├── makefunc.go
│ ├── swapper.go
│ ├── type.go
│ └── value.go
├── runtime
│ ├── HACKING.md
│ ├── README.md
│ ├── alg.go
│ ├── asm.s
│ ├── asm_amd64.s
│ ├── asm_wasm.s
│ ├── atomic_pointer.go
│ ├── cgo.go
│ ├── cgo
│ │ ├── asm_amd64.s
│ │ ├── callbacks.go
│ │ ├── callbacks_traceback.go
│ │ ├── cgo.go
│ │ ├── gcc_amd64.S
│ │ ├── gcc_context.c
│ │ ├── gcc_darwin_amd64.c
│ │ ├── gcc_fatalf.c
│ │ ├── gcc_libinit.c
│ │ ├── gcc_linux_amd64.c
│ │ ├── gcc_mmap.c
│ │ ├── gcc_setenv.c
│ │ ├── gcc_sigaction.c
│ │ ├── gcc_traceback.c
│ │ ├── gcc_util.c
│ │ ├── iscgo.go
│ │ ├── libcgo.h
│ │ ├── libcgo_unix.h
│ │ ├── mmap.go
│ │ ├── setenv.go
│ │ └── sigaction.go
│ ├── cgo_mmap.go
│ ├── cgo_sigaction.go
│ ├── cgocall.go
│ ├── cgocallback.go
│ ├── cgocheck.go
│ ├── chan.go
│ ├── checkptr.go
│ ├── compiler.go
│ ├── complex.go
│ ├── cpuflags.go
│ ├── cpuflags_amd64.go
│ ├── cpuprof.go
│ ├── cputicks.go
│ ├── debug.go
│ ├── debug
│ │ ├── debug.s
│ │ ├── garbage.go
│ │ ├── mod.go
│ │ ├── stack.go
│ │ └── stubs.go
│ ├── debugcall.go
│ ├── debuglog.go
│ ├── debuglog_off.go
│ ├── debuglog_on.go
│ ├── defs1_linux.go
│ ├── defs2_linux.go
│ ├── defs3_linux.go
│ ├── defs_darwin.go
│ ├── defs_darwin_amd64.go
│ ├── defs_linux.go
│ ├── defs_linux_amd64.go
│ ├── duff_amd64.s
│ ├── env_posix.go
│ ├── error.go
│ ├── extern.go
│ ├── fastlog2.go
│ ├── fastlog2table.go
│ ├── float.go
│ ├── funcdata.h
│ ├── go_tls.h
│ ├── hash32.go
│ ├── hash64.go
│ ├── heapdump.go
│ ├── histogram.go
│ ├── iface.go
│ ├── internal
│ │ ├── atomic
│ │ │ ├── asm_amd64.s
│ │ │ ├── atomic_amd64.go
│ │ │ ├── atomic_wasm.go
│ │ │ └── stubs.go
│ │ ├── math
│ │ │ └── math.go
│ │ └── sys
│ │ │ ├── arch.go
│ │ │ ├── arch_amd64.go
│ │ │ ├── arch_wasm.go
│ │ │ ├── gengoos.go
│ │ │ ├── intrinsics.go
│ │ │ ├── intrinsics_common.go
│ │ │ ├── intrinsics_stubs.go
│ │ │ ├── stubs.go
│ │ │ ├── sys.go
│ │ │ ├── zgoarch_amd64.go
│ │ │ ├── zgoarch_wasm.go
│ │ │ └── zgoos_linux.go
│ ├── lfstack.go
│ ├── lfstack_64bit.go
│ ├── libfuzzer.go
│ ├── libfuzzer_amd64.s
│ ├── lock_futex.go
│ ├── lock_js.go
│ ├── lock_sema.go
│ ├── lockrank.go
│ ├── lockrank_off.go
│ ├── lockrank_on.go
│ ├── malloc.go
│ ├── map.go
│ ├── map_fast32.go
│ ├── map_fast64.go
│ ├── map_faststr.go
│ ├── mbarrier.go
│ ├── mbitmap.go
│ ├── mcache.go
│ ├── mcentral.go
│ ├── mcheckmark.go
│ ├── mem_darwin.go
│ ├── mem_js.go
│ ├── mem_linux.go
│ ├── memclr_amd64.s
│ ├── memclr_wasm.s
│ ├── memmove_amd64.s
│ ├── memmove_wasm.s
│ ├── metrics.go
│ ├── metrics
│ │ ├── description.go
│ │ ├── doc.go
│ │ ├── histogram.go
│ │ ├── sample.go
│ │ └── value.go
│ ├── mfinal.go
│ ├── mfixalloc.go
│ ├── mgc.go
│ ├── mgcmark.go
│ ├── mgcscavenge.go
│ ├── mgcstack.go
│ ├── mgcsweep.go
│ ├── mgcsweepbuf.go
│ ├── mgcwork.go
│ ├── mheap.go
│ ├── mkduff.go
│ ├── mkfastlog2table.go
│ ├── mkpreempt.go
│ ├── mksizeclasses.go
│ ├── mmap.go
│ ├── mpagealloc.go
│ ├── mpagealloc_64bit.go
│ ├── mpagecache.go
│ ├── mpallocbits.go
│ ├── mprof.go
│ ├── mranges.go
│ ├── msan.go
│ ├── msan0.go
│ ├── msan_amd64.s
│ ├── msize.go
│ ├── mspanset.go
│ ├── mstats.go
│ ├── mwbbuf.go
│ ├── nbpipe_pipe.go
│ ├── nbpipe_pipe2.go
│ ├── netpoll.go
│ ├── netpoll_epoll.go
│ ├── netpoll_fake.go
│ ├── netpoll_kqueue.go
│ ├── netpoll_stub.go
│ ├── os_darwin.go
│ ├── os_js.go
│ ├── os_linux.go
│ ├── os_linux_amd64.go
│ ├── os_linux_be64.go
│ ├── os_linux_generic.go
│ ├── os_linux_noauxv.go
│ ├── os_linux_novdso.go
│ ├── os_linux_x86.go
│ ├── os_nonopenbsd.go
│ ├── panic.go
│ ├── panic32.go
│ ├── plugin.go
│ ├── preempt.go
│ ├── preempt_amd64.s
│ ├── preempt_nonwindows.go
│ ├── preempt_wasm.s
│ ├── print.go
│ ├── proc.go
│ ├── profbuf.go
│ ├── proflabel.go
│ ├── race.go
│ ├── race
│ │ ├── README
│ │ ├── doc.go
│ │ └── race.go
│ ├── race0.go
│ ├── race_amd64.s
│ ├── rdebug.go
│ ├── relax_stub.go
│ ├── rt0_darwin_amd64.s
│ ├── rt0_ios_amd64.s
│ ├── rt0_js_wasm.s
│ ├── rt0_linux_amd64.s
│ ├── runtime-gdb.py
│ ├── runtime.go
│ ├── runtime1.go
│ ├── runtime2.go
│ ├── rwmutex.go
│ ├── select.go
│ ├── sema.go
│ ├── sigaction.go
│ ├── signal_amd64.go
│ ├── signal_darwin.go
│ ├── signal_darwin_amd64.go
│ ├── signal_linux_amd64.go
│ ├── signal_unix.go
│ ├── sigqueue.go
│ ├── sigqueue_note.go
│ ├── sigtab_linux_generic.go
│ ├── sizeclasses.go
│ ├── slice.go
│ ├── softfloat64.go
│ ├── stack.go
│ ├── string.go
│ ├── stubs.go
│ ├── stubs2.go
│ ├── stubs3.go
│ ├── stubs_amd64.go
│ ├── stubs_linux.go
│ ├── stubs_nonlinux.go
│ ├── symtab.go
│ ├── sys_darwin.go
│ ├── sys_darwin_amd64.s
│ ├── sys_linux_amd64.s
│ ├── sys_nonppc64x.go
│ ├── sys_wasm.go
│ ├── sys_wasm.s
│ ├── sys_x86.go
│ ├── textflag.h
│ ├── time.go
│ ├── time_fake.go
│ ├── time_nofake.go
│ ├── timestub.go
│ ├── timestub2.go
│ ├── trace.go
│ ├── traceback.go
│ ├── type.go
│ ├── typekind.go
│ ├── utf8.go
│ ├── vdso_elf32.go
│ ├── vdso_elf64.go
│ ├── vdso_in_none.go
│ ├── vdso_linux.go
│ ├── vdso_linux_amd64.go
│ └── write_err.go
├── sync
│ ├── atomic
│ │ ├── asm.s
│ │ ├── doc.go
│ │ ├── race.s
│ │ └── value.go
│ ├── cond.go
│ ├── map.go
│ ├── mutex.go
│ ├── once.go
│ ├── pool.go
│ ├── poolqueue.go
│ ├── runtime.go
│ ├── runtime2.go
│ ├── rwmutex.go
│ └── waitgroup.go
├── syscall
│ ├── asm_darwin_amd64.s
│ ├── asm_linux_amd64.s
│ ├── bpf_darwin.go
│ ├── dirent.go
│ ├── endian_little.go
│ ├── env_unix.go
│ ├── exec_darwin.go
│ ├── exec_libc.go
│ ├── exec_linux.go
│ ├── exec_unix.go
│ ├── flock.go
│ ├── flock_darwin.go
│ ├── forkpipe.go
│ ├── forkpipe2.go
│ ├── fs_js.go
│ ├── js
│ │ ├── func.go
│ │ ├── js.go
│ │ ├── js_js.s
│ │ └── js_test.go
│ ├── lsf_linux.go
│ ├── mkall.sh
│ ├── mkasm_darwin.go
│ ├── mkerrors.sh
│ ├── mkpost.go
│ ├── mksyscall.pl
│ ├── mksyscall_libc.pl
│ ├── mksysnum_darwin.pl
│ ├── mksysnum_linux.pl
│ ├── msan.go
│ ├── msan0.go
│ ├── net.go
│ ├── net_js.go
│ ├── netlink_linux.go
│ ├── route_darwin.go
│ ├── setuidgid_linux.go
│ ├── sock_cloexec_linux.go
│ ├── sockcmsg_linux.go
│ ├── sockcmsg_unix.go
│ ├── sockcmsg_unix_other.go
│ ├── str.go
│ ├── syscall.go
│ ├── syscall_darwin.go
│ ├── syscall_darwin_amd64.go
│ ├── syscall_js.go
│ ├── syscall_linux.go
│ ├── syscall_linux_amd64.go
│ ├── syscall_unix.go
│ ├── tables_js.go
│ ├── time_fake.go
│ ├── time_nofake.go
│ ├── timestruct.go
│ ├── types_darwin.go
│ ├── types_linux.go
│ ├── zerrors_darwin_amd64.go
│ ├── zerrors_linux_amd64.go
│ ├── zsyscall_darwin_amd64.go
│ ├── zsyscall_darwin_amd64.s
│ ├── zsyscall_linux_amd64.go
│ ├── zsysnum_darwin_amd64.go
│ ├── zsysnum_linux_amd64.go
│ ├── ztypes_darwin_amd64.go
│ └── ztypes_linux_amd64.go
├── testing
│ ├── allocs.go
│ ├── benchmark.go
│ ├── cover.go
│ ├── match.go
│ └── testing.go
├── time
│ ├── sleep.go
│ ├── tick.go
│ └── time.go
└── unsafe
│ └── unsafe.go
└── website
├── Makefile
├── archetypes
└── default.md
├── config.toml
├── make-cn.go
└── themes
└── book
├── archetypes
├── docs.md
└── posts.md
├── assets
├── _custom.scss
├── _defaults.scss
├── _fonts.scss
├── _main.scss
├── _markdown.scss
├── _print.scss
├── _shortcodes.scss
├── _utils.scss
├── _variables.scss
├── book.scss
├── normalize.css
├── search-data.js
└── search.js
├── i18n
├── cn.yaml
└── en.yaml
├── layouts
├── 404.html
├── home.html
├── partials
│ └── zh-cn
│ │ ├── brand.html
│ │ ├── footer.html
│ │ ├── html-head.html
│ │ ├── inject
│ │ ├── body.html
│ │ ├── footer.html
│ │ ├── head.html
│ │ ├── menu-after.html
│ │ └── menu-before.html
│ │ ├── languages.html
│ │ ├── mathjax-support.html
│ │ ├── menu-bundle.html
│ │ ├── menu-filetree.html
│ │ ├── menu.html
│ │ ├── mobile-header.html
│ │ ├── search.html
│ │ ├── title.html
│ │ └── toc.html
├── posts
│ ├── baseof.html
│ ├── list.html
│ └── single.html
├── shortcodes
│ ├── button.html
│ ├── columns.html
│ ├── expand.html
│ ├── hint.html
│ ├── mermaid.html
│ ├── tab.html
│ └── tabs.html
├── taxonomy
│ ├── list.html
│ └── taxonomy.html
└── zh-cn
│ ├── baseof.html
│ ├── list.html
│ └── single.html
├── static
├── dark.js
├── favicon.png
├── flexsearch.min.js
├── fonts
│ ├── roboto-mono-v6-latin-regular.woff
│ ├── roboto-mono-v6-latin-regular.woff2
│ ├── roboto-v19-latin-300italic.woff
│ ├── roboto-v19-latin-300italic.woff2
│ ├── roboto-v19-latin-700.woff
│ ├── roboto-v19-latin-700.woff2
│ ├── roboto-v19-latin-regular.woff
│ └── roboto-v19-latin-regular.woff2
├── magic.js
├── mermaid.min.js
└── svg
│ ├── calendar.svg
│ ├── edit.svg
│ ├── menu.svg
│ └── translate.svg
└── theme.toml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [changkun] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: # Replace with a single Patreon username
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: 报告错误
4 |
5 | ---
6 |
7 | ## 实际描述
8 |
9 | - 文件路径:例如,book/zh-cn/part2runtime/ch06sched/init.md
10 | - 原文段落:
11 |
12 | ```
13 | 复制原文段落
14 | ```
15 |
16 | ## 预期描述
17 |
18 | ```
19 | 修改后的段落
20 | ```
21 |
22 | ## 附图
23 |
24 | 必要时,请附上相关截图
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: 内容建议
4 |
5 | ---
6 |
7 | ## 动机
8 |
9 | 请描述你提交内容建议的动机。
10 |
11 | ## 需求说明
12 |
13 | 请描述你提交内容建议的详单,
14 | 例如具体是增加哪个 Go 源码模块(或文件)的源码分析。
15 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/Question.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Question
3 | about: 提交问题
4 |
5 | ---
6 |
7 | ## 问题描述
8 |
9 | 请在此描述你的问题,提问前请参考[提问的智慧](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md)
10 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | resolve #issue_id
2 |
3 | ## 说明
4 |
5 | 此处详细说明 PR 的动机是什么、解决了什么样的问题。
6 |
7 | ## 变化箱单
8 |
9 | - 修复了 XXX 的 typo 错误
10 | - 增加了 XXX 相关的说明
11 | - 解决了关于 XXX 的描述性错误
12 |
13 | ## 参考文献
14 |
15 | 如果有请注明
16 |
--------------------------------------------------------------------------------
/README.en-us.md:
--------------------------------------------------------------------------------
1 | # Go: Under The Hood
2 |
3 | 
4 | 
5 | 
6 | [](https://www.paypal.me/changkunde/4.99eur) 
7 |
8 | 🇬🇧 English version of the book is not provided yet, the author apologies for any inconveniences.
9 |
10 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/book/assets/alipay.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/alipay.jpg
--------------------------------------------------------------------------------
/book/assets/bench-perflock.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/bench-perflock.png
--------------------------------------------------------------------------------
/book/assets/bench-significant.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/bench-significant.png
--------------------------------------------------------------------------------
/book/assets/benchstat-rbtree-correct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/benchstat-rbtree-correct.png
--------------------------------------------------------------------------------
/book/assets/benchstat-rbtree-wrong.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/benchstat-rbtree-wrong.png
--------------------------------------------------------------------------------
/book/assets/book.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/book.png
--------------------------------------------------------------------------------
/book/assets/boot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/boot.png
--------------------------------------------------------------------------------
/book/assets/cgo-go-c.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/cgo-go-c.png
--------------------------------------------------------------------------------
/book/assets/chan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/chan.png
--------------------------------------------------------------------------------
/book/assets/cover-cn-v2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/cover-cn-v2.png
--------------------------------------------------------------------------------
/book/assets/cover-cn-v3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/cover-cn-v3.png
--------------------------------------------------------------------------------
/book/assets/cover-cn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/cover-cn.png
--------------------------------------------------------------------------------
/book/assets/cover.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/cover.png
--------------------------------------------------------------------------------
/book/assets/defer-link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/defer-link.png
--------------------------------------------------------------------------------
/book/assets/defer-perf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/defer-perf.png
--------------------------------------------------------------------------------
/book/assets/errors-branch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/errors-branch.png
--------------------------------------------------------------------------------
/book/assets/errors-chan.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/errors-chan.png
--------------------------------------------------------------------------------
/book/assets/g-status.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/g-status.png
--------------------------------------------------------------------------------
/book/assets/gc-blueprint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc-blueprint.png
--------------------------------------------------------------------------------
/book/assets/gc-mutator.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc-mutator.png
--------------------------------------------------------------------------------
/book/assets/gc-pacing.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc-pacing.png
--------------------------------------------------------------------------------
/book/assets/gc-phase.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc-phase.png
--------------------------------------------------------------------------------
/book/assets/gc-wb-dijkstra.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc-wb-dijkstra.png
--------------------------------------------------------------------------------
/book/assets/gc-wb-yuasa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc-wb-yuasa.png
--------------------------------------------------------------------------------
/book/assets/gc1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc1.png
--------------------------------------------------------------------------------
/book/assets/gc2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc2.png
--------------------------------------------------------------------------------
/book/assets/gc3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/gc3.png
--------------------------------------------------------------------------------
/book/assets/header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/header.png
--------------------------------------------------------------------------------
/book/assets/map-syncmap.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/map-syncmap.png
--------------------------------------------------------------------------------
/book/assets/map-write-performance.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/map-write-performance.png
--------------------------------------------------------------------------------
/book/assets/mem-struct.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/mem-struct.png
--------------------------------------------------------------------------------
/book/assets/p-status.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/p-status.png
--------------------------------------------------------------------------------
/book/assets/proc-stack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/proc-stack.png
--------------------------------------------------------------------------------
/book/assets/raw/bench.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/bench.graffle
--------------------------------------------------------------------------------
/book/assets/raw/book.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/book.graffle
--------------------------------------------------------------------------------
/book/assets/raw/boot.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/boot.graffle
--------------------------------------------------------------------------------
/book/assets/raw/chan.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/chan.graffle
--------------------------------------------------------------------------------
/book/assets/raw/cover-cn-v2.afphoto:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/cover-cn-v2.afphoto
--------------------------------------------------------------------------------
/book/assets/raw/cover-cn.afphoto:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/cover-cn.afphoto
--------------------------------------------------------------------------------
/book/assets/raw/cover.afphoto:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/cover.afphoto
--------------------------------------------------------------------------------
/book/assets/raw/defer.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/defer.graffle
--------------------------------------------------------------------------------
/book/assets/raw/errors.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/errors.graffle
--------------------------------------------------------------------------------
/book/assets/raw/gc-picture.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc-picture.graffle
--------------------------------------------------------------------------------
/book/assets/raw/gc-vis.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc-vis.graffle
--------------------------------------------------------------------------------
/book/assets/raw/gc.graffle/data.plist:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc.graffle/data.plist
--------------------------------------------------------------------------------
/book/assets/raw/gc.graffle/image2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc.graffle/image2.png
--------------------------------------------------------------------------------
/book/assets/raw/gc.graffle/image3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc.graffle/image3.png
--------------------------------------------------------------------------------
/book/assets/raw/gc.graffle/image4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc.graffle/image4.png
--------------------------------------------------------------------------------
/book/assets/raw/gc.graffle/image5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc.graffle/image5.png
--------------------------------------------------------------------------------
/book/assets/raw/gc.graffle/preview.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/gc.graffle/preview.jpeg
--------------------------------------------------------------------------------
/book/assets/raw/header-2.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/header-2.afdesign
--------------------------------------------------------------------------------
/book/assets/raw/header.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/header.afdesign
--------------------------------------------------------------------------------
/book/assets/raw/mem.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/mem.graffle
--------------------------------------------------------------------------------
/book/assets/raw/sched-numa.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/sched-numa.graffle
--------------------------------------------------------------------------------
/book/assets/raw/sched.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/sched.graffle
--------------------------------------------------------------------------------
/book/assets/raw/signal-handler.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/signal-handler.graffle
--------------------------------------------------------------------------------
/book/assets/raw/stack.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/stack.graffle
--------------------------------------------------------------------------------
/book/assets/raw/timers.graffle:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/timers.graffle
--------------------------------------------------------------------------------
/book/assets/raw/warning.afphoto:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/raw/warning.afphoto
--------------------------------------------------------------------------------
/book/assets/sched-init.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/sched-init.png
--------------------------------------------------------------------------------
/book/assets/sched-numa.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/sched-numa.png
--------------------------------------------------------------------------------
/book/assets/schedule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/schedule.png
--------------------------------------------------------------------------------
/book/assets/signal-handler.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/signal-handler.png
--------------------------------------------------------------------------------
/book/assets/timers.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/timers.png
--------------------------------------------------------------------------------
/book/assets/warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/warning.png
--------------------------------------------------------------------------------
/book/assets/wechat.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/book/assets/wechat.jpg
--------------------------------------------------------------------------------
/book/backlog/ch01proc/compile.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1106
3 | title: "1.6 编译与链接原理"
4 | bookHidden: true
5 | ---
6 |
7 | # 1.6 编译与链接原理
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch01proc/cpu.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1105
3 | title: "1.5 CPU 设计与架构"
4 | bookHidden: true
5 | ---
6 |
7 | ## 1.5 CPU 设计与架构
8 |
9 |
10 | - 此处暂时记录平台相关差异
11 | - 考虑成书时要么加入所有平台的比较、要么只考虑 darwin/linux,amd64
12 |
13 | ## amd64p32
14 |
15 | - amd64p32 具有 ptrSize == 4 的大小但 CALL 指令仍然在栈中存储了 8 字节的 PC。
16 | - `runtime.dataOffset`: amd64p32 表示 32 位指针仍然使用 64 位对齐布局。
17 | - amd64p32 (NaCl) 不支持 AES 指令
--------------------------------------------------------------------------------
/book/backlog/ch01proc/os.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1103
3 | title: "1.3 系统内核与系统调用"
4 | bookHidden: true
5 | ---
6 |
7 | # 1.3 系统内核与系统调用
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch01proc/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1100
3 | title: "第 1 章 程序基础"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 1 章 程序基础
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | > _就在我们启动 Go 语言项目的那段时间,我尝试去读 C++ 0x 的草案,结果这成了说服我对 Go 语言如此热衷的原因。_
17 | >
18 | > _The reason I was enthusiastic about Go is because, at the same time we were starting on Go, I tried to read the C++ 0x proposed standard, that was the convincer for me._
19 | >
20 | > -- Ken Thompson
21 |
22 |
23 |
24 | ## 许可
25 |
26 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
27 |
--------------------------------------------------------------------------------
/book/backlog/ch01proc/stack.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1102
3 | title: "1.2 传统程序堆栈"
4 | bookHidden: true
5 | ---
6 |
7 | # 1.2 传统程序堆栈
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch02parallel/consensus.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1205
3 | title: "2.5 共识技术"
4 | bookHidden: true
5 | ---
6 |
7 |
8 | # 2.5 共识技术
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch02parallel/define.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1201
3 | title: "2.1 并行与并发的基本概念"
4 | ---
5 |
6 | # 2.1 并行与并发的基本概念
7 |
8 |
9 | - Intel Tick-Tock 模型(?可忽略)
10 | - 计算的度量单位
11 | - 摩尔定律的失效
12 | - 串行计算的极限
13 | - 并行算法的优势
14 | - 并行算法的难点
15 | - Amdahl 定律(下一节?)
16 | - 并行单元的设计
17 | - 串行语义的最小化
18 | - 同步的的最小化
19 | - 局部性原理
20 | - 性能模型与测量
21 | - 寻找优化的目标
22 | - CPU 技术
23 | - RISC vs CISC
24 | - 流水线技术
25 | - 超标量技术
26 | - 乱序执行技术
27 | - 超长指令字技术
28 | - 向量指令技术
29 | - SIMD 技术
30 |
31 | CAS 思想
32 |
33 | ```
34 | for {
35 | 复制旧数据
36 | 基于旧数据构造新数据
37 | if CompareAndSwap(内存地址,旧数据,新数据) {
38 | break
39 | }
40 | }
41 | ```
42 |
43 | ## 许可
44 |
45 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
46 |
--------------------------------------------------------------------------------
/book/backlog/ch02parallel/distributed.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1204
3 | title: "2.4 分布式计算的基本概念"
4 | bookHidden: true
5 | ---
6 |
7 | # 2.4 分布式计算的基本概念
8 |
9 |
10 | 关于时间的研究从牛顿到爱因斯坦,直到相对论的发展,我们才知道了光速与观察者无关。
11 | 根据这个假设,相对论证明了在一个参考系下同时发生的时间,对于相对此参考系运动的观察者并非同时。
12 | 从而对于两个不同的观察者而言,事件顺序可能发生错乱。
13 |
14 | 分布式计算中,物理上时间的概念也具有不确定性。我们不禁要问,当需要观察某个分布式系统中,
15 | 某个确定事件的某些状态是否同时出现。这一点可以体现在并行垃圾回收器中,因为我们不可避免的
16 | 需要观察某个对象是否已可以回收,从而需要观察并行线程关于此对象的引用状态以及进程间的通信。
17 |
18 | ## 分布式时序
19 |
20 | 一个分布式系统 $P$ 通常由 N 个进程(或线程)$p_i (i=1, 2, ..., N)$ 组成。
21 |
22 | ## 向量时钟算法
23 |
24 | 向量时钟算法提供了一个 能够得到与事件时序同构的严格偏序关系 $V$,即有若 V(e) < V(e') 则 e < e'。
25 |
26 | 设分布式系统中 N 个进程维护自身的时钟 $V_i$,用于给本地事件加时间戳。当进程发送消息时,附带自身维护的时钟。
27 | 则在初始情况下 $V_i [j] = 0, i,j = 1, 2, ..., N$。
28 |
29 | ## 全局状态谓词
30 |
31 | ## 全局谓词的性质
32 |
33 | ## 小结
34 |
35 | ## 许可
36 |
37 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
38 |
--------------------------------------------------------------------------------
/book/backlog/ch02parallel/locks.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1207
3 | title: "2.7 同步锁"
4 | bookHidden: true
5 | ---
6 |
7 | # 2.7 同步锁
8 |
9 |
10 |
11 | TODO: mutex, spin lock, transactional memory
12 |
13 | TODO: obstruction-free, lock-free, wait-free, wait-free bounded, wait-free population oblivious
14 |
15 | ## 许可
16 |
17 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
18 |
--------------------------------------------------------------------------------
/book/backlog/ch02parallel/perfs.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1203
3 | title: "2.3 性能模型"
4 | bookHidden: true
5 | ---
6 |
7 | # 2.3 性能模型
8 |
9 |
10 | - 性能方程
11 | - memory wall
12 | - Amdahl 定律
13 | - Gustafson 定律
14 | - 经典例子:矩阵乘法的瓶颈, tiling 技巧
15 | - 性能测量
16 |
17 | ## 许可
18 |
19 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
20 |
--------------------------------------------------------------------------------
/book/backlog/ch02parallel/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1200
3 | title: "第 2 章 并行、并发与分布式计算"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 2 章 并行、并发与分布式计算
8 |
9 | - [2.1 并行、并发的基本概念](./define.md)
10 | - [2.2 缓存技术](./cache.md)
11 |
12 |
13 |
14 | - [2.6 顺序进程通讯](./csp.md)
15 |
16 |
17 | ## 许可
18 |
19 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
20 |
--------------------------------------------------------------------------------
/book/backlog/ch03scheduling/interrupt.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1305
3 | title: "3.5 中断与抢占"
4 | bookHidden: true
5 | ---
6 |
7 | # 3.5 中断与抢占
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/backlog/ch03scheduling/queue.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1301
3 | title: "3.1 排队理论"
4 | bookHidden: true
5 | ---
6 |
7 | # 3.1 排队理论
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch03scheduling/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1300
3 | title: "第 3 章 排队与调度理论"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 3 章 排队与调度理论
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | ## 许可
16 |
17 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
18 |
--------------------------------------------------------------------------------
/book/backlog/ch03scheduling/stochastic.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1303
3 | title: "3.3 随机调度模型"
4 | bookHidden: true
5 | ---
6 |
7 | # 3.3 随机调度模型
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch04memory/alloc.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1401
3 | title: "4.1 内存分配器"
4 | bookHidden: true
5 | ---
6 |
7 | # 4.1 内存分配器
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch04memory/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1400
3 | title: "第 4 章 内存管理工程"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 4 章 内存管理工程
8 |
9 |
10 | - [4.2 标记清扫法与三色抽象](./cms.md)
11 | - [4.3 屏障技术](./barrier.md)
12 | - [4.4 垃圾回收统一理论](./unifiedgc.md)
13 |
14 | > _640KB(内存)对于任何人都应该足够了。_
15 | >
16 | > _640KB [of memory] ought to be enough for anybody._
17 | >
18 | > -- Bill Gates
19 |
20 | ## 许可
21 |
22 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
23 |
--------------------------------------------------------------------------------
/book/backlog/ch10abi/callconv.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2503
3 | title: "10.3 调用规范"
4 | bookHidden: true
5 | ---
6 |
7 | # 10.3 调用规范
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch10abi/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2500
3 | title: "第 10 章 兼容与契约"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 10 章 兼容与契约
8 |
9 | - [10.1 运行时系统调用](./syscallrt.md)
10 | - [10.2 用户态系统调用](./syscallpkg.md)
11 |
12 | - [10.4 Cgo](./cgo.md)
13 |
14 |
15 | ## 许可
16 |
17 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/backlog/ch10abi/wasm.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2505
3 | title: "10.5 WebAssembly"
4 | bookHidden: true
5 | ---
6 |
7 | # 10.5 WebAssembly
8 |
9 |
10 | 目前已经有很多关于 WebAssembly 的教程了,事实上中我们并不关心 WebAssembly 本身,相反,我们较为关心的是
11 | 当同时使用 Go 参与的 WebAssembly 时,Go 的运行时究竟与普通的 Go 程序运行时的差异。
12 |
13 | ## 内存分配
14 |
15 | ## goroutine 调度
16 |
17 | ## 垃圾回收
18 |
19 | ## 模拟并发
20 |
21 | ## 系统调用
22 |
23 | ## 进一步阅读的参考文献
24 |
25 | 1. [Go WebAssembly](https://github.com/golang/go/wiki/WebAssembly)
26 |
27 | ## 许可
28 |
29 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/backlog/ch14linker/link.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3402
3 | title: "14.2 模块链接"
4 | bookHidden: true
5 | ---
6 |
7 | # 14.2 模块链接
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/backlog/ch14linker/obj.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3403
3 | title: "14.3 目标文件"
4 | bookHidden: true
5 | ---
6 |
7 | # 14.2 目标文件
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/backlog/ch14linker/plugin.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3404
3 | title: "14.4 plugin 包"
4 | bookHidden: true
5 | ---
6 |
7 | # 14.4 plugin 包
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/backlog/ch14linker/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3400
3 | title: "第 14 章 链接器"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 14 章 链接器
8 |
9 |
10 |
11 |
12 |
13 |
14 | ## 许可
15 |
16 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/backlog/ch16net/fd.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 4201
3 | title: "16.1 文件描述符抽象"
4 | bookHidden: true
5 | ---
6 |
7 | # 16.1 文件描述符抽象
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/ch16net/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 4200
3 | title: "第 16 章 网络操作"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 16 章 网络操作
8 |
9 |
10 |
11 |
12 | ## 许可
13 |
14 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
15 |
--------------------------------------------------------------------------------
/book/backlog/ch16net/routers.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 4202
3 | title: "16.2 路由管理"
4 | bookHidden: true
5 | ---
6 |
7 | # 16.2 路由管理
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/backlog/scavenge.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2310
3 | title: "8.10 清道夫及其调步算法"
4 | bookHidden: true
5 | ---
6 |
7 | # 8.10 清道夫及其调步算法
8 |
9 | TODO: scavenge
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch01basic/history.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1101
3 | title: "1.1 编程语言的发展"
4 | ---
5 |
6 |
7 | ## 许可
8 |
9 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
10 |
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch01basic/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1100
3 | title: "第 1 章 Go 语言的前世今生"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 1 章 Go 语言的前世今生
8 |
9 | - [1.1 编程语言的发展](./history.md)
10 | - [1.2 Go 语言综述](./go.md)
11 | - [1.3 顺序过程通讯](./csp.md)
12 | - [1.4 Plan 9 汇编语言](./asm.md)
13 |
14 |
15 |
16 |
17 | 就在我们启动 Go 语言项目的那段时间,我尝试去读 C++ 0x 的草案,结果这成了说服我对 Go 语言如此热衷的原因。
18 |
19 |
20 | The reason I was enthusiastic about Go is because, at the same time we were starting on Go, I tried to read the C++ 0x proposed standard, that was the convincer for me.
21 |
22 |
23 | -- Ken Thompson
24 |
25 |
26 |
27 | ## 许可
28 |
29 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
30 |
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch02life/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1200
3 | title: "第 2 章 程序生命周期"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 2 章 程序生命周期
8 |
9 | - [2.1 从 `go` 命令谈起](./cmd.md)
10 | - [2.2 编译流程](./compile.md)
11 | - [2.3 启动引导](./boot.md)
12 | - [2.4 主 Goroutine 的生与死](./main.md)
13 |
14 | ## 许可
15 |
16 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
17 |
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch03lang/alias.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1309
3 | title: "3.9 类型别名"
4 | ---
5 |
6 | # 3.9 类型别名
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch03lang/func.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1303
3 | title: "3.3 函数调用"
4 | ---
5 |
6 | # 3.3 函数调用
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch03lang/interface.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1307
3 | title: "3.7 接口"
4 | ---
5 |
6 | # 3.7 接口
7 |
8 | 接口 `interface{}` 作为 Go 语言类型系统中重要的一员,从语义上规定了一组方法集合,
9 | 只要某个类型实现了这一组方法,则这些类型都可以视为同一类型参数进行传递。
10 | 尽管这个理念与鸭子类型(Duck typing)所定义的类似,一个常见的错误观点便是 Go
11 | 是一种支持鸭子类型的语言。事实上,鸭子类型强调的是类型的运行时特性而非编译期特性。
12 | 不巧,Go 语言中的 `interface{}` 恰好只是一种编译期特性,所以 Go 的类型系统
13 | 应该被严谨的描述为**结构化类型系统**(Structural Type System)。
14 |
15 | TODO:
16 |
17 |
18 | ## 进一步阅读的参考文献
19 |
20 | - [Cox, 2009] Russ Cox. Go Data Structures: Interfaces. December 2009. https://research.swtch.com/interfaces
21 |
22 | ## 许可
23 |
24 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
25 |
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch03lang/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1300
3 | title: "第 3 章 语言核心"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 3 章 语言核心
8 |
9 | - [3.1 数组、切片与字符串](./slice.md)
10 | - [3.2 散列表](./map.md)
11 | - [3.3 函数调用](./func.md)
12 | - [3.4 延迟调用](./defer.md)
13 | - [3.5 恐慌与恢复](./panic.md)
14 | - [3.6 通信原语](./chan.md)
15 | - [3.7 接口](./interface.md)
16 | - [3.8 类型系统](./type.md)
17 | - [3.9 类型别名](./alias.md)
18 | - [3.10 进一步阅读的参考文献](./ref.md)
19 |
20 |
21 |
22 |
23 | 大道至简。
24 |
25 |
26 | Simplicity is complicated.
27 |
28 |
29 | -- Rob Pike
30 |
31 |
32 |
33 | ## 许可
34 |
35 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch03lang/ref.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1310
3 | title: "3.10 进一步阅读的参考文献"
4 | ---
5 |
6 | # 3.10 进一步阅读的参考文献
7 |
8 |
9 |
10 |
11 | [Ghemawat and Menage, 2009] Sanjay Ghemawat, Paul Menage. "TCMalloc : Thread-Caching Malloc." Google Inc., 2009 http://goog-perftools.sourceforge.net/doc/tcmalloc.html
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | ## 许可
20 |
21 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
22 |
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch03lang/slice.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1301
3 | title: "3.1 数组、切片与字符串"
4 | ---
5 |
6 | # 3.1 数组、切片与字符串
7 |
8 | TODO:
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch04errors/context.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1403
3 | title: "4.3 错误格式与上下文"
4 | ---
5 |
6 | # 4.3 错误格式与上下文
7 |
8 |
9 |
10 | 错误检查仅仅只提供了编码时对错误链条操作的便利性,但仍然无法从仅由字符串定义的错误值
11 | 获得错误传播链条的上下文信息,例如产生错误的文件位置、具体的行号等等。
12 | 这些信息在大型工程的调试和监控过程中对于错误的定位是相当有用的。
13 | 这也就要求我们需要进一步对错误的格式化添加上下文信息。即第二个问题:
14 | 如何增强错误发生时的上下文信息并合理格式化一个错误?
15 |
16 | ## 4.3.1 错误格式
17 |
18 | ## 4.3.2 错误堆栈
19 |
20 | 堆栈信息与 `runtime.Caller` 的性能优化
21 |
22 | TODO: 讨论目前标准库不具备的能力以及 x/errors 为什么被拒
23 |
24 |
25 | ## 许可
26 |
27 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
28 |
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/ch05sync/basic.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1501
3 | title: "5.1 共享内存式同步模式"
4 | ---
5 |
6 | # 5.1 共享内存式同步模式
7 |
8 | ## 基本概念
9 |
10 | 事件、事件序、先于、并发、
11 |
12 | ## 临界区
13 |
14 | ## 过滤锁
15 |
16 | ## 锁的公平性
17 |
18 | ## Bakery 算法
19 |
20 | ## 共享单元数量的下界
21 |
22 | ## 并发对象的正确性
23 |
24 | ### 静态一致性
25 |
26 | ### 顺序一致性
27 |
28 | ###
29 |
30 | ## 并发对象的前进保障
31 |
32 | ## 许可
33 |
34 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part1basic/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 1000
3 | title: "第一部分 基础篇"
4 | ---
5 |
6 | # 第一部分 基础篇
7 |
8 | - [第 1 章 Go 语言的前世今生](./ch01basic)
9 | - [第 2 章 程序生命周期](./ch02life)
10 | - [第 3 章 语言核心](./ch03lang)
11 | - [第 4 章 错误](./ch04errors)
12 | - [第 5 章 同步模式](./ch05sync)
13 |
14 | ## 许可
15 |
16 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
17 |
--------------------------------------------------------------------------------
/book/zh-cn/part2runtime/ch06sched/poller.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2110
3 | title: "6.10 网络轮询器"
4 | ---
5 |
6 | # 6.10 网络轮询器
7 |
8 | ## 许可
9 |
10 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
11 |
--------------------------------------------------------------------------------
/book/zh-cn/part2runtime/ch07alloc/history.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2209
3 | title: "7.9 过去、现在与未来"
4 | bookHidden: true
5 | ---
6 |
7 | # 7.9 过去、现在与未来
8 |
9 | ## 许可
10 |
11 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
12 |
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part2runtime/ch07alloc/pagealloc.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2207
3 | title: "7.7 页分配器"
4 | bookHidden: true
5 | ---
6 |
7 | # 7.7 页分配器
8 |
9 | ## 许可
10 |
11 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
12 |
--------------------------------------------------------------------------------
/book/zh-cn/part2runtime/ch07alloc/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2200
3 | title: "第 7 章 内存分配"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 7 章 内存分配
8 |
9 | - [7.1 设计原则](./basic.md)
10 | - [7.2 组件](./component.md)
11 | - [7.3 初始化](./init.md)
12 | - [7.4 大对象分配](./largealloc.md)
13 | - [7.5 小对象分配](./smallalloc.md)
14 | - [7.6 微对象分配](./tinyalloc.md)
15 | - [7.7 页分配器](./pagealloc.md)
16 | - [7.9 过去、现在与未来](./history.md)
17 |
18 |
19 |
20 |
21 | 640KB(内存)对于任何人来说都应该足够了。
22 |
23 |
24 | 640KB [of memory] ought to be enough for anybody.
25 |
26 |
27 | -- Bill Gates
28 |
29 |
30 |
31 | ## 许可
32 |
33 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
34 |
--------------------------------------------------------------------------------
/book/zh-cn/part2runtime/ch08GC/generational.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2308
3 | title: "8.8 分代假设与代际回收"
4 | ---
5 |
6 | # 8.8 分代假设与代际回收
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part2runtime/ch08GC/roc.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2309
3 | title: "8.9 请求假设与事务制导回收"
4 | ---
5 |
6 | # 8.9 请求假设与事务制导回收
7 |
8 |
9 |
10 | ROC 的全称是面向请求的回收器(Request Oriented Collector),它其实也是分代 GC 的一种重新叙述。它提出了一个请求假设(Request Hypothesis):与一个完整请求、休眠 goroutine 所关联的对象比其他对象更容易死亡。
11 |
12 | ## 许可
13 |
14 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
15 |
--------------------------------------------------------------------------------
/book/zh-cn/part2runtime/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 2000
3 | title: "第二部分 运行时篇"
4 | ---
5 |
6 | # 第二部分 运行时篇
7 |
8 | - [第 6 章 调度器](./ch06sched)
9 | - [第 7 章 内存分配器](./ch07alloc)
10 | - [第 8 章 垃圾回收器](./ch08GC)
11 |
12 | ## 许可
13 |
14 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
15 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch09analysis/gopls.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3107
3 | title: "9.7 语言服务协议"
4 | ---
5 |
6 | # 9.7 语言服务协议
7 |
8 | ## 许可
9 |
10 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch09analysis/metric.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3106
3 | title: "9.6 运行时统计量"
4 | ---
5 |
6 | # 9.6 运行时统计量
7 |
8 | ## 许可
9 |
10 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch09analysis/race.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3102
3 | title: "9.2 竞争检查"
4 | ---
5 |
6 | # 9.2 竞争检查
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch09analysis/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3100
3 | title: "第 9 章 代码分析"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 9 章 代码分析
8 |
9 | - [9.1 死锁检测](./deadlock.md)
10 | - [9.2 竞争检测](./race.md)
11 | - [9.3 性能追踪](./trace.md)
12 | - [9.4 代码测试](./testing.md)
13 | - [9.5 基准测试](./perf.md)
14 | - [9.6 运行时统计量](./metric.md)
15 | - [9.7 语言服务协议](./gopls.md)
16 |
17 |
18 |
19 |
20 | 每个人都知道调试的难度是编写程序的两倍。如果你在编码时尽可能聪明,这样的程序你怎么调试得了呢?
21 |
22 |
23 | Everyone knows that debugging is twice as hard as writing a program in the first place. So if you are as clever as you can be when you write it, how will you ever debug it?
24 |
25 |
26 | -- Brian Kernighan
27 |
28 |
29 |
30 | ## 许可
31 |
32 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch09analysis/testing.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3104
3 | title: "9.4 代码测试"
4 | ---
5 |
6 | # 9.4 代码测试
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch09analysis/trace.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3103
3 | title: "9.3 性能追踪"
4 | ---
5 |
6 | # 9.3 性能追踪
7 |
8 |
9 |
10 | ## 进一步阅读的参考文献
11 |
12 | - [Hiltner 2017] [Rhys Hiltner, An Introduction to go tool trace, July 13, 2017](https://about.sourcegraph.com/go/an-introduction-to-go-tool-trace-rhys-hiltner)
13 |
14 | ## 许可
15 |
16 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
17 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch10deps/challenges.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3201
3 | title: "10.1 依赖管理的难点"
4 | ---
5 |
6 | # 10.1 依赖管理的难点
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch10deps/fight.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3204
3 | title: "10.4 vgo 与 dep 之争"
4 | ---
5 |
6 | # 10.4 vgo 与 dep 之争
7 |
8 |
9 |
10 | - [Cox, 2018] Russ Cox. cmd/go: add package version support to Go toolchain. Mar 7, 2018. https://github.com/golang/go/issues/24301
11 |
12 | ## 许可
13 |
14 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
15 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch10deps/minimum.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3203
3 | title: "10.3 最小版本选择算法"
4 | ---
5 |
6 | # 10.3 最小版本选择算法
7 |
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch10deps/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3200
3 | title: "第 10 章 依赖管理"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 10 章 依赖管理
8 |
9 | - [10.1 依赖管理的难点](./challenges.md)
10 | - [10.2 语义化版本管理](./semantics.md)
11 | - [10.3 最小版本选择算法](./minimum.md)
12 | - [10.4 vgo 与 dep 之争](./fight.md)
13 |
14 |
15 |
16 |
17 | 怎么不看看其他语言怎么做的呢?Java 有 Maven、Node 有 NPM、Ruby 有 Bundler,而且 Rust 有 Cargo。(依赖管理)怎么就成了一个未解决的问题了呢?
18 |
19 |
20 | Why not do what other languages do? Java has Maven, Node has NPM, Ruby has Bundler, Rust has Cargo. How is this not a solved problem?
21 |
22 |
23 | -- Russ Cox
24 |
25 |
26 |
27 | ## 许可
28 |
29 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch10deps/semantics.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3202
3 | title: "10.2 语义化版本管理"
4 | ---
5 |
6 | # 10.2 语义化版本管理
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch11compile/asm.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3308
3 | title: "13.8 调用规范"
4 | ---
5 |
6 | # 13.8 调用规范
7 |
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch11compile/callconv.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3309
3 | title: "13.9 调用规范"
4 | ---
5 |
6 | # 13.9 调用规范
7 |
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch11compile/escape.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3305
3 | title: "13.5 逃逸分析"
4 | ---
5 |
6 | # 13.5 逃逸分析
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch11compile/future.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3306
3 | title: "13.6 过去、现在与未来"
4 | bookHidden: true
5 | ---
6 |
7 | # 13.6 过去、现在与未来
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch11compile/link.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3307
3 | title: "13.7 模块链接"
4 | ---
5 |
6 | # 13.7 模块链接
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch11compile/optimize.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3303
3 | title: "13.3 优化器"
4 | ---
5 |
6 | # 13.3 优化器
7 |
8 |
9 |
10 | ## 许可
11 |
12 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
13 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch11compile/parse.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3301
3 | title: "13.1 词法与文法"
4 | ---
5 |
6 | # 13.1 词法与文法
7 |
8 |
9 |
10 |
11 | ## 许可
12 |
13 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
14 |
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch12generics/checker.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3403
3 | title: "12.3 类型检查技术"
4 | ---
5 |
6 | # 12.3 类型检查技术
7 |
8 | ## 许可
9 |
10 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/ch12generics/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3400
3 | title: "第 12 章 泛型"
4 | bookCollapseSection: true
5 | ---
6 |
7 | # 第 12 章 泛型
8 |
9 | - [12.1 泛型设计的演进](./history.md)
10 | - [12.2 基于合约的泛型](./contracts.md)
11 | - [12.3 类型检查技术](./checker.md)
12 | - [12.4 泛型的未来](./future.md)
13 | - [12.5 进一步阅读的参考文献](./ref.md)
14 |
15 |
16 |
17 |
从某种意义上说,「概念」是一个古老的话题;但人们总觉得这是一个全新的内容。
18 |
"Concepts", in some ways, that's a very old topic; and other thinks it's new.
19 |
20 | -- Bjarne Stroustrup, "Concepts: The Future of Generic Programming"
21 |
22 |
23 |
24 | 泛型编程的基本想法围绕如何对具体、高效的算法进行抽象,并在结合考虑不同数据表示的过程中形成多种多样且通用的泛型算法。
25 |
26 | ## 许可
27 |
28 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
--------------------------------------------------------------------------------
/book/zh-cn/part3tools/readme.md:
--------------------------------------------------------------------------------
1 | ---
2 | weight: 3000
3 | title: "第三部分 工具链篇"
4 | ---
5 |
6 | # 第三部分 工具链篇
7 |
8 | - [第 9 章 代码分析](./ch09analysis)
9 | - [第 10 章 依赖管理](./ch10deps)
10 | - [第 11 章 编译技术](./ch11compile)
11 | - [第 12 章 泛型](./ch12generics)
12 |
13 | ## 许可
14 |
15 | © 2018-2020 The [golang.design](https://golang.design) Initiative Authors. Licensed under [CC-BY-NC-ND 4.0](https://creativecommons.org/licenses/by-nc-nd/4.0/).
16 |
--------------------------------------------------------------------------------
/demo/ch05boot/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main1 main1.go
3 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main2 main2.go
4 | go tool objdump -s "main.init" main1 > main1.S
5 | go tool objdump -s "main.init" main2 > main2.S
6 | clean:
7 | rm -rf main1 main1.S main2 main2.S
--------------------------------------------------------------------------------
/demo/ch05boot/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | println("hello, world!")
5 | }
6 |
--------------------------------------------------------------------------------
/demo/ch05boot/main1.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | _ "net/http"
6 | )
7 |
8 | func init() {
9 | println("func main.init")
10 | }
11 |
12 | func main() {
13 | fmt.Printf("hello, %s", "world!")
14 | }
15 |
--------------------------------------------------------------------------------
/demo/ch05boot/main2.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | _ "net/http"
5 |
6 | "fmt"
7 | )
8 |
9 | func init() {
10 | println("func main.init")
11 | }
12 |
13 | func main() {
14 | fmt.Printf("hello, %s", "world!")
15 | }
16 |
--------------------------------------------------------------------------------
/demo/ch06sched/exec/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "fmt"
4 |
5 | const RegSize = 4 << (^uint32(0) >> 63)
6 |
7 | func main() {
8 | var controlWord64 uint16 = 0x3f + 2<<8 + 0<<10
9 | fmt.Printf("%x\n", controlWord64)
10 |
11 | var siz int32 = 0
12 | siz = (siz + 7) &^ 7
13 | fmt.Printf("%d\n", siz)
14 |
15 | totalSize := 4*RegSize + uintptr(siz)
16 | totalSize += -totalSize & 0
17 | fmt.Printf("%d\n", RegSize)
18 | fmt.Printf("%d\n", totalSize)
19 | }
20 |
--------------------------------------------------------------------------------
/demo/ch06sched/init/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func round2(x int32) int32 {
4 | s := uint(0)
5 | for 1< main.S
4 | clean:
5 | rm -rf main.out main.S
--------------------------------------------------------------------------------
/demo/ch06sched/peer/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "time"
4 |
5 | func longcall() {
6 | for {
7 | time.Sleep(time.Second)
8 | }
9 | }
10 |
11 | func main() {
12 | go longcall()
13 |
14 | for {
15 | time.Sleep(time.Second)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/demo/ch06sched/preemption/main:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/demo/ch06sched/preemption/main
--------------------------------------------------------------------------------
/demo/ch06sched/preemption/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "runtime"
5 | "time"
6 | )
7 |
8 | func main() {
9 | runtime.GOMAXPROCS(1)
10 |
11 | go func() {
12 | for {
13 | }
14 | }()
15 |
16 | time.Sleep(time.Millisecond)
17 | println("OK")
18 | runtime.Gosched()
19 | }
20 |
--------------------------------------------------------------------------------
/demo/ch07mem/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main.out main.go
3 | go tool objdump -s "main.main" main.out > main.S
4 | clean:
5 | rm -rf main.out main.S
--------------------------------------------------------------------------------
/demo/ch07mem/alloc/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l -m" -ldflags=-compressdwarf=false -o alloc.out alloc.go
3 | go tool objdump -s "main.*" alloc.out > alloc.S
4 | clean:
5 | rm -rf alloc.out alloc.S
--------------------------------------------------------------------------------
/demo/ch07mem/alloc/alloc.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | type smallobj struct {
4 | arr [1 << 10]byte
5 | }
6 |
7 | type largeobj struct {
8 | arr [1 << 26]byte
9 | }
10 |
11 | func f1() int {
12 | x := 1
13 | return x
14 | }
15 |
16 | func f2() *int {
17 | y := 2
18 | return &y
19 | }
20 |
21 | func f3() {
22 | large := largeobj{}
23 | println(&large)
24 | }
25 |
26 | func f4() {
27 | small := smallobj{}
28 | print(&small)
29 | }
30 |
31 | func main() {
32 | x := f1()
33 | y := f2()
34 | f3()
35 | f4()
36 | println(x, y)
37 | }
38 |
--------------------------------------------------------------------------------
/demo/ch07mem/arenahint/mallocinit.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "fmt"
4 |
5 | // ...
6 | const (
7 | PtrSize = 4 << (^uintptr(0) >> 63)
8 | uintptrMask = 1<<(8*PtrSize) - 1
9 | )
10 |
11 | func main() {
12 | var p uintptr
13 | for i := 0x7f; i >= 0; i-- {
14 | p = uintptr(i)<<40 | uintptrMask&(0x00c0<<32)
15 | fmt.Printf("addr: %x\n", p)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/demo/ch07mem/main.S:
--------------------------------------------------------------------------------
1 | TEXT main.main(SB) /Users/changkun/dev/go-under-the-hood/demo/5-mem/main.go
2 | main.go:3 0x104e020 65488b0c2530000000 MOVQ GS:0x30, CX
3 | main.go:3 0x104e029 483b6110 CMPQ 0x10(CX), SP
4 | main.go:3 0x104e02d 761a JBE 0x104e049
5 | main.go:3 0x104e02f 4883ec08 SUBQ $0x8, SP
6 | main.go:3 0x104e033 48892c24 MOVQ BP, 0(SP)
7 | main.go:3 0x104e037 488d2c24 LEAQ 0(SP), BP
8 | main.go:4 0x104e03b e8e0ffffff CALL main.main(SB)
9 | main.go:5 0x104e040 488b2c24 MOVQ 0(SP), BP
10 | main.go:5 0x104e044 4883c408 ADDQ $0x8, SP
11 | main.go:5 0x104e048 c3 RET
12 | main.go:3 0x104e049 e87289ffff CALL runtime.morestack_noctxt(SB)
13 | main.go:3 0x104e04e ebd0 JMP main.main(SB)
14 |
--------------------------------------------------------------------------------
/demo/ch07mem/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | main()
5 | }
6 |
--------------------------------------------------------------------------------
/demo/ch07mem/memorder/main.go:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/demo/ch07mem/memorder/main.go
--------------------------------------------------------------------------------
/demo/ch07mem/memorder_test.go:
--------------------------------------------------------------------------------
1 | package main_test
2 |
3 | import "testing"
4 |
5 | func TestMemOrder(t *testing.T) {
6 | var a, b int
7 |
8 | f := func() {
9 | a = 1
10 | b = 2
11 | }
12 |
13 | g := func() {
14 | println(b)
15 | println(a)
16 | }
17 |
18 | go f()
19 | g()
20 | }
21 |
--------------------------------------------------------------------------------
/demo/ch07mem/mstats/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "runtime"
6 | )
7 |
8 | func main() {
9 | var mem runtime.MemStats
10 | runtime.ReadMemStats(&mem)
11 | fmt.Printf("%+v\n", mem)
12 | }
13 |
--------------------------------------------------------------------------------
/demo/ch08GC/evil/cpu.prof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/demo/ch08GC/evil/cpu.prof
--------------------------------------------------------------------------------
/demo/ch08GC/evil/evil_test.go:
--------------------------------------------------------------------------------
1 | package main_test
2 |
3 | import (
4 | "testing"
5 | )
6 |
7 | func BenchmarkGC(b *testing.B) {
8 | b.RunParallel(func(pb *testing.PB) {
9 | for pb.Next() {
10 | _ = make([]byte, 1*1024*1024*1024) // 1GB
11 | }
12 | })
13 | }
14 |
--------------------------------------------------------------------------------
/demo/ch08GC/evil/mem.prof:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/demo/ch08GC/evil/mem.prof
--------------------------------------------------------------------------------
/demo/ch08GC/leak/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 | "runtime/trace"
6 | )
7 |
8 | func main() {
9 | trace.Start(os.Stderr)
10 | defer trace.Stop()
11 | for i := 0; i < 100000; i++ {
12 | go func() {
13 | select {}
14 | }()
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/demo/ch08GC/stw/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "runtime"
5 | "time"
6 | )
7 |
8 | func main() {
9 | go func() {
10 | for {
11 | }
12 | }()
13 |
14 | time.Sleep(time.Millisecond)
15 | runtime.GC()
16 | println("OK")
17 | }
18 |
--------------------------------------------------------------------------------
/demo/ch08GC/trigger/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 | "runtime"
6 | "runtime/trace"
7 | "sync/atomic"
8 | )
9 |
10 | var stop uint64
11 |
12 | func gcfinished() *int {
13 | p := 1
14 | runtime.SetFinalizer(&p, func(_ *int) {
15 | println("gc finished")
16 | atomic.StoreUint64(&stop, 1)
17 | })
18 | return &p
19 | }
20 |
21 | func allocate() {
22 | _ = make([]byte, int((1<<20)*0.25))
23 | }
24 |
25 | func main() {
26 | f, _ := os.Create("trace.out")
27 | defer f.Close()
28 | trace.Start(f)
29 | defer trace.Stop()
30 | gcfinished()
31 | for n := 1; atomic.LoadUint64(&stop) != 1; n++ {
32 | println("#allocate: ", n)
33 | allocate()
34 | }
35 | println("terminate")
36 | }
37 |
--------------------------------------------------------------------------------
/demo/ch09lang/chan/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o chan.out chan.go
3 | go tool objdump -s "main.main" chan.out > chan.S
4 | clean:
5 | rm -rf chan.out chan.S
--------------------------------------------------------------------------------
/demo/ch09lang/chan/chan.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | var x chan int
5 | go func() {
6 | x <- 1
7 | }()
8 | select {
9 | case v := <-x:
10 | println(v)
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/demo/ch09lang/defer/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o defer.out defer.go
3 | go tool objdump -s "main.main" defer.out > defer.S
4 | clean:
5 | rm -rf defer.out defer.S
--------------------------------------------------------------------------------
/demo/ch09lang/defer/defer.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | defer println("hello, world!")
5 | }
6 |
--------------------------------------------------------------------------------
/demo/ch09lang/defer/defer_test.go:
--------------------------------------------------------------------------------
1 | package main_test
2 |
3 | import (
4 | "sync"
5 | "testing"
6 | )
7 |
8 | var lock sync.Mutex
9 |
10 | func NoDefer() {
11 | lock.Lock()
12 | lock.Unlock()
13 | }
14 | func Defer() {
15 | lock.Lock()
16 | defer lock.Unlock()
17 | }
18 |
19 | func BenchmarkNoDefer(b *testing.B) {
20 | for i := 0; i < b.N; i++ {
21 | NoDefer()
22 | }
23 | }
24 |
25 | func BenchmarkDefer(b *testing.B) {
26 | for i := 0; i < b.N; i++ {
27 | Defer()
28 | }
29 | }
30 |
31 | func foo(x int) int {
32 | // fast path
33 | if x != 42 {
34 | return x
35 | }
36 | // slow path
37 | mu.Lock()
38 | defer mu.Unlock()
39 | seq++
40 | return seq
41 | }
42 |
43 | var (
44 | mu sync.Mutex
45 | seq int
46 | )
47 |
48 | func BenchmarkFastpathDefer(b *testing.B) {
49 | for i := 0; i < b.N; i++ {
50 | foo(0)
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/demo/ch09lang/defer/semantics/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "math/rand"
5 | "time"
6 | )
7 |
8 | func randomDefer() {
9 | rand.Seed(time.Now().UnixNano())
10 | for rand.Intn(100) > 42 {
11 | defer func() {
12 | println("golang-design/under-the-hood")
13 | }()
14 | }
15 | }
16 |
17 | func main() {
18 | randomDefer()
19 | }
20 |
--------------------------------------------------------------------------------
/demo/ch09lang/go/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main.out main.go
3 | go tool objdump -s "main.main" main.out > main.S
4 | clean:
5 | rm -rf main.out main.S
--------------------------------------------------------------------------------
/demo/ch09lang/go/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func hello(msg string) {
4 | println(msg)
5 | }
6 |
7 | func main() {
8 | go hello("hello world")
9 | }
10 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/assertion/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go tool compile -N -l -S main.go > main.S
3 | clean:
4 | rm -rf main.o main.S
5 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/assertion/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | var u uint32
4 | var i int32
5 | var ok bool
6 | var eface interface{}
7 |
8 | func assertion() {
9 | t := uint64(42)
10 | eface = t
11 | u = eface.(uint32)
12 | i, ok = eface.(int32)
13 | }
14 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/eface/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go tool compile -N -l -S main1.go > main1.S
3 | go tool compile -N -l -S main2.go > main2.S
4 | clean:
5 | rm -rf main1.o main1.S
6 | rm -rf main2.o main2.S
7 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/eface/main1.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | num1 := 3
5 | var num2 interface{} = num1
6 | println(num2)
7 | }
8 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/eface/main2.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | var num2 interface{} = 3
5 | println(num2)
6 | }
7 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/iface/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go tool compile -N -l -S main1.go > main1.S
3 | go tool compile -N -l -S main2.go > main2.S
4 | go run ssa.go > ssa.txt
5 | clean:
6 | rm -rf main1.o main1.S
7 | rm -rf main2.o main2.S
8 | rm -rf ssa.txt
9 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/iface/main1.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | type Person interface {
4 | Name() string
5 | }
6 |
7 | type student struct {
8 | name string
9 | }
10 |
11 | func (s student) Name() string {
12 | return s.name
13 | }
14 |
15 | func main() {
16 | s := student{name: "sean"}
17 | echoName(s)
18 | }
19 |
20 | func echoName(p Person) {
21 | println(p.Name())
22 | }
23 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/iface/main2.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | type Person interface {
4 | Name() string
5 | Age() int
6 | }
7 |
8 | type student struct {
9 | name string
10 | age int
11 | }
12 |
13 | func (s student) Name() string {
14 | return s.name
15 | }
16 |
17 | func (s student) Age() int {
18 | return s.age
19 | }
20 |
21 | func main() {
22 | s := student{name: "sean", age: 20}
23 | echoPerson(s)
24 | }
25 |
26 | func echoPerson(p Person) {
27 | p.Name()
28 | p.Age()
29 | }
30 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/receiver/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go tool compile -N -l -S main4.go > main4.S
3 | go tool compile -N -l -S main3.go > main3.S
4 | go tool compile -N -l -S main2.go > main2.S
5 | go tool compile -N -l -S main1.go > main1.S
6 | clean:
7 | rm -rf main1.o main1.S
8 | rm -rf main2.o main2.S
9 | rm -rf main3.o main3.S
10 | rm -rf main4.o main4.S
11 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/receiver/main1.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | type Person interface {
4 | Name() string
5 | }
6 |
7 | type student struct {
8 | name string
9 | }
10 |
11 | func (s *student) Name() string {
12 | return s.name
13 | }
14 |
15 | func main() {
16 | s := student{name: "sean"}
17 | echoName(s)
18 | }
19 |
20 | func echoName(p Person) {
21 | println(p.Name())
22 | }
23 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/receiver/main2.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | type Person interface {
4 | Name() string
5 | }
6 |
7 | type student struct {
8 | name string
9 | }
10 |
11 | func (s *student) Name() string {
12 | return s.name
13 | }
14 |
15 | func main() {
16 | s := &student{name: "sean"}
17 | echoName(s)
18 | }
19 |
20 | func echoName(p Person) {
21 | println(p.Name())
22 | }
23 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/receiver/main3.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | type Person interface {
4 | Name() string
5 | }
6 |
7 | type student struct {
8 | name string
9 | }
10 |
11 | func (s student) Name() string {
12 | return s.name
13 | }
14 |
15 | func main() {
16 | s := student{name: "sean"}
17 | echoName(s)
18 | }
19 |
20 | func echoName(p Person) {
21 | println(p.Name())
22 | }
23 |
--------------------------------------------------------------------------------
/demo/ch09lang/interface/receiver/main4.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | type Person interface {
4 | Name() string
5 | }
6 |
7 | type student struct {
8 | name string
9 | }
10 |
11 | func (s student) Name() string {
12 | return s.name
13 | }
14 |
15 | func main() {
16 | s := &student{name: "sean"}
17 | echoName(s)
18 | }
19 |
20 | func echoName(p Person) {
21 | println(p.Name())
22 | }
23 |
--------------------------------------------------------------------------------
/demo/ch09lang/map/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main.out main.go
3 | go tool objdump -s "main.write" main.out > main.S
4 | clean:
5 | rm -rf main.out main.S
--------------------------------------------------------------------------------
/demo/ch09lang/map/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "time"
6 | )
7 |
8 | func write() {
9 | var step int64 = 1000000
10 | var t1 time.Time
11 | m := map[int64]int64{}
12 | for i := int64(0); ; i += step {
13 | t1 = time.Now()
14 | for j := int64(0); j < step; j++ {
15 | m[i+j] = i + j
16 | }
17 | fmt.Printf("%d done, time: %v\n", i, time.Since(t1).Seconds())
18 | }
19 | }
20 |
21 | func main() {
22 | write()
23 | }
24 |
--------------------------------------------------------------------------------
/demo/ch09lang/panic/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main.out main.go
3 | go tool objdump -s "main.main" main.out > main.S
4 | clean:
5 | rm -rf main.out main.S
--------------------------------------------------------------------------------
/demo/ch09lang/panic/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | func main() {
4 | defer func() {
5 | recover()
6 | }()
7 | panic(nil)
8 | }
9 |
--------------------------------------------------------------------------------
/demo/ch09lang/panic/main2.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "fmt"
4 |
5 | // func panicf1() {
6 | // defer func() {
7 | // println("1")
8 | // }()
9 | // panic("panic at panicf1")
10 | // defer func() {
11 | // println("not reach")
12 | // }()
13 | // }
14 |
15 | // func panicf2() {
16 | // defer func() {
17 | // println("3")
18 | // }()
19 | // }
20 |
21 | // func main() {
22 | // defer func() {
23 | // if r := recover(); r != nil {
24 | // fmt.Printf("%s\n", r)
25 | // }
26 | // }()
27 | // panicf1()
28 | // panicf2()
29 | // }
30 |
31 | func panicf1() {
32 | defer func() {
33 | println("1")
34 | }()
35 | panicf2()
36 | }
37 |
38 | func panicf2() {
39 | panic("panic at panicf2")
40 | }
41 |
42 | func main() {
43 | defer func() {
44 | if r := recover(); r != nil {
45 | fmt.Printf("%s\n", r)
46 | }
47 | }()
48 | panicf1()
49 | }
50 |
--------------------------------------------------------------------------------
/demo/ch10abi/cgo/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | go build -v -o main main.go
3 | go tool cgo main.go
4 | go tool objdump -s "(main.main)|(main._Cfunc_print)" main > main.S
5 | clean:
6 | rm -rf main main.S _obj
--------------------------------------------------------------------------------
/demo/ch10abi/cgo/ccallgo/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | go build -x -o gofunc/hello.so -buildmode=c-shared gofunc/hello.go
3 | gcc main.c -o main gofunc/hello.so
4 | clean:
5 | rm -rf main gofunc/hello.h gofunc/hello.so
--------------------------------------------------------------------------------
/demo/ch10abi/cgo/ccallgo/gofunc/hello.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "C"
4 | import "fmt"
5 |
6 | //export hello
7 | func hello() {
8 | fmt.Println("Call Go from C")
9 | }
10 |
11 | func main() {
12 | }
13 |
--------------------------------------------------------------------------------
/demo/ch10abi/cgo/ccallgo/main:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/demo/ch10abi/cgo/ccallgo/main
--------------------------------------------------------------------------------
/demo/ch10abi/cgo/ccallgo/main.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include "gofunc/hello.h"
3 |
4 | int main() {
5 | hello();
6 | return 0;
7 | }
--------------------------------------------------------------------------------
/demo/ch10abi/cgo/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | /*
4 | #include "stdio.h"
5 | void print() {
6 | printf("hellow, cgo");
7 | }
8 | */
9 | import "C"
10 |
11 | func main() {
12 | C.print()
13 | }
14 |
--------------------------------------------------------------------------------
/demo/ch13gc/compile/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "./packa"
4 |
5 | func main() {
6 | packa.CallB()
7 | }
8 |
--------------------------------------------------------------------------------
/demo/ch13gc/compile/packa/a.go:
--------------------------------------------------------------------------------
1 | package packa
2 |
3 | import (
4 | _ "unsafe"
5 | )
6 |
7 | func packb_EmptyCall()
8 |
9 | func CallB() {
10 | packb_EmptyCall()
11 | }
12 |
13 | //go:linkname EmptyCall packb.packa_EmptyCall
14 | func EmptyCall() {
15 | println("packa")
16 | }
17 |
--------------------------------------------------------------------------------
/demo/ch13gc/compile/packb/b.go:
--------------------------------------------------------------------------------
1 | package packb
2 |
3 | import (
4 | _ "unsafe"
5 | )
6 |
7 | func packa_CallEmpty()
8 |
9 | //go:linkname EmptyCall packa.packb_EmptyCall
10 | func EmptyCall() {
11 | println("packb")
12 | }
13 |
14 | func CallA() {
15 | packa_CallEmpty()
16 | }
17 |
--------------------------------------------------------------------------------
/demo/ch13gc/unsafe/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main.out main.go
3 | go tool objdump -s "main.main" main.out > main.S
4 | clean:
5 | rm -rf main.out main.S
--------------------------------------------------------------------------------
/demo/ch13gc/unsafe/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "unsafe"
4 |
5 | func main() {
6 | var p = 42
7 | pp := unsafe.Pointer(&p)
8 | println(pp)
9 | }
10 |
--------------------------------------------------------------------------------
/demo/ch15sync/atomic/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go build -gcflags "-N -l" -ldflags=-compressdwarf=false -o main.out main.go
3 | go tool objdump -s "atomic.CompareAndSwapUintptr|atomic.Casuintptr" main.out > main.S
4 | clean:
5 | rm -rf main.out main.S
--------------------------------------------------------------------------------
/demo/ch15sync/atomic/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "sync/atomic"
5 | "unsafe"
6 | )
7 |
8 | func main() {
9 | var p unsafe.Pointer
10 | newP := 42
11 | atomic.CompareAndSwapPointer(&p, nil, unsafe.Pointer(&newP))
12 |
13 | v := (*int)(p)
14 | println(*v)
15 | }
16 |
--------------------------------------------------------------------------------
/demo/ch15sync/sync/cond/cond.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "sync"
6 | )
7 |
8 | func main() {
9 | cond := sync.NewCond(new(sync.Mutex))
10 | condition := 0
11 |
12 | // Consumer
13 | go func() {
14 | for {
15 | cond.L.Lock()
16 | for condition == 0 {
17 | cond.Wait()
18 | }
19 | condition--
20 | fmt.Printf("Consumer: %d\n", condition)
21 | cond.Signal()
22 | cond.L.Unlock()
23 | }
24 | }()
25 |
26 | // Producer
27 | for {
28 | cond.L.Lock()
29 | for condition == 3 {
30 | cond.Wait()
31 | }
32 | condition++
33 | fmt.Printf("Producer: %d\n", condition)
34 | cond.Signal()
35 | cond.L.Unlock()
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/demo/ch15sync/sync/map/old/map.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "unsafe"
6 | )
7 |
8 | func main() {
9 | var expunged = unsafe.Pointer(new(interface{}))
10 | fmt.Printf("%v", expunged)
11 |
12 | fmt.Printf("%v", unsafe.Pointer(^uintptr(0)))
13 | }
14 |
--------------------------------------------------------------------------------
/demo/ch15sync/sync/waigroup/Makefile:
--------------------------------------------------------------------------------
1 | all:
2 | GOOS=darwin GOARCH=386 go run waitgroup.go
3 | GOOS=darwin GOARCH=amd64 go run waitgroup.go
--------------------------------------------------------------------------------
/demo/ch15sync/sync/waigroup/waitgroup.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "fmt"
5 | "unsafe"
6 | )
7 |
8 | type waitgroup struct {
9 | state [3]uint32
10 | }
11 |
12 | func main() {
13 | var a uint32 = 1
14 | println("uint32: ", unsafe.Sizeof(a))
15 | wg := waitgroup{}
16 | println("[3]uint32: ", unsafe.Sizeof(wg))
17 | fmt.Printf("%d\n", uintptr(unsafe.Pointer(&wg.state))%8)
18 | }
19 |
--------------------------------------------------------------------------------
/demo/ch2parallel/cache/main_test.go:
--------------------------------------------------------------------------------
1 | package cache_test
2 |
3 | import (
4 | "sync/atomic"
5 | "testing"
6 | )
7 |
8 | type pad struct {
9 | x uint64 // 8byte
10 | y uint64 // 8byte
11 | z uint64 // 8byte
12 | }
13 |
14 | func (s *pad) increase() {
15 | atomic.AddUint64(&s.x, 1)
16 | atomic.AddUint64(&s.y, 1)
17 | atomic.AddUint64(&s.z, 1)
18 | }
19 |
20 | func BenchmarkNoPad(b *testing.B) {
21 | s := pad{}
22 | b.RunParallel(func(pb *testing.PB) {
23 | for pb.Next() {
24 | s.increase()
25 | }
26 | })
27 | }
28 |
29 | type withPad struct {
30 | x uint64 // 8byte
31 | _ [56]byte
32 | y uint64 // 8byte
33 | _ [56]byte
34 | z uint64 // 8byte
35 | _ [56]byte
36 | }
37 |
38 | func (s *withPad) increase() {
39 | atomic.AddUint64(&s.x, 1)
40 | atomic.AddUint64(&s.y, 1)
41 | atomic.AddUint64(&s.z, 1)
42 | }
43 |
44 | func BenchmarkWithPad(b *testing.B) {
45 | s := withPad{}
46 | b.RunParallel(func(pb *testing.PB) {
47 | for pb.Next() {
48 | s.increase()
49 | }
50 | })
51 | }
52 |
--------------------------------------------------------------------------------
/demo/ch2parallel/cache/new.txt:
--------------------------------------------------------------------------------
1 | goos: darwin
2 | goarch: amd64
3 | BenchmarkPad-4 30000000 45.9 ns/op 0 B/op 0 allocs/op
4 | BenchmarkPad-4 50000000 39.1 ns/op 0 B/op 0 allocs/op
5 | BenchmarkPad-4 50000000 38.2 ns/op 0 B/op 0 allocs/op
6 | BenchmarkPad-4 50000000 39.5 ns/op 0 B/op 0 allocs/op
7 | BenchmarkPad-4 50000000 39.5 ns/op 0 B/op 0 allocs/op
8 | BenchmarkPad-4 50000000 43.9 ns/op 0 B/op 0 allocs/op
9 | BenchmarkPad-4 50000000 39.4 ns/op 0 B/op 0 allocs/op
10 | BenchmarkPad-4 50000000 39.5 ns/op 0 B/op 0 allocs/op
11 | BenchmarkPad-4 50000000 39.7 ns/op 0 B/op 0 allocs/op
12 | BenchmarkPad-4 50000000 39.4 ns/op 0 B/op 0 allocs/op
13 | PASS
14 | ok _/Users/changkun/dev/go-under-the-hood/demo/ch2parallel/cache 19.703s
15 |
--------------------------------------------------------------------------------
/demo/ch2parallel/cache/old.txt:
--------------------------------------------------------------------------------
1 | goos: darwin
2 | goarch: amd64
3 | BenchmarkPad-4 30000000 66.4 ns/op 0 B/op 0 allocs/op
4 | BenchmarkPad-4 50000000 70.2 ns/op 0 B/op 0 allocs/op
5 | BenchmarkPad-4 30000000 68.6 ns/op 0 B/op 0 allocs/op
6 | BenchmarkPad-4 30000000 69.5 ns/op 0 B/op 0 allocs/op
7 | BenchmarkPad-4 30000000 68.2 ns/op 0 B/op 0 allocs/op
8 | BenchmarkPad-4 30000000 74.6 ns/op 0 B/op 0 allocs/op
9 | BenchmarkPad-4 20000000 68.0 ns/op 0 B/op 0 allocs/op
10 | BenchmarkPad-4 30000000 68.3 ns/op 0 B/op 0 allocs/op
11 | BenchmarkPad-4 20000000 68.3 ns/op 0 B/op 0 allocs/op
12 | BenchmarkPad-4 20000000 68.2 ns/op 0 B/op 0 allocs/op
13 | PASS
14 | ok _/Users/changkun/dev/go-under-the-hood/demo/ch2parallel/cache 20.645s
15 |
--------------------------------------------------------------------------------
/gosrc/cmd/cgo/zdefaultcc.go:
--------------------------------------------------------------------------------
1 | // Code generated by go tool dist; DO NOT EDIT.
2 |
3 | package main
4 |
5 | const defaultPkgConfig = `pkg-config`
6 | func defaultCC(goos, goarch string) string {
7 | switch goos+`/`+goarch {
8 | }
9 | return "clang"
10 | }
11 | func defaultCXX(goos, goarch string) string {
12 | switch goos+`/`+goarch {
13 | }
14 | return "clang++"
15 | }
16 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/amd64/galign.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package amd64
6 |
7 | import (
8 | "cmd/compile/internal/gc"
9 | "cmd/internal/obj/x86"
10 | )
11 |
12 | var leaptr = x86.ALEAQ
13 |
14 | func Init(arch *gc.Arch) {
15 | arch.LinkArch = &x86.Linkamd64
16 | arch.REGSP = x86.REGSP
17 | arch.MAXWIDTH = 1 << 50
18 |
19 | arch.ZeroRange = zerorange
20 | arch.Ginsnop = ginsnop
21 | arch.Ginsnopdefer = ginsnop
22 |
23 | arch.SSAMarkMoves = ssaMarkMoves
24 | arch.SSAGenValue = ssaGenValue
25 | arch.SSAGenBlock = ssaGenBlock
26 | }
27 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/gc/bimport.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package gc
6 |
7 | import (
8 | "cmd/internal/src"
9 | )
10 |
11 | // numImport tracks how often a package with a given name is imported.
12 | // It is used to provide a better error message (by using the package
13 | // path to disambiguate) if a package that appears multiple times with
14 | // the same name appears in an error message.
15 | var numImport = make(map[string]int)
16 |
17 | func npos(pos src.XPos, n *Node) *Node {
18 | n.Pos = pos
19 | return n
20 | }
21 |
22 | func builtinCall(op Op) *Node {
23 | return nod(OCALL, mkname(builtinpkg.Lookup(goopnames[op])), nil)
24 | }
25 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/gc/bootstrap.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !go1.8
6 |
7 | package gc
8 |
9 | import "runtime"
10 |
11 | func startMutexProfiling() {
12 | Fatalf("mutex profiling unavailable in version %v", runtime.Version())
13 | }
14 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/gc/class_string.go:
--------------------------------------------------------------------------------
1 | // Code generated by "stringer -type=Class"; DO NOT EDIT.
2 |
3 | package gc
4 |
5 | import "strconv"
6 |
7 | func _() {
8 | // An "invalid array index" compiler error signifies that the constant values have changed.
9 | // Re-run the stringer command to generate them again.
10 | var x [1]struct{}
11 | _ = x[Pxxx-0]
12 | _ = x[PEXTERN-1]
13 | _ = x[PAUTO-2]
14 | _ = x[PAUTOHEAP-3]
15 | _ = x[PPARAM-4]
16 | _ = x[PPARAMOUT-5]
17 | _ = x[PFUNC-6]
18 | }
19 |
20 | const _Class_name = "PxxxPEXTERNPAUTOPAUTOHEAPPPARAMPPARAMOUTPFUNC"
21 |
22 | var _Class_index = [...]uint8{0, 4, 11, 16, 25, 31, 40, 45}
23 |
24 | func (i Class) String() string {
25 | if i >= Class(len(_Class_index)-1) {
26 | return "Class(" + strconv.FormatInt(int64(i), 10) + ")"
27 | }
28 | return _Class_name[_Class_index[i]:_Class_index[i+1]]
29 | }
30 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/gc/mapfile_read.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd
6 |
7 | package gc
8 |
9 | import (
10 | "io"
11 | "os"
12 | )
13 |
14 | func mapFile(f *os.File, offset, length int64) (string, error) {
15 | buf := make([]byte, length)
16 | _, err := io.ReadFull(io.NewSectionReader(f, offset, length), buf)
17 | if err != nil {
18 | return "", err
19 | }
20 | return string(buf), nil
21 | }
22 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/gc/pprof.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.8
6 |
7 | package gc
8 |
9 | import "runtime"
10 |
11 | func startMutexProfiling() {
12 | runtime.SetMutexProfileFraction(1)
13 | }
14 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/gc/trace.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.7
6 |
7 | package gc
8 |
9 | import (
10 | "os"
11 | tracepkg "runtime/trace"
12 | )
13 |
14 | func init() {
15 | traceHandler = traceHandlerGo17
16 | }
17 |
18 | func traceHandlerGo17(traceprofile string) {
19 | f, err := os.Create(traceprofile)
20 | if err != nil {
21 | Fatalf("%v", err)
22 | }
23 | if err := tracepkg.Start(f); err != nil {
24 | Fatalf("%v", err)
25 | }
26 | atExit(tracepkg.Stop)
27 | }
28 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/gc/types_acc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file implements convertions between *types.Node and *Node.
6 | // TODO(gri) try to eliminate these soon
7 |
8 | package gc
9 |
10 | import (
11 | "cmd/compile/internal/types"
12 | "unsafe"
13 | )
14 |
15 | func asNode(n *types.Node) *Node { return (*Node)(unsafe.Pointer(n)) }
16 | func asTypesNode(n *Node) *types.Node { return (*types.Node)(unsafe.Pointer(n)) }
17 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/ssa/TODO:
--------------------------------------------------------------------------------
1 | This is a list of possible improvements to the SSA pass of the compiler.
2 |
3 | Optimizations (better compiled code)
4 | ------------------------------------
5 | - Reduce register pressure in scheduler
6 | - Make dead store pass inter-block
7 | - If there are a lot of MOVQ $0, ..., then load
8 | 0 into a register and use the register as the source instead.
9 | - Allow large structs to be SSAable (issue 24416)
10 | - Allow arrays of length >1 to be SSAable
11 | - If strings are being passed around without being interpreted (ptr
12 | and len fields being accessed) pass them in xmm registers?
13 | Same for interfaces?
14 | - any pointer generated by unsafe arithmetic must be non-nil?
15 | (Of course that may not be true in general, but it is for all uses
16 | in the runtime, and we can play games with unsafe.)
17 |
18 | Optimizations (better compiler)
19 | -------------------------------
20 | - Handle signed division overflow and sign extension earlier
21 |
22 | Regalloc
23 | --------
24 | - Make liveness analysis non-quadratic
25 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/ssa/gen/AMD64splitload.rules:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file contains rules used by flagalloc to split
6 | // a flag-generating merged load op into separate load and op.
7 | // Unlike with the other rules files, not all of these
8 | // rules will be applied to all values.
9 | // Rather, flagalloc will request for rules to be applied
10 | // to a particular problematic value.
11 | // These are often the exact inverse of rules in AMD64.rules,
12 | // only with the conditions removed.
13 |
14 | (CMP(Q|L|W|B)load {sym} [off] ptr x mem) -> (CMP(Q|L|W|B) (MOV(Q|L|W|B)load {sym} [off] ptr mem) x)
15 |
16 | (CMP(Q|L|W|B)constload {sym} [vo] ptr mem) -> (CMP(Q|L|W|B)const (MOV(Q|L|W|B)load {sym} [offOnly(vo)] ptr mem) [valOnly(vo)])
17 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/ssa/gen/README:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | This package generates opcode tables, rewrite rules, etc. for the ssa compiler.
6 | Run it with go-1.13 (or above):
7 | go run *.go
8 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/ssa/id.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package ssa
6 |
7 | type ID int32
8 |
9 | // idAlloc provides an allocator for unique integers.
10 | type idAlloc struct {
11 | last ID
12 | }
13 |
14 | // get allocates an ID and returns it. IDs are always > 0.
15 | func (a *idAlloc) get() ID {
16 | x := a.last
17 | x++
18 | if x == 1<<31-1 {
19 | panic("too many ids for this function")
20 | }
21 | a.last = x
22 | return x
23 | }
24 |
25 | // num returns the maximum ID ever returned + 1.
26 | func (a *idAlloc) num() int {
27 | return int(a.last + 1)
28 | }
29 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/ssa/opt.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package ssa
6 |
7 | // machine-independent optimization
8 | func opt(f *Func) {
9 | applyRewrite(f, rewriteBlockgeneric, rewriteValuegeneric)
10 | }
11 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/ssa/stackframe.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package ssa
6 |
7 | // stackframe calls back into the frontend to assign frame offsets.
8 | func stackframe(f *Func) {
9 | f.fe.AllocFrame(f)
10 | }
11 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/syntax/operator_string.go:
--------------------------------------------------------------------------------
1 | // Code generated by "stringer -type Operator -linecomment"; DO NOT EDIT.
2 |
3 | package syntax
4 |
5 | import "strconv"
6 |
7 | const _Operator_name = ":!<-||&&==!=<<=>>=+-|^*/%&&^<<>>"
8 |
9 | var _Operator_index = [...]uint8{0, 1, 2, 4, 6, 8, 10, 12, 13, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 30, 32}
10 |
11 | func (i Operator) String() string {
12 | i -= 1
13 | if i >= Operator(len(_Operator_index)-1) {
14 | return "Operator(" + strconv.FormatInt(int64(i+1), 10) + ")"
15 | }
16 | return _Operator_name[_Operator_index[i]:_Operator_index[i+1]]
17 | }
18 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/syntax/token_string.go:
--------------------------------------------------------------------------------
1 | // Code generated by "stringer -type token -linecomment"; DO NOT EDIT.
2 |
3 | package syntax
4 |
5 | import "strconv"
6 |
7 | const _token_name = "EOFnameliteralopop=opop=:=<-*([{)]},;:....breakcasechanconstcontinuedefaultdeferelsefallthroughforfuncgogotoifimportinterfacemappackagerangereturnselectstructswitchtypevar"
8 |
9 | var _token_index = [...]uint8{0, 3, 7, 14, 16, 19, 23, 24, 26, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 42, 47, 51, 55, 60, 68, 75, 80, 84, 95, 98, 102, 104, 108, 110, 116, 125, 128, 135, 140, 146, 152, 158, 164, 168, 171, 171}
10 |
11 | func (i token) String() string {
12 | i -= 1
13 | if i >= token(len(_token_index)-1) {
14 | return "token(" + strconv.FormatInt(int64(i+1), 10) + ")"
15 | }
16 | return _token_name[_token_index[i]:_token_index[i+1]]
17 | }
18 |
--------------------------------------------------------------------------------
/gosrc/cmd/compile/internal/x86/galign.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package x86
6 |
7 | import (
8 | "cmd/compile/internal/gc"
9 | "cmd/internal/obj/x86"
10 | "cmd/internal/objabi"
11 | "fmt"
12 | "os"
13 | )
14 |
15 | func Init(arch *gc.Arch) {
16 | arch.LinkArch = &x86.Link386
17 | arch.REGSP = x86.REGSP
18 | switch v := objabi.GO386; v {
19 | case "387":
20 | arch.Use387 = true
21 | arch.SSAGenValue = ssaGenValue387
22 | arch.SSAGenBlock = ssaGenBlock387
23 | case "sse2":
24 | arch.SSAGenValue = ssaGenValue
25 | arch.SSAGenBlock = ssaGenBlock
26 | default:
27 | fmt.Fprintf(os.Stderr, "unsupported setting GO386=%s\n", v)
28 | gc.Exit(1)
29 | }
30 | arch.MAXWIDTH = (1 << 32) - 1
31 |
32 | arch.ZeroRange = zerorange
33 | arch.Ginsnop = ginsnop
34 | arch.Ginsnopdefer = ginsnop
35 |
36 | arch.SSAMarkMoves = ssaMarkMoves
37 | }
38 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/go11.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build go1.1
6 |
7 | package main
8 |
9 | // Test that go1.1 tag above is included in builds. main.go refers to this definition.
10 | const go11tag = true
11 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/auth/auth.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package auth provides access to user-provided authentication credentials.
6 | package auth
7 |
8 | import "net/http"
9 |
10 | // AddCredentials fills in the user's credentials for req, if any.
11 | // The return value reports whether any matching credentials were found.
12 | func AddCredentials(req *http.Request) (added bool) {
13 | // TODO(golang.org/issue/26232): Support arbitrary user-provided credentials.
14 | netrcOnce.Do(readNetrc)
15 | for _, l := range netrc {
16 | if l.machine == req.URL.Host {
17 | req.SetBasicAuth(l.login, l.password)
18 | return true
19 | }
20 | }
21 |
22 | return false
23 | }
24 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/base/env.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package base
6 |
7 | // EnvForDir returns a modified environment suitable for running in the given
8 | // directory.
9 | // The environment is the supplied base environment but with an updated $PWD, so
10 | // that an os.Getwd in the child will be faster.
11 | func EnvForDir(dir string, base []string) []string {
12 | // Internally we only use rooted paths, so dir is rooted.
13 | // Even if dir is not rooted, no harm done.
14 | return append(base, "PWD="+dir)
15 | }
16 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/base/signal.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package base
6 |
7 | import (
8 | "os"
9 | "os/signal"
10 | "sync"
11 | )
12 |
13 | // Interrupted is closed when the go command receives an interrupt signal.
14 | var Interrupted = make(chan struct{})
15 |
16 | // processSignals setups signal handler.
17 | func processSignals() {
18 | sig := make(chan os.Signal)
19 | signal.Notify(sig, signalsToIgnore...)
20 | go func() {
21 | <-sig
22 | close(Interrupted)
23 | }()
24 | }
25 |
26 | var onceProcessSignals sync.Once
27 |
28 | // StartSigHandlers starts the signal handlers.
29 | func StartSigHandlers() {
30 | onceProcessSignals.Do(processSignals)
31 | }
32 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/base/signal_unix.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build aix darwin dragonfly freebsd js linux netbsd openbsd solaris
6 |
7 | package base
8 |
9 | import (
10 | "os"
11 | "syscall"
12 | )
13 |
14 | var signalsToIgnore = []os.Signal{os.Interrupt, syscall.SIGQUIT}
15 |
16 | // SignalTrace is the signal to send to make a Go program
17 | // crash with a stack trace.
18 | var SignalTrace os.Signal = syscall.SIGQUIT
19 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/cfg/zdefaultcc.go:
--------------------------------------------------------------------------------
1 | // Code generated by go tool dist; DO NOT EDIT.
2 |
3 | package cfg
4 |
5 | const DefaultPkgConfig = `pkg-config`
6 | func DefaultCC(goos, goarch string) string {
7 | switch goos+`/`+goarch {
8 | }
9 | return "clang"
10 | }
11 | func DefaultCXX(goos, goarch string) string {
12 | switch goos+`/`+goarch {
13 | }
14 | return "clang++"
15 | }
16 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/load/path.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package load
6 |
7 | import (
8 | "path/filepath"
9 | )
10 |
11 | // expandPath returns the symlink-expanded form of path.
12 | func expandPath(p string) string {
13 | x, err := filepath.EvalSymlinks(p)
14 | if err == nil {
15 | return x
16 | }
17 | return p
18 | }
19 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modcmd/mod.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package modcmd implements the ``go mod'' command.
6 | package modcmd
7 |
8 | import (
9 | "cmd/go/internal/base"
10 | )
11 |
12 | var CmdMod = &base.Command{
13 | UsageLine: "go mod",
14 | Short: "module maintenance",
15 | Long: `Go mod provides access to operations on modules.
16 |
17 | Note that support for modules is built into all the go commands,
18 | not just 'go mod'. For example, day-to-day adding, removing, upgrading,
19 | and downgrading of dependencies should be done using 'go get'.
20 | See 'go help modules' for an overview of module functionality.
21 | `,
22 |
23 | Commands: []*base.Command{
24 | cmdDownload,
25 | cmdEdit,
26 | cmdGraph,
27 | cmdInit,
28 | cmdTidy,
29 | cmdVendor,
30 | cmdVerify,
31 | cmdWhy,
32 | },
33 | }
34 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modconv/glock.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modconv
6 |
7 | import (
8 | "strings"
9 |
10 | "golang.org/x/mod/modfile"
11 | "golang.org/x/mod/module"
12 | )
13 |
14 | func ParseGLOCKFILE(file string, data []byte) (*modfile.File, error) {
15 | mf := new(modfile.File)
16 | for _, line := range strings.Split(string(data), "\n") {
17 | f := strings.Fields(line)
18 | if len(f) >= 2 && f[0] != "cmd" {
19 | mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: f[0], Version: f[1]}})
20 | }
21 | }
22 | return mf, nil
23 | }
24 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modconv/godeps.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modconv
6 |
7 | import (
8 | "encoding/json"
9 |
10 | "golang.org/x/mod/modfile"
11 | "golang.org/x/mod/module"
12 | )
13 |
14 | func ParseGodepsJSON(file string, data []byte) (*modfile.File, error) {
15 | var cfg struct {
16 | ImportPath string
17 | Deps []struct {
18 | ImportPath string
19 | Rev string
20 | }
21 | }
22 | if err := json.Unmarshal(data, &cfg); err != nil {
23 | return nil, err
24 | }
25 | mf := new(modfile.File)
26 | for _, d := range cfg.Deps {
27 | mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: d.ImportPath, Version: d.Rev}})
28 | }
29 | return mf, nil
30 | }
31 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modconv/modconv.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modconv
6 |
7 | import "golang.org/x/mod/modfile"
8 |
9 | var Converters = map[string]func(string, []byte) (*modfile.File, error){
10 | "GLOCKFILE": ParseGLOCKFILE,
11 | "Godeps/Godeps.json": ParseGodepsJSON,
12 | "Gopkg.lock": ParseGopkgLock,
13 | "dependencies.tsv": ParseDependenciesTSV,
14 | "glide.lock": ParseGlideLock,
15 | "vendor.conf": ParseVendorConf,
16 | "vendor.yml": ParseVendorYML,
17 | "vendor/manifest": ParseVendorManifest,
18 | "vendor/vendor.json": ParseVendorJSON,
19 | }
20 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modconv/tsv.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modconv
6 |
7 | import (
8 | "strings"
9 |
10 | "golang.org/x/mod/modfile"
11 | "golang.org/x/mod/module"
12 | )
13 |
14 | func ParseDependenciesTSV(file string, data []byte) (*modfile.File, error) {
15 | mf := new(modfile.File)
16 | for _, line := range strings.Split(string(data), "\n") {
17 | f := strings.Split(line, "\t")
18 | if len(f) >= 3 {
19 | mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: f[0], Version: f[2]}})
20 | }
21 | }
22 | return mf, nil
23 | }
24 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modconv/vconf.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modconv
6 |
7 | import (
8 | "strings"
9 |
10 | "golang.org/x/mod/modfile"
11 | "golang.org/x/mod/module"
12 | )
13 |
14 | func ParseVendorConf(file string, data []byte) (*modfile.File, error) {
15 | mf := new(modfile.File)
16 | for _, line := range strings.Split(string(data), "\n") {
17 | if i := strings.Index(line, "#"); i >= 0 {
18 | line = line[:i]
19 | }
20 | f := strings.Fields(line)
21 | if len(f) >= 2 {
22 | mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: f[0], Version: f[1]}})
23 | }
24 | }
25 | return mf, nil
26 | }
27 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modconv/vjson.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modconv
6 |
7 | import (
8 | "encoding/json"
9 |
10 | "golang.org/x/mod/modfile"
11 | "golang.org/x/mod/module"
12 | )
13 |
14 | func ParseVendorJSON(file string, data []byte) (*modfile.File, error) {
15 | var cfg struct {
16 | Package []struct {
17 | Path string
18 | Revision string
19 | }
20 | }
21 | if err := json.Unmarshal(data, &cfg); err != nil {
22 | return nil, err
23 | }
24 | mf := new(modfile.File)
25 | for _, d := range cfg.Package {
26 | mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: d.Path, Version: d.Revision}})
27 | }
28 | return mf, nil
29 | }
30 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modconv/vmanifest.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modconv
6 |
7 | import (
8 | "encoding/json"
9 |
10 | "golang.org/x/mod/modfile"
11 | "golang.org/x/mod/module"
12 | )
13 |
14 | func ParseVendorManifest(file string, data []byte) (*modfile.File, error) {
15 | var cfg struct {
16 | Dependencies []struct {
17 | ImportPath string
18 | Revision string
19 | }
20 | }
21 | if err := json.Unmarshal(data, &cfg); err != nil {
22 | return nil, err
23 | }
24 | mf := new(modfile.File)
25 | for _, d := range cfg.Dependencies {
26 | mf.Require = append(mf.Require, &modfile.Require{Mod: module.Version{Path: d.ImportPath, Version: d.Revision}})
27 | }
28 | return mf, nil
29 | }
30 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modfetch/bootstrap.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build cmd_go_bootstrap
6 |
7 | package modfetch
8 |
9 | import "golang.org/x/mod/module"
10 |
11 | func useSumDB(mod module.Version) bool {
12 | return false
13 | }
14 |
15 | func lookupSumDB(mod module.Version) (string, []string, error) {
16 | panic("bootstrap")
17 | }
18 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modfetch/insecure.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modfetch
6 |
7 | import (
8 | "cmd/go/internal/cfg"
9 | "cmd/go/internal/get"
10 | "cmd/go/internal/str"
11 | )
12 |
13 | // allowInsecure reports whether we are allowed to fetch this path in an insecure manner.
14 | func allowInsecure(path string) bool {
15 | return get.Insecure || str.GlobsMatchPath(cfg.GOINSECURE, path)
16 | }
17 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modfetch/key.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package modfetch
6 |
7 | var knownGOSUMDB = map[string]string{
8 | "sum.golang.org": "sum.golang.org+033de0ae+Ac4zctda0e5eza+HJyk9SxEdh+s3Ux18htTTAD8OuAn8",
9 | }
10 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modload/stat_openfile.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build aix js,wasm plan9
6 |
7 | // On plan9, per http://9p.io/magic/man2html/2/access: “Since file permissions
8 | // are checked by the server and group information is not known to the client,
9 | // access must open the file to check permissions.”
10 | //
11 | // aix and js,wasm are similar, in that they do not define syscall.Access.
12 |
13 | package modload
14 |
15 | import (
16 | "os"
17 | )
18 |
19 | // hasWritePerm reports whether the current user has permission to write to the
20 | // file with the given info.
21 | func hasWritePerm(path string, _ os.FileInfo) bool {
22 | if f, err := os.OpenFile(path, os.O_WRONLY, 0); err == nil {
23 | f.Close()
24 | return true
25 | }
26 | return false
27 | }
28 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/modload/testgo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build testgo
6 |
7 | package modload
8 |
9 | func init() {
10 | printStackInDie = true
11 | }
12 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/robustio/robustio_darwin.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package robustio
6 |
7 | import (
8 | "errors"
9 | "syscall"
10 | )
11 |
12 | const errFileNotFound = syscall.ENOENT
13 |
14 | // isEphemeralError returns true if err may be resolved by waiting.
15 | func isEphemeralError(err error) bool {
16 | var errno syscall.Errno
17 | if errors.As(err, &errno) {
18 | return errno == errFileNotFound
19 | }
20 | return false
21 | }
22 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/robustio/robustio_other.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !windows,!darwin
6 |
7 | package robustio
8 |
9 | import (
10 | "io/ioutil"
11 | "os"
12 | )
13 |
14 | func rename(oldpath, newpath string) error {
15 | return os.Rename(oldpath, newpath)
16 | }
17 |
18 | func readFile(filename string) ([]byte, error) {
19 | return ioutil.ReadFile(filename)
20 | }
21 |
22 | func removeAll(path string) error {
23 | return os.RemoveAll(path)
24 | }
25 |
26 | func isEphemeralError(err error) bool {
27 | return false
28 | }
29 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/web/bootstrap.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build cmd_go_bootstrap
6 |
7 | // This code is compiled only into the bootstrap 'go' binary.
8 | // These stubs avoid importing packages with large dependency
9 | // trees that potentially require C linking,
10 | // like the use of "net/http" in vcs.go.
11 |
12 | package web
13 |
14 | import (
15 | "errors"
16 | urlpkg "net/url"
17 | )
18 |
19 | func get(security SecurityMode, url *urlpkg.URL) (*Response, error) {
20 | return nil, errors.New("no http in bootstrap go command")
21 | }
22 |
23 | func openBrowser(url string) bool { return false }
24 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/web/url_other.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !windows
6 |
7 | package web
8 |
9 | import (
10 | "errors"
11 | "path/filepath"
12 | )
13 |
14 | func convertFileURLPath(host, path string) (string, error) {
15 | switch host {
16 | case "", "localhost":
17 | default:
18 | return "", errors.New("file URL specifies non-local host")
19 | }
20 | return filepath.FromSlash(path), nil
21 | }
22 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/internal/work/testgo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // This file contains extra hooks for testing the go command.
6 |
7 | // +build testgo
8 |
9 | package work
10 |
11 | import "os"
12 |
13 | func init() {
14 | if v := os.Getenv("TESTGO_VERSION"); v != "" {
15 | runtimeVersion = v
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/gosrc/cmd/go/mkalldocs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Copyright 2012 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 |
6 | set -e
7 |
8 | go build -o go.latest
9 | # If the command used to generate alldocs.go changes, update TestDocsUpToDate in
10 | # help_test.go.
11 | GO111MODULE='' ./go.latest help documentation >alldocs.go
12 | gofmt -w alldocs.go
13 | rm go.latest
14 |
--------------------------------------------------------------------------------
/gosrc/cmd/internal/obj/abi_string.go:
--------------------------------------------------------------------------------
1 | // Code generated by "stringer -type ABI"; DO NOT EDIT.
2 |
3 | package obj
4 |
5 | import "strconv"
6 |
7 | const _ABI_name = "ABI0ABIInternalABICount"
8 |
9 | var _ABI_index = [...]uint8{0, 4, 15, 23}
10 |
11 | func (i ABI) String() string {
12 | if i >= ABI(len(_ABI_index)-1) {
13 | return "ABI(" + strconv.FormatInt(int64(i), 10) + ")"
14 | }
15 | return _ABI_name[_ABI_index[i]:_ABI_index[i+1]]
16 | }
17 |
--------------------------------------------------------------------------------
/gosrc/cmd/internal/obj/addrtype_string.go:
--------------------------------------------------------------------------------
1 | // Code generated by "stringer -type AddrType"; DO NOT EDIT.
2 |
3 | package obj
4 |
5 | import "strconv"
6 |
7 | const _AddrType_name = "TYPE_NONETYPE_BRANCHTYPE_TEXTSIZETYPE_MEMTYPE_CONSTTYPE_FCONSTTYPE_SCONSTTYPE_REGTYPE_ADDRTYPE_SHIFTTYPE_REGREGTYPE_REGREG2TYPE_INDIRTYPE_REGLIST"
8 |
9 | var _AddrType_index = [...]uint8{0, 9, 20, 33, 41, 51, 62, 73, 81, 90, 100, 111, 123, 133, 145}
10 |
11 | func (i AddrType) String() string {
12 | if i >= AddrType(len(_AddrType_index)-1) {
13 | return "AddrType(" + strconv.FormatInt(int64(i), 10) + ")"
14 | }
15 | return _AddrType_name[_AddrType_index[i]:_AddrType_index[i+1]]
16 | }
17 |
--------------------------------------------------------------------------------
/gosrc/cmd/internal/obj/go.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package obj
6 |
7 | // go-specific code shared across loaders (5l, 6l, 8l).
8 |
9 | func Nopout(p *Prog) {
10 | p.As = ANOP
11 | p.Scond = 0
12 | p.From = Addr{}
13 | p.RestArgs = nil
14 | p.Reg = 0
15 | p.To = Addr{}
16 | }
17 |
--------------------------------------------------------------------------------
/gosrc/cmd/internal/obj/line.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package obj
6 |
7 | import (
8 | "cmd/internal/src"
9 | )
10 |
11 | // AddImport adds a package to the list of imported packages.
12 | func (ctxt *Link) AddImport(pkg string) {
13 | ctxt.Imports = append(ctxt.Imports, pkg)
14 | }
15 |
16 | func linkgetlineFromPos(ctxt *Link, xpos src.XPos) (f string, l int32) {
17 | pos := ctxt.PosTable.Pos(xpos)
18 | if !pos.IsKnown() {
19 | pos = src.Pos{}
20 | }
21 | // TODO(gri) Should this use relative or absolute line number?
22 | return pos.SymFilename(), int32(pos.RelLine())
23 | }
24 |
--------------------------------------------------------------------------------
/gosrc/internal/cpu/cpu_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package cpu
6 |
7 | const GOARCH = "amd64"
8 |
--------------------------------------------------------------------------------
/gosrc/internal/cpu/cpu_x86.s:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386 amd64
6 |
7 | #include "textflag.h"
8 |
9 | // func cpuid(eaxArg, ecxArg uint32) (eax, ebx, ecx, edx uint32)
10 | TEXT ·cpuid(SB), NOSPLIT, $0-24
11 | MOVL eaxArg+0(FP), AX
12 | MOVL ecxArg+4(FP), CX
13 | CPUID
14 | MOVL AX, eax+8(FP)
15 | MOVL BX, ebx+12(FP)
16 | MOVL CX, ecx+16(FP)
17 | MOVL DX, edx+20(FP)
18 | RET
19 |
20 | // func xgetbv() (eax, edx uint32)
21 | TEXT ·xgetbv(SB),NOSPLIT,$0-8
22 | MOVL $0, CX
23 | XGETBV
24 | MOVL AX, eax+0(FP)
25 | MOVL DX, edx+4(FP)
26 | RET
27 |
--------------------------------------------------------------------------------
/gosrc/os/signal/sig.s:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // The runtime package uses //go:linkname to push a few functions into this
6 | // package but we still need a .s file so the Go tool does not pass -complete
7 | // to the go tool compile so the latter does not complain about Go functions
8 | // with no bodies.
9 |
--------------------------------------------------------------------------------
/gosrc/plugin/plugin_stubs.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !linux,!freebsd,!darwin !cgo
6 |
7 | package plugin
8 |
9 | import "errors"
10 |
11 | func lookup(p *Plugin, symName string) (Symbol, error) {
12 | return nil, errors.New("plugin: not implemented")
13 | }
14 |
15 | func open(name string) (*Plugin, error) {
16 | return nil, errors.New("plugin: not implemented")
17 | }
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/asm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #include "textflag.h"
6 |
7 | // funcdata for functions with no local variables in frame.
8 | // Define two zero-length bitmaps, because the same index is used
9 | // for the local variables as for the argument frame, and assembly
10 | // frames have two argument bitmaps, one without results and one with results.
11 | DATA runtime·no_pointers_stackmap+0x00(SB)/4, $2
12 | DATA runtime·no_pointers_stackmap+0x04(SB)/4, $0
13 | GLOBL runtime·no_pointers_stackmap(SB),RODATA, $8
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/callbacks_traceback.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build darwin linux
6 |
7 | package cgo
8 |
9 | import _ "unsafe" // for go:linkname
10 |
11 | // Calls the traceback function passed to SetCgoTraceback.
12 |
13 | //go:cgo_import_static x_cgo_callers
14 | //go:linkname x_cgo_callers x_cgo_callers
15 | //go:linkname _cgo_callers _cgo_callers
16 | var x_cgo_callers byte
17 | var _cgo_callers = &x_cgo_callers
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/cgo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2010 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | /*
6 | Package cgo contains runtime support for code generated
7 | by the cgo tool. See the documentation for the cgo command
8 | for details on using cgo.
9 | */
10 | package cgo
11 |
12 | /*
13 |
14 | #cgo darwin,!arm64 LDFLAGS: -lpthread
15 | #cgo darwin,arm64 LDFLAGS: -framework CoreFoundation
16 | #cgo dragonfly LDFLAGS: -lpthread
17 | #cgo freebsd LDFLAGS: -lpthread
18 | #cgo android LDFLAGS: -llog
19 | #cgo !android,linux LDFLAGS: -lpthread
20 | #cgo netbsd LDFLAGS: -lpthread
21 | #cgo openbsd LDFLAGS: -lpthread
22 | #cgo aix LDFLAGS: -Wl,-berok
23 | #cgo solaris LDFLAGS: -lxnet
24 | #cgo illumos LDFLAGS: -lsocket
25 |
26 | // Issue 35247.
27 | #cgo darwin CFLAGS: -Wno-nullability-completeness
28 |
29 | #cgo CFLAGS: -Wall -Werror
30 |
31 | #cgo solaris CPPFLAGS: -D_POSIX_PTHREAD_SEMANTICS
32 |
33 | */
34 | import "C"
35 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/gcc_context.c:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build cgo
6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
7 |
8 | #include "libcgo.h"
9 |
10 | // Releases the cgo traceback context.
11 | void _cgo_release_context(uintptr_t ctxt) {
12 | void (*pfn)(struct context_arg*);
13 |
14 | pfn = _cgo_get_context_function();
15 | if (ctxt != 0 && pfn != nil) {
16 | struct context_arg arg;
17 |
18 | arg.Context = ctxt;
19 | (*pfn)(&arg);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/gcc_fatalf.c:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build aix !android,linux freebsd
6 |
7 | #include
8 | #include
9 | #include
10 | #include "libcgo.h"
11 |
12 | void
13 | fatalf(const char* format, ...)
14 | {
15 | va_list ap;
16 |
17 | fprintf(stderr, "runtime/cgo: ");
18 | va_start(ap, format);
19 | vfprintf(stderr, format, ap);
20 | va_end(ap);
21 | fprintf(stderr, "\n");
22 | abort();
23 | }
24 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/gcc_mmap.c:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux,amd64 linux,arm64
6 |
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | #include "libcgo.h"
13 |
14 | uintptr_t
15 | x_cgo_mmap(void *addr, uintptr_t length, int32_t prot, int32_t flags, int32_t fd, uint32_t offset) {
16 | void *p;
17 |
18 | _cgo_tsan_acquire();
19 | p = mmap(addr, length, prot, flags, fd, offset);
20 | _cgo_tsan_release();
21 | if (p == MAP_FAILED) {
22 | /* This is what the Go code expects on failure. */
23 | return (uintptr_t)errno;
24 | }
25 | return (uintptr_t)p;
26 | }
27 |
28 | void
29 | x_cgo_munmap(void *addr, uintptr_t length) {
30 | int r;
31 |
32 | _cgo_tsan_acquire();
33 | r = munmap(addr, length);
34 | _cgo_tsan_release();
35 | if (r < 0) {
36 | /* The Go runtime is not prepared for munmap to fail. */
37 | abort();
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/gcc_setenv.c:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build cgo
6 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
7 |
8 | #include "libcgo.h"
9 |
10 | #include
11 |
12 | /* Stub for calling setenv */
13 | void
14 | x_cgo_setenv(char **arg)
15 | {
16 | _cgo_tsan_acquire();
17 | setenv(arg[0], arg[1], 1);
18 | _cgo_tsan_release();
19 | }
20 |
21 | /* Stub for calling unsetenv */
22 | void
23 | x_cgo_unsetenv(char **arg)
24 | {
25 | _cgo_tsan_acquire();
26 | unsetenv(arg[0]);
27 | _cgo_tsan_release();
28 | }
29 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/gcc_traceback.c:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build cgo,darwin cgo,linux
6 |
7 | #include
8 | #include "libcgo.h"
9 |
10 | // Call the user's traceback function and then call sigtramp.
11 | // The runtime signal handler will jump to this code.
12 | // We do it this way so that the user's traceback function will be called
13 | // by a C function with proper unwind info.
14 | void
15 | x_cgo_callers(uintptr_t sig, void *info, void *context, void (*cgoTraceback)(struct cgoTracebackArg*), uintptr_t* cgoCallers, void (*sigtramp)(uintptr_t, void*, void*)) {
16 | struct cgoTracebackArg arg;
17 |
18 | arg.Context = 0;
19 | arg.SigContext = (uintptr_t)(context);
20 | arg.Buf = cgoCallers;
21 | arg.Max = 32; // must match len(runtime.cgoCallers)
22 | (*cgoTraceback)(&arg);
23 | sigtramp(sig, info, context);
24 | }
25 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/iscgo.go:
--------------------------------------------------------------------------------
1 | // Copyright 2010 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // The runtime package contains an uninitialized definition
6 | // for runtime·iscgo. Override it to tell the runtime we're here.
7 | // There are various function pointers that should be set too,
8 | // but those depend on dynamic linker magic to get initialized
9 | // correctly, and sometimes they break. This variable is a
10 | // backup: it depends only on old C style static linking rules.
11 |
12 | package cgo
13 |
14 | import _ "unsafe" // for go:linkname
15 |
16 | //go:linkname _iscgo runtime.iscgo
17 | var _iscgo bool = true
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/libcgo_unix.h:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | /*
6 | * Call pthread_create, retrying on EAGAIN.
7 | */
8 | extern int _cgo_try_pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*);
9 |
10 | /*
11 | * Same as _cgo_try_pthread_create, but passing on the pthread_create function.
12 | * Only defined on OpenBSD.
13 | */
14 | extern int _cgo_openbsd_try_pthread_create(int (*)(pthread_t*, const pthread_attr_t*, void *(*pfn)(void*), void*),
15 | pthread_t*, const pthread_attr_t*, void* (*)(void*), void* arg);
16 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/setenv.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
6 |
7 | package cgo
8 |
9 | import _ "unsafe" // for go:linkname
10 |
11 | //go:cgo_import_static x_cgo_setenv
12 | //go:linkname x_cgo_setenv x_cgo_setenv
13 | //go:linkname _cgo_setenv runtime._cgo_setenv
14 | var x_cgo_setenv byte
15 | var _cgo_setenv = &x_cgo_setenv
16 |
17 | //go:cgo_import_static x_cgo_unsetenv
18 | //go:linkname x_cgo_unsetenv x_cgo_unsetenv
19 | //go:linkname _cgo_unsetenv runtime._cgo_unsetenv
20 | var x_cgo_unsetenv byte
21 | var _cgo_unsetenv = &x_cgo_unsetenv
22 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgo/sigaction.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux,amd64 freebsd,amd64 linux,arm64
6 |
7 | package cgo
8 |
9 | // Import "unsafe" because we use go:linkname.
10 | import _ "unsafe"
11 |
12 | // When using cgo, call the C library for sigaction, so that we call into
13 | // any sanitizer interceptors. This supports using the memory
14 | // sanitizer with Go programs. The memory sanitizer only applies to
15 | // C/C++ code; this permits that code to see the Go runtime's existing signal
16 | // handlers when registering new signal handlers for the process.
17 |
18 | //go:cgo_import_static x_cgo_sigaction
19 | //go:linkname x_cgo_sigaction x_cgo_sigaction
20 | //go:linkname _cgo_sigaction _cgo_sigaction
21 | var x_cgo_sigaction byte
22 | var _cgo_sigaction = &x_cgo_sigaction
23 |
--------------------------------------------------------------------------------
/gosrc/runtime/cgocallback.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package runtime
6 |
7 | // These functions are called from C code via cgo/callbacks.go.
8 |
9 | // Panic.
10 |
11 | func _cgo_panic_internal(p *byte) {
12 | panic(gostringnocopy(p))
13 | }
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/compiler.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package runtime
6 |
7 | // Compiler is the name of the compiler toolchain that built the
8 | // running binary. Known toolchains are:
9 | //
10 | // gc Also known as cmd/compile.
11 | // gccgo The gccgo front end, part of the GCC compiler suite.
12 | //
13 | const Compiler = "gc"
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/cpuflags.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package runtime
6 |
7 | import (
8 | "internal/cpu"
9 | "unsafe"
10 | )
11 |
12 | // Offsets into internal/cpu records for use in assembly.
13 | const (
14 | offsetX86HasAVX = unsafe.Offsetof(cpu.X86.HasAVX)
15 | offsetX86HasAVX2 = unsafe.Offsetof(cpu.X86.HasAVX2)
16 | offsetX86HasERMS = unsafe.Offsetof(cpu.X86.HasERMS)
17 | offsetX86HasSSE2 = unsafe.Offsetof(cpu.X86.HasSSE2)
18 |
19 | offsetARMHasIDIVA = unsafe.Offsetof(cpu.ARM.HasIDIVA)
20 |
21 | offsetMIPS64XHasMSA = unsafe.Offsetof(cpu.MIPS64X.HasMSA)
22 | )
23 |
24 | var (
25 | // Set in runtime.cpuinit.
26 | // TODO: deprecate these; use internal/cpu directly.
27 | x86HasPOPCNT bool
28 | x86HasSSE41 bool
29 | x86HasFMA bool
30 |
31 | armHasVFPv4 bool
32 |
33 | arm64HasATOMICS bool
34 | )
35 |
--------------------------------------------------------------------------------
/gosrc/runtime/cpuflags_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package runtime
6 |
7 | import (
8 | "internal/cpu"
9 | )
10 |
11 | var useAVXmemmove bool
12 |
13 | func init() {
14 | // Let's remove stepping and reserved fields
15 | processor := processorVersionInfo & 0x0FFF3FF0
16 |
17 | isIntelBridgeFamily := isIntel &&
18 | processor == 0x206A0 ||
19 | processor == 0x206D0 ||
20 | processor == 0x306A0 ||
21 | processor == 0x306E0
22 |
23 | useAVXmemmove = cpu.X86.HasAVX && !isIntelBridgeFamily
24 | }
25 |
--------------------------------------------------------------------------------
/gosrc/runtime/cputicks.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !arm
6 | // +build !arm64
7 | // +build !mips64
8 | // +build !mips64le
9 | // +build !mips
10 | // +build !mipsle
11 | // +build !wasm
12 |
13 | package runtime
14 |
15 | // careful: cputicks is not guaranteed to be monotonic! In particular, we have
16 | // noticed drift between cpus on certain os/arch combinations. See issue 8976.
17 | func cputicks() int64
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/debug/debug.s:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Nothing to see here.
6 | // This file exists so that the go command knows that parts of the
7 | // package are implemented in C, so that it does not instruct the
8 | // Go compiler to complain about extern declarations.
9 | // The actual implementations are in package runtime.
10 |
--------------------------------------------------------------------------------
/gosrc/runtime/debug/stack.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package debug contains facilities for programs to debug themselves while
6 | // they are running.
7 | package debug
8 |
9 | import (
10 | "os"
11 | "runtime"
12 | )
13 |
14 | // PrintStack prints to standard error the stack trace returned by runtime.Stack.
15 | func PrintStack() {
16 | os.Stderr.Write(Stack())
17 | }
18 |
19 | // Stack returns a formatted stack trace of the goroutine that calls it.
20 | // It calls runtime.Stack with a large enough buffer to capture the entire trace.
21 | func Stack() []byte {
22 | buf := make([]byte, 1024)
23 | for {
24 | n := runtime.Stack(buf, false)
25 | if n < len(buf) {
26 | return buf[:n]
27 | }
28 | buf = make([]byte, 2*len(buf))
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/gosrc/runtime/debug/stubs.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package debug
6 |
7 | import (
8 | "time"
9 | )
10 |
11 | // Implemented in package runtime.
12 | func readGCStats(*[]time.Duration)
13 | func freeOSMemory()
14 | func setMaxStack(int) int
15 | func setGCPercent(int32) int32
16 | func setPanicOnFault(bool) bool
17 | func setMaxThreads(int) int
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/debuglog_off.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !debuglog
6 |
7 | package runtime
8 |
9 | const dlogEnabled = false
10 |
11 | type dlogPerM struct{}
12 |
13 | func getCachedDlogger() *dlogger {
14 | return nil
15 | }
16 |
17 | func putCachedDlogger(l *dlogger) bool {
18 | return false
19 | }
20 |
--------------------------------------------------------------------------------
/gosrc/runtime/defs1_linux.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build ignore
6 |
7 | /*
8 | Input to cgo -cdefs
9 |
10 | GOARCH=amd64 cgo -cdefs defs.go defs1.go >amd64/defs.h
11 | */
12 |
13 | package runtime
14 |
15 | /*
16 | #include
17 | #include
18 | #include
19 | */
20 | import "C"
21 |
22 | const (
23 | O_RDONLY = C.O_RDONLY
24 | O_NONBLOCK = C.O_NONBLOCK
25 | O_CLOEXEC = C.O_CLOEXEC
26 | SA_RESTORER = C.SA_RESTORER
27 | )
28 |
29 | type Usigset C.__sigset_t
30 | type Fpxreg C.struct__libc_fpxreg
31 | type Xmmreg C.struct__libc_xmmreg
32 | type Fpstate C.struct__libc_fpstate
33 | type Fpxreg1 C.struct__fpxreg
34 | type Xmmreg1 C.struct__xmmreg
35 | type Fpstate1 C.struct__fpstate
36 | type Fpreg1 C.struct__fpreg
37 | type StackT C.stack_t
38 | type Mcontext C.mcontext_t
39 | type Ucontext C.ucontext_t
40 | type Sigcontext C.struct_sigcontext
41 |
--------------------------------------------------------------------------------
/gosrc/runtime/go_tls.h:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #ifdef GOARCH_arm
6 | #define LR R14
7 | #endif
8 |
9 | #ifdef GOARCH_amd64
10 | #define get_tls(r) MOVQ TLS, r
11 | #define g(r) 0(r)(TLS*1)
12 | #endif
13 |
14 | #ifdef GOARCH_386
15 | #define get_tls(r) MOVL TLS, r
16 | #define g(r) 0(r)(TLS*1)
17 | #endif
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/atomic/stubs.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !wasm
6 |
7 | package atomic
8 |
9 | import "unsafe"
10 |
11 | //go:noescape
12 | func Cas(ptr *uint32, old, new uint32) bool
13 |
14 | // NO go:noescape annotation; see atomic_pointer.go.
15 | func Casp1(ptr *unsafe.Pointer, old, new unsafe.Pointer) bool
16 |
17 | //go:noescape
18 | func Casuintptr(ptr *uintptr, old, new uintptr) bool
19 |
20 | //go:noescape
21 | func Storeuintptr(ptr *uintptr, new uintptr)
22 |
23 | //go:noescape
24 | func Loaduintptr(ptr *uintptr) uintptr
25 |
26 | //go:noescape
27 | func Loaduint(ptr *uint) uint
28 |
29 | // TODO(matloob): Should these functions have the go:noescape annotation?
30 |
31 | //go:noescape
32 | func Loadint64(ptr *int64) int64
33 |
34 | //go:noescape
35 | func Xaddint64(ptr *int64, delta int64) int64
36 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/math/math.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package math
6 |
7 | import "runtime/internal/sys"
8 |
9 | const MaxUintptr = ^uintptr(0)
10 |
11 | // MulUintptr returns a * b and whether the multiplication overflowed.
12 | // On supported platforms this is an intrinsic lowered by the compiler.
13 | func MulUintptr(a, b uintptr) (uintptr, bool) {
14 | if a|b < 1<<(4*sys.PtrSize) || a == 0 {
15 | return a * b, false
16 | }
17 | overflow := b > MaxUintptr/a
18 | return a * b, overflow
19 | }
20 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/arch.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package sys
6 |
7 | type ArchFamilyType int
8 |
9 | const (
10 | AMD64 ArchFamilyType = iota
11 | ARM
12 | ARM64
13 | I386
14 | MIPS
15 | MIPS64
16 | PPC64
17 | RISCV64
18 | S390X
19 | WASM
20 | )
21 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/arch_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package sys
6 |
7 | const (
8 | ArchFamily = AMD64
9 | BigEndian = false
10 | DefaultPhysPageSize = 4096
11 | PCQuantum = 1
12 | Int64Align = 8
13 | MinFrameSize = 0
14 | )
15 |
16 | type Uintreg uint64
17 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/arch_wasm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package sys
6 |
7 | const (
8 | ArchFamily = WASM
9 | BigEndian = false
10 | DefaultPhysPageSize = 65536
11 | PCQuantum = 1
12 | Int64Align = 8
13 | MinFrameSize = 0
14 | )
15 |
16 | type Uintreg uint64
17 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/intrinsics_stubs.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build 386
6 |
7 | package sys
8 |
9 | func Ctz64(x uint64) int
10 | func Ctz32(x uint32) int
11 | func Ctz8(x uint8) int
12 | func Bswap64(x uint64) uint64
13 | func Bswap32(x uint32) uint32
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/stubs.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package sys
6 |
7 | // Declarations for runtime services implemented in C or assembly.
8 |
9 | const PtrSize = 4 << (^uintptr(0) >> 63) // unsafe.Sizeof(uintptr(0)) but an ideal const
10 | const RegSize = 4 << (^Uintreg(0) >> 63) // unsafe.Sizeof(uintreg(0)) but an ideal const
11 | const SpAlign = 1*(1-GoarchArm64) + 16*GoarchArm64 // SP alignment: 1 normally, 16 for ARM64
12 |
13 | var DefaultGoroot string // set at link time
14 |
15 | // AIX requires a larger stack for syscalls.
16 | const StackGuardMultiplier = StackGuardMultiplierDefault*(1-GoosAix) + 2*GoosAix
17 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/sys.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // package sys contains system- and configuration- and architecture-specific
6 | // constants used by the runtime.
7 | package sys
8 |
9 | // The next line makes 'go generate' write the zgo*.go files with
10 | // per-OS and per-arch information, including constants
11 | // named Goos$GOOS and Goarch$GOARCH for every
12 | // known GOOS and GOARCH. The constant is 1 on the
13 | // current system, 0 otherwise; multiplying by them is
14 | // useful for defining GOOS- or GOARCH-specific constants.
15 | //go:generate go run gengoos.go
16 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/zgoarch_amd64.go:
--------------------------------------------------------------------------------
1 | // Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
2 |
3 | // +build amd64
4 |
5 | package sys
6 |
7 | const GOARCH = `amd64`
8 |
9 | const Goarch386 = 0
10 | const GoarchAmd64 = 1
11 | const GoarchAmd64p32 = 0
12 | const GoarchArm = 0
13 | const GoarchArmbe = 0
14 | const GoarchArm64 = 0
15 | const GoarchArm64be = 0
16 | const GoarchPpc64 = 0
17 | const GoarchPpc64le = 0
18 | const GoarchMips = 0
19 | const GoarchMipsle = 0
20 | const GoarchMips64 = 0
21 | const GoarchMips64le = 0
22 | const GoarchMips64p32 = 0
23 | const GoarchMips64p32le = 0
24 | const GoarchPpc = 0
25 | const GoarchRiscv = 0
26 | const GoarchRiscv64 = 0
27 | const GoarchS390 = 0
28 | const GoarchS390x = 0
29 | const GoarchSparc = 0
30 | const GoarchSparc64 = 0
31 | const GoarchWasm = 0
32 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/zgoarch_wasm.go:
--------------------------------------------------------------------------------
1 | // Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
2 |
3 | // +build wasm
4 |
5 | package sys
6 |
7 | const GOARCH = `wasm`
8 |
9 | const Goarch386 = 0
10 | const GoarchAmd64 = 0
11 | const GoarchAmd64p32 = 0
12 | const GoarchArm = 0
13 | const GoarchArmbe = 0
14 | const GoarchArm64 = 0
15 | const GoarchArm64be = 0
16 | const GoarchPpc64 = 0
17 | const GoarchPpc64le = 0
18 | const GoarchMips = 0
19 | const GoarchMipsle = 0
20 | const GoarchMips64 = 0
21 | const GoarchMips64le = 0
22 | const GoarchMips64p32 = 0
23 | const GoarchMips64p32le = 0
24 | const GoarchPpc = 0
25 | const GoarchRiscv = 0
26 | const GoarchRiscv64 = 0
27 | const GoarchS390 = 0
28 | const GoarchS390x = 0
29 | const GoarchSparc = 0
30 | const GoarchSparc64 = 0
31 | const GoarchWasm = 1
32 |
--------------------------------------------------------------------------------
/gosrc/runtime/internal/sys/zgoos_linux.go:
--------------------------------------------------------------------------------
1 | // Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
2 |
3 | // +build !android
4 | // +build linux
5 |
6 | package sys
7 |
8 | const GOOS = `linux`
9 |
10 | const GoosAix = 0
11 | const GoosAndroid = 0
12 | const GoosDarwin = 0
13 | const GoosDragonfly = 0
14 | const GoosFreebsd = 0
15 | const GoosHurd = 0
16 | const GoosIllumos = 0
17 | const GoosIos = 0
18 | const GoosJs = 0
19 | const GoosLinux = 1
20 | const GoosNacl = 0
21 | const GoosNetbsd = 0
22 | const GoosOpenbsd = 0
23 | const GoosPlan9 = 0
24 | const GoosSolaris = 0
25 | const GoosWindows = 0
26 | const GoosZos = 0
27 |
--------------------------------------------------------------------------------
/gosrc/runtime/memclr_wasm.s:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #include "textflag.h"
6 |
7 | // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
8 | TEXT runtime·memclrNoHeapPointers(SB), NOSPLIT, $0-16
9 | MOVD ptr+0(FP), R0
10 | MOVD n+8(FP), R1
11 |
12 | loop:
13 | Loop
14 | Get R1
15 | I64Eqz
16 | If
17 | RET
18 | End
19 |
20 | Get R0
21 | I32WrapI64
22 | I64Const $0
23 | I64Store8 $0
24 |
25 | Get R0
26 | I64Const $1
27 | I64Add
28 | Set R0
29 |
30 | Get R1
31 | I64Const $1
32 | I64Sub
33 | Set R1
34 |
35 | Br loop
36 | End
37 | UNDEF
38 |
--------------------------------------------------------------------------------
/gosrc/runtime/mmap.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !plan9
6 | // +build !solaris
7 | // +build !windows
8 | // +build !linux !amd64
9 | // +build !linux !arm64
10 | // +build !js
11 | // +build !darwin
12 | // +build !aix
13 |
14 | package runtime
15 |
16 | import "unsafe"
17 |
18 | // mmap calls the mmap system call. It is implemented in assembly.
19 | // We only pass the lower 32 bits of file offset to the
20 | // assembly routine; the higher bits (if required), should be provided
21 | // by the assembly routine as 0.
22 | // The err result is an OS error code such as ENOMEM.
23 | func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) (p unsafe.Pointer, err int)
24 |
25 | // munmap calls the munmap system call. It is implemented in assembly.
26 | func munmap(addr unsafe.Pointer, n uintptr)
27 |
--------------------------------------------------------------------------------
/gosrc/runtime/msan0.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !msan
6 |
7 | // Dummy MSan support API, used when not built with -msan.
8 |
9 | package runtime
10 |
11 | import (
12 | "unsafe"
13 | )
14 |
15 | const msanenabled = false
16 |
17 | // Because msanenabled is false, none of these functions should be called.
18 |
19 | func msanread(addr unsafe.Pointer, sz uintptr) { throw("msan") }
20 | func msanwrite(addr unsafe.Pointer, sz uintptr) { throw("msan") }
21 | func msanmalloc(addr unsafe.Pointer, sz uintptr) { throw("msan") }
22 | func msanfree(addr unsafe.Pointer, sz uintptr) { throw("msan") }
23 |
--------------------------------------------------------------------------------
/gosrc/runtime/msize.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Malloc small size classes.
6 | //
7 | // See malloc.go for overview.
8 | // See also mksizeclasses.go for how we decide what size classes to use.
9 | // Malloc 大小较小的 class
10 | //
11 | // 参见 malloc.go 的综述
12 | // 另参见 mksizeclasses.go 来了解如何根据 size 决定使用的 class
13 |
14 | package runtime
15 |
16 | // Returns size of the memory block that mallocgc will allocate if you ask for the size.
17 | // 如果要求大小,则返回 mallocgc 将分配的内存块的大小。
18 | func roundupsize(size uintptr) uintptr {
19 | if size < _MaxSmallSize {
20 | if size <= smallSizeMax-8 {
21 | return uintptr(class_to_size[size_to_class8[divRoundUp(size, smallSizeDiv)]])
22 | } else {
23 | return uintptr(class_to_size[size_to_class128[divRoundUp(size-smallSizeMax, largeSizeDiv)]])
24 | }
25 | }
26 | if size+_PageSize < size {
27 | return size
28 | }
29 | return alignUp(size, _PageSize)
30 | }
31 |
--------------------------------------------------------------------------------
/gosrc/runtime/nbpipe_pipe.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build aix darwin dragonfly
6 |
7 | package runtime
8 |
9 | func nonblockingPipe() (r, w int32, errno int32) {
10 | r, w, errno = pipe()
11 | if errno != 0 {
12 | return -1, -1, errno
13 | }
14 | closeonexec(r)
15 | setNonblock(r)
16 | closeonexec(w)
17 | setNonblock(w)
18 | return r, w, errno
19 | }
20 |
--------------------------------------------------------------------------------
/gosrc/runtime/nbpipe_pipe2.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build freebsd linux netbsd openbsd solaris
6 |
7 | package runtime
8 |
9 | func nonblockingPipe() (r, w int32, errno int32) {
10 | r, w, errno = pipe2(_O_NONBLOCK | _O_CLOEXEC)
11 | if errno == -_ENOSYS {
12 | r, w, errno = pipe()
13 | if errno != 0 {
14 | return -1, -1, errno
15 | }
16 | closeonexec(r)
17 | setNonblock(r)
18 | closeonexec(w)
19 | setNonblock(w)
20 | }
21 | return r, w, errno
22 | }
23 |
--------------------------------------------------------------------------------
/gosrc/runtime/netpoll_fake.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Fake network poller for wasm/js.
6 | // Should never be used, because wasm/js network connections do not honor "SetNonblock".
7 |
8 | // +build js,wasm
9 |
10 | package runtime
11 |
12 | func netpollinit() {
13 | }
14 |
15 | func netpollIsPollDescriptor(fd uintptr) bool {
16 | return false
17 | }
18 |
19 | func netpollopen(fd uintptr, pd *pollDesc) int32 {
20 | return 0
21 | }
22 |
23 | func netpollclose(fd uintptr) int32 {
24 | return 0
25 | }
26 |
27 | func netpollarm(pd *pollDesc, mode int) {
28 | }
29 |
30 | func netpollBreak() {
31 | }
32 |
33 | func netpoll(delay int64) gList {
34 | return gList{}
35 | }
36 |
--------------------------------------------------------------------------------
/gosrc/runtime/os_linux_be64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // The standard GNU/Linux sigset type on big-endian 64-bit machines.
6 |
7 | // +build linux
8 | // +build ppc64 s390x
9 |
10 | package runtime
11 |
12 | const (
13 | _SS_DISABLE = 2
14 | _NSIG = 65
15 | _SI_USER = 0
16 | _SIG_BLOCK = 0
17 | _SIG_UNBLOCK = 1
18 | _SIG_SETMASK = 2
19 | )
20 |
21 | type sigset uint64
22 |
23 | var sigset_all = sigset(^uint64(0))
24 |
25 | //go:nosplit
26 | //go:nowritebarrierrec
27 | func sigaddset(mask *sigset, i int) {
28 | if i > 64 {
29 | throw("unexpected signal greater than 64")
30 | }
31 | *mask |= 1 << (uint(i) - 1)
32 | }
33 |
34 | func sigdelset(mask *sigset, i int) {
35 | if i > 64 {
36 | throw("unexpected signal greater than 64")
37 | }
38 | *mask &^= 1 << (uint(i) - 1)
39 | }
40 |
41 | func sigfillset(mask *uint64) {
42 | *mask = ^uint64(0)
43 | }
44 |
--------------------------------------------------------------------------------
/gosrc/runtime/os_linux_noauxv.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build !arm,!arm64,!mips,!mipsle,!mips64,!mips64le,!s390x,!ppc64,!ppc64le
7 |
8 | package runtime
9 |
10 | func archauxv(tag, val uintptr) {
11 | }
12 |
--------------------------------------------------------------------------------
/gosrc/runtime/os_linux_novdso.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build !386,!amd64,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le
7 |
8 | package runtime
9 |
10 | func vdsoauxv(tag, val uintptr) {
11 | }
12 |
--------------------------------------------------------------------------------
/gosrc/runtime/os_linux_x86.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 | // +build 386 amd64
7 |
8 | package runtime
9 |
10 | func osArchInit() {}
11 |
--------------------------------------------------------------------------------
/gosrc/runtime/os_nonopenbsd.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !openbsd
6 |
7 | package runtime
8 |
9 | // osStackAlloc performs OS-specific initialization before s is used
10 | // as stack memory.
11 | func osStackAlloc(s *mspan) {
12 | }
13 |
14 | // osStackFree undoes the effect of osStackAlloc before s is returned
15 | // to the heap.
16 | func osStackFree(s *mspan) {
17 | }
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/preempt_nonwindows.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !windows
6 |
7 | package runtime
8 |
9 | //go:nosplit
10 | func osPreemptExtEnter(mp *m) {}
11 |
12 | //go:nosplit
13 | func osPreemptExtExit(mp *m) {}
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/preempt_wasm.s:
--------------------------------------------------------------------------------
1 | // Code generated by mkpreempt.go; DO NOT EDIT.
2 |
3 | #include "go_asm.h"
4 | #include "textflag.h"
5 |
6 | // Note: asyncPreempt doesn't use the internal ABI, but we must be able to inject calls to it from the signal handler, so Go code has to see the PC of this function literally.
7 | TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
8 | // No async preemption on wasm
9 | UNDEF
10 |
--------------------------------------------------------------------------------
/gosrc/runtime/race/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package race implements data race detection logic.
6 | // No public interface is provided.
7 | // For details about the race detector see
8 | // https://golang.org/doc/articles/race_detector.html
9 | package race
10 |
--------------------------------------------------------------------------------
/gosrc/runtime/race/race.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build race,linux,amd64 race,freebsd,amd64 race,netbsd,amd64 race,darwin,amd64 race,windows,amd64 race,linux,ppc64le race,linux,arm64 race,darwin,arm64
6 |
7 | package race
8 |
9 | // This file merely ensures that we link in runtime/cgo in race build,
10 | // this in turn ensures that runtime uses pthread_create to create threads.
11 | // The prebuilt race runtime lives in race_GOOS_GOARCH.syso.
12 | // Calls to the runtime are done directly from src/runtime/race.go.
13 |
14 | // void __race_unused_func(void);
15 | import "C"
16 |
--------------------------------------------------------------------------------
/gosrc/runtime/rdebug.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package runtime
6 |
7 | import _ "unsafe" // for go:linkname
8 |
9 | //go:linkname setMaxStack runtime/debug.setMaxStack
10 | func setMaxStack(in int) (out int) {
11 | out = int(maxstacksize)
12 | maxstacksize = uintptr(in)
13 | return out
14 | }
15 |
16 | //go:linkname setPanicOnFault runtime/debug.setPanicOnFault
17 | func setPanicOnFault(new bool) (old bool) {
18 | _g_ := getg()
19 | old = _g_.paniconfault
20 | _g_.paniconfault = new
21 | return old
22 | }
23 |
--------------------------------------------------------------------------------
/gosrc/runtime/relax_stub.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !windows
6 |
7 | package runtime
8 |
9 | // osRelaxMinNS is the number of nanoseconds of idleness to tolerate
10 | // without performing an osRelax. Since osRelax may reduce the
11 | // precision of timers, this should be enough larger than the relaxed
12 | // timer precision to keep the timer error acceptable.
13 | const osRelaxMinNS = 0
14 |
15 | // osRelax is called by the scheduler when transitioning to and from
16 | // all Ps being idle.
17 | func osRelax(relax bool) {}
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/rt0_darwin_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #include "textflag.h"
6 |
7 | TEXT _rt0_amd64_darwin(SB),NOSPLIT,$-8
8 | JMP _rt0_amd64(SB)
9 |
10 | // When linking with -shared, this symbol is called when the shared library
11 | // is loaded.
12 | TEXT _rt0_amd64_darwin_lib(SB),NOSPLIT,$0
13 | JMP _rt0_amd64_lib(SB)
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/rt0_ios_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #include "textflag.h"
6 |
7 | // internal linking executable entry point.
8 | // ios/amd64 only supports external linking.
9 | TEXT _rt0_amd64_ios(SB),NOSPLIT|NOFRAME,$0
10 | UNDEF
11 |
12 | // library entry point.
13 | TEXT _rt0_amd64_ios_lib(SB),NOSPLIT|NOFRAME,$0
14 | JMP _rt0_amd64_darwin_lib(SB)
15 |
--------------------------------------------------------------------------------
/gosrc/runtime/rt0_linux_amd64.s:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | #include "textflag.h"
6 |
7 | TEXT _rt0_amd64_linux(SB),NOSPLIT,$-8
8 | JMP _rt0_amd64(SB)
9 |
10 | TEXT _rt0_amd64_linux_lib(SB),NOSPLIT,$0
11 | JMP _rt0_amd64_lib(SB)
12 |
--------------------------------------------------------------------------------
/gosrc/runtime/sigaction.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux,!amd64,!arm64 freebsd,!amd64
6 |
7 | package runtime
8 |
9 | // This version is used on Linux and FreeBSD systems on which we don't
10 | // use cgo to call the C version of sigaction.
11 | // 此版本用于 Linux 和 FreeBSD 系统,我们不使用 cgo 来调用 sigaction 的 C 版本。
12 |
13 | //go:nosplit
14 | //go:nowritebarrierrec
15 | func sigaction(sig uint32, new, old *sigactiont) {
16 | sysSigaction(sig, new, old)
17 | }
18 |
--------------------------------------------------------------------------------
/gosrc/runtime/sigqueue_note.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // The current implementation of notes on Darwin is not async-signal-safe,
6 | // so on Darwin the sigqueue code uses different functions to wake up the
7 | // signal_recv thread. This file holds the non-Darwin implementations of
8 | // those functions. These functions will never be called.
9 |
10 | // +build !darwin
11 | // +build !plan9
12 |
13 | package runtime
14 |
15 | func sigNoteSetup(*note) {
16 | throw("sigNoteSetup")
17 | }
18 |
19 | func sigNoteSleep(*note) {
20 | throw("sigNoteSleep")
21 | }
22 |
23 | func sigNoteWakeup(*note) {
24 | throw("sigNoteWakeup")
25 | }
26 |
--------------------------------------------------------------------------------
/gosrc/runtime/stubs3.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !plan9
6 | // +build !solaris
7 | // +build !freebsd
8 | // +build !darwin
9 | // +build !aix
10 |
11 | package runtime
12 |
13 | func nanotime1() int64
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/stubs_linux.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux
6 |
7 | package runtime
8 |
9 | import "unsafe"
10 |
11 | func sbrk0() uintptr
12 |
13 | // Called from write_err_android.go only, but defined in sys_linux_*.s;
14 | // declared here (instead of in write_err_android.go) for go vet on non-android builds.
15 | // The return value is the raw syscall result, which may encode an error number.
16 | //go:noescape
17 | func access(name *byte, mode int32) int32
18 | func connect(fd int32, addr unsafe.Pointer, len int32) int32
19 | func socket(domain int32, typ int32, prot int32) int32
20 |
--------------------------------------------------------------------------------
/gosrc/runtime/stubs_nonlinux.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !linux
6 |
7 | package runtime
8 |
9 | // sbrk0 returns the current process brk, or 0 if not implemented.
10 | func sbrk0() uintptr {
11 | return 0
12 | }
13 |
--------------------------------------------------------------------------------
/gosrc/runtime/sys_nonppc64x.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !ppc64,!ppc64le
6 |
7 | package runtime
8 |
9 | func prepGoExitFrame(sp uintptr) {
10 | }
11 |
--------------------------------------------------------------------------------
/gosrc/runtime/sys_wasm.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package runtime
6 |
7 | import (
8 | "runtime/internal/sys"
9 | "unsafe"
10 | )
11 |
12 | type m0Stack struct {
13 | _ [8192 * sys.StackGuardMultiplier]byte
14 | }
15 |
16 | var wasmStack m0Stack
17 |
18 | func wasmMove()
19 |
20 | func wasmZero()
21 |
22 | func wasmDiv()
23 |
24 | func wasmTruncS()
25 | func wasmTruncU()
26 |
27 | func wasmExit(code int32)
28 |
29 | // adjust Gobuf as it if executed a call to fn with context ctxt
30 | // and then did an immediate gosave.
31 | func gostartcall(buf *gobuf, fn, ctxt unsafe.Pointer) {
32 | sp := buf.sp
33 | if sys.RegSize > sys.PtrSize {
34 | sp -= sys.PtrSize
35 | *(*uintptr)(unsafe.Pointer(sp)) = 0
36 | }
37 | sp -= sys.PtrSize
38 | *(*uintptr)(unsafe.Pointer(sp)) = buf.pc
39 | buf.sp = sp
40 | buf.pc = uintptr(fn)
41 | buf.ctxt = ctxt
42 | }
43 |
--------------------------------------------------------------------------------
/gosrc/runtime/sys_x86.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build amd64 386
6 |
7 | package runtime
8 |
9 | import (
10 | "runtime/internal/sys"
11 | "unsafe"
12 | )
13 |
14 | // adjust Gobuf as if it executed a call to fn with context ctxt
15 | // and then did an immediate gosave.
16 | // 调整 Gobuf,就好像它用上下文 ctxt 对 fn 执行了一个调用,然后立即进行了 gosave
17 | func gostartcall(buf *gobuf, fn, ctxt unsafe.Pointer) {
18 | sp := buf.sp
19 | if sys.RegSize > sys.PtrSize {
20 | sp -= sys.PtrSize
21 | *(*uintptr)(unsafe.Pointer(sp)) = 0
22 | }
23 | sp -= sys.PtrSize
24 | *(*uintptr)(unsafe.Pointer(sp)) = buf.pc
25 | buf.sp = sp
26 | buf.pc = uintptr(fn)
27 | buf.ctxt = ctxt
28 | }
29 |
--------------------------------------------------------------------------------
/gosrc/runtime/time_nofake.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !faketime
6 |
7 | package runtime
8 |
9 | import "unsafe"
10 |
11 | // faketime is the simulated time in nanoseconds since 1970 for the
12 | // playground.
13 | //
14 | // Zero means not to use faketime.
15 | var faketime int64
16 |
17 | //go:nosplit
18 | func nanotime() int64 {
19 | return nanotime1()
20 | }
21 |
22 | func walltime() (sec int64, nsec int32) {
23 | return walltime1()
24 | }
25 |
26 | // write must be nosplit on Windows (see write1)
27 | //
28 | //go:nosplit
29 | func write(fd uintptr, p unsafe.Pointer, n int32) int32 {
30 | return write1(fd, p, n)
31 | }
32 |
--------------------------------------------------------------------------------
/gosrc/runtime/timestub.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Declarations for operating systems implementing time.now
6 | // indirectly, in terms of walltime and nanotime assembly.
7 |
8 | // +build !windows
9 |
10 | package runtime
11 |
12 | import _ "unsafe" // for go:linkname
13 |
14 | //go:linkname time_now time.now
15 | func time_now() (sec int64, nsec int32, mono int64) {
16 | sec, nsec = walltime()
17 | return sec, nsec, nanotime()
18 | }
19 |
--------------------------------------------------------------------------------
/gosrc/runtime/timestub2.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !darwin
6 | // +build !windows
7 | // +build !freebsd
8 | // +build !aix
9 | // +build !solaris
10 |
11 | package runtime
12 |
13 | func walltime1() (sec int64, nsec int32)
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/vdso_in_none.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build linux,!386,!amd64,!arm,!arm64,!mips64,!mips64le,!ppc64,!ppc64le !linux
6 |
7 | package runtime
8 |
9 | // A dummy version of inVDSOPage for targets that don't use a VDSO.
10 |
11 | func inVDSOPage(pc uintptr) bool {
12 | return false
13 | }
14 |
--------------------------------------------------------------------------------
/gosrc/runtime/vdso_linux_amd64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package runtime
6 |
7 | const (
8 | // vdsoArrayMax is the byte-size of a maximally sized array on this architecture.
9 | // See cmd/compile/internal/amd64/galign.go arch.MAXWIDTH initialization.
10 | vdsoArrayMax = 1<<50 - 1
11 | )
12 |
13 | var vdsoLinuxVersion = vdsoVersionKey{"LINUX_2.6", 0x3ae75f6}
14 |
15 | var vdsoSymbolKeys = []vdsoSymbolKey{
16 | {"__vdso_gettimeofday", 0x315ca59, 0xb01bca00, &vdsoGettimeofdaySym},
17 | {"__vdso_clock_gettime", 0xd35ec75, 0x6e43a318, &vdsoClockgettimeSym},
18 | }
19 |
20 | var (
21 | vdsoGettimeofdaySym uintptr
22 | vdsoClockgettimeSym uintptr
23 | )
24 |
--------------------------------------------------------------------------------
/gosrc/runtime/write_err.go:
--------------------------------------------------------------------------------
1 | // Copyright 2009 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !android
6 |
7 | package runtime
8 |
9 | import "unsafe"
10 |
11 | func writeErr(b []byte) {
12 | write(2, unsafe.Pointer(&b[0]), int32(len(b)))
13 | }
14 |
--------------------------------------------------------------------------------
/gosrc/sync/atomic/race.s:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build race
6 |
7 | // This file is here only to allow external functions.
8 | // The operations are implemented in src/runtime/race_amd64.s
9 |
--------------------------------------------------------------------------------
/gosrc/sync/runtime2.go:
--------------------------------------------------------------------------------
1 | // Copyright 2020 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !goexperiment.staticlockranking
6 |
7 | package sync
8 |
9 | import "unsafe"
10 |
11 | // Approximation of notifyList in runtime/sema.go. Size and alignment must
12 | // agree.
13 | type notifyList struct {
14 | wait uint32
15 | notify uint32
16 | lock uintptr // key field of the mutex
17 | head unsafe.Pointer
18 | tail unsafe.Pointer
19 | }
20 |
--------------------------------------------------------------------------------
/gosrc/syscall/endian_little.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 | //
5 | // +build 386 amd64 arm arm64 ppc64le mips64le mipsle riscv64 wasm
6 |
7 | package syscall
8 |
9 | const isBigEndian = false
10 |
--------------------------------------------------------------------------------
/gosrc/syscall/flock.go:
--------------------------------------------------------------------------------
1 | // +build linux freebsd openbsd netbsd dragonfly
2 |
3 | // Copyright 2014 The Go Authors. All rights reserved.
4 | // Use of this source code is governed by a BSD-style
5 | // license that can be found in the LICENSE file.
6 |
7 | package syscall
8 |
9 | import "unsafe"
10 |
11 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux
12 | // systems by flock_linux_32bit.go to be SYS_FCNTL64.
13 | var fcntl64Syscall uintptr = SYS_FCNTL
14 |
15 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
16 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
17 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk)))
18 | if errno == 0 {
19 | return nil
20 | }
21 | return errno
22 | }
23 |
--------------------------------------------------------------------------------
/gosrc/syscall/flock_darwin.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package syscall
6 |
7 | import "unsafe"
8 |
9 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
10 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error {
11 | _, err := fcntlPtr(int(fd), cmd, unsafe.Pointer(lk))
12 | return err
13 | }
14 |
--------------------------------------------------------------------------------
/gosrc/syscall/forkpipe.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build aix darwin dragonfly solaris
6 |
7 | package syscall
8 |
9 | // Try to open a pipe with O_CLOEXEC set on both file descriptors.
10 | func forkExecPipe(p []int) error {
11 | err := Pipe(p)
12 | if err != nil {
13 | return err
14 | }
15 | _, err = fcntl(p[0], F_SETFD, FD_CLOEXEC)
16 | if err != nil {
17 | return err
18 | }
19 | _, err = fcntl(p[1], F_SETFD, FD_CLOEXEC)
20 | return err
21 | }
22 |
--------------------------------------------------------------------------------
/gosrc/syscall/forkpipe2.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build freebsd netbsd openbsd
6 |
7 | package syscall
8 |
9 | func forkExecPipe(p []int) error {
10 | return Pipe2(p, O_CLOEXEC)
11 | }
12 |
--------------------------------------------------------------------------------
/gosrc/syscall/mksysnum_darwin.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env perl
2 | # Copyright 2009 The Go Authors. All rights reserved.
3 | # Use of this source code is governed by a BSD-style
4 | # license that can be found in the LICENSE file.
5 | #
6 | # Generate system call table for Darwin from sys/syscall.h
7 |
8 | use strict;
9 |
10 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV);
11 |
12 | print <){
22 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){
23 | my $name = $1;
24 | my $num = $2;
25 | $name =~ y/a-z/A-Z/;
26 | print " SYS_$name = $num;"
27 | }
28 | }
29 |
30 | print <= 10 {
18 | buf[i] = byte(val%10 + '0')
19 | i--
20 | val /= 10
21 | }
22 | buf[i] = byte(val + '0')
23 | return string(buf[i:])
24 | }
25 |
--------------------------------------------------------------------------------
/gosrc/syscall/time_fake.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build faketime
6 |
7 | package syscall
8 |
9 | import "unsafe"
10 |
11 | const faketime = true
12 |
13 | // When faketime is enabled, we redirect writes to FDs 1 and 2 through
14 | // the runtime's write function, since that adds the framing that
15 | // reports the emulated time.
16 |
17 | //go:linkname runtimeWrite runtime.write
18 | func runtimeWrite(fd uintptr, p unsafe.Pointer, n int32) int32
19 |
20 | func faketimeWrite(fd int, p []byte) int {
21 | var pp *byte
22 | if len(p) > 0 {
23 | pp = &p[0]
24 | }
25 | return int(runtimeWrite(uintptr(fd), unsafe.Pointer(pp), int32(len(p))))
26 | }
27 |
--------------------------------------------------------------------------------
/gosrc/syscall/time_nofake.go:
--------------------------------------------------------------------------------
1 | // Copyright 2019 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !faketime
6 |
7 | package syscall
8 |
9 | const faketime = false
10 |
11 | func faketimeWrite(fd int, p []byte) int {
12 | // This should never be called since faketime is false.
13 | panic("not implemented")
14 | }
15 |
--------------------------------------------------------------------------------
/website/Makefile:
--------------------------------------------------------------------------------
1 | all: clean
2 | go run make-cn.go
3 | hugo -D --minify
4 |
5 | s: all
6 | hugo server -D
7 |
8 | clean:
9 | rm -rf content resources public
--------------------------------------------------------------------------------
/website/archetypes/default.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "{{ replace .Name "-" " " | title }}"
3 | date: {{ .Date }}
4 | draft: true
5 | ---
6 |
7 |
--------------------------------------------------------------------------------
/website/config.toml:
--------------------------------------------------------------------------------
1 | baseURL = "http://golang.design/under-the-hood"
2 | languageCode = "zh-cn"
3 | title = "Go 语言原本"
4 | theme = "book"
5 |
6 | [markup.highlight]
7 | codeFences = true
8 | guessSyntax = false
9 | hl_Lines = ""
10 | lineNoStart = 1
11 | lineNos = true
12 | lineNumbersInTable = true
13 | noClasses = true
14 | style = "vs"
15 | tabWidth = 4
16 | [markup.goldmark.renderer]
17 | unsafe= true
--------------------------------------------------------------------------------
/website/themes/book/archetypes/docs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "{{ .Name | humanize | title }}"
3 | weight: 1
4 | # bookFlatSection: false
5 | # bookToc: 6
6 | # bookHidden: false
7 | ---
8 |
--------------------------------------------------------------------------------
/website/themes/book/archetypes/posts.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "{{ replace .Name "-" " " | title }}"
3 | date: {{ .Date }}
4 | ---
5 |
--------------------------------------------------------------------------------
/website/themes/book/assets/_custom.scss:
--------------------------------------------------------------------------------
1 | .img-center {
2 | display: block;
3 | margin: 1.0rem auto;
4 | margin-bottom: 30px;
5 | height: auto;
6 | text-align: center;
7 | }
8 | .img-center img {
9 | padding: 5px;
10 | }
11 | .img-center strong {
12 | display: block;
13 | }
14 | .guide-links {
15 | font-weight: bolder;
16 | margin-bottom: 50px;
17 | }
--------------------------------------------------------------------------------
/website/themes/book/assets/_print.scss:
--------------------------------------------------------------------------------
1 | @media print {
2 | .book-menu,
3 | .book-footer {
4 | display: none;
5 | }
6 |
7 | main {
8 | flex-direction: column-reverse;
9 | }
10 |
11 | .book-toc {
12 | flex: none;
13 |
14 | nav {
15 | position: relative;
16 | width: auto;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/website/themes/book/assets/_utils.scss:
--------------------------------------------------------------------------------
1 | .flex {
2 | display: flex;
3 | }
4 |
5 | .flex-auto {
6 | flex: 1 1 auto;
7 | }
8 |
9 | .flex-even {
10 | flex: 1 1;
11 | }
12 |
13 | .flex-wrap {
14 | flex-wrap: wrap;
15 | }
16 |
17 | .justify-start {
18 | justify-content: flex-start;
19 | }
20 |
21 | .justify-end {
22 | justify-content: flex-end;
23 | }
24 |
25 | .justify-center {
26 | justify-content: center;
27 | }
28 |
29 | .justify-between {
30 | justify-content: space-between;
31 | }
32 |
33 | .align-center {
34 | align-items: center;
35 | }
36 |
37 | .mx-auto {
38 | margin: 0 auto;
39 | }
40 |
41 | .text-center {
42 | text-align: center;
43 | }
44 |
45 | .hidden {
46 | display: none;
47 | }
48 |
49 | @mixin spin($duration) {
50 | animation: spin $duration ease infinite;
51 | @keyframes spin {
52 | 100% {
53 | transform: rotate(360deg);
54 | }
55 | }
56 | }
57 |
58 | @mixin fixed {
59 | position: fixed;
60 | top: 0;
61 | bottom: 0;
62 | overflow-x: hidden;
63 | overflow-y: auto;
64 | }
65 |
--------------------------------------------------------------------------------
/website/themes/book/assets/_variables.scss:
--------------------------------------------------------------------------------
1 | /* You can override SASS variables here. */
2 |
3 | // @import "plugins/dark";
4 |
--------------------------------------------------------------------------------
/website/themes/book/assets/book.scss:
--------------------------------------------------------------------------------
1 | @import "defaults";
2 | @import "variables";
3 |
4 | @import "normalize";
5 | @import "utils";
6 | @import "main";
7 | @import "fonts";
8 | @import "print";
9 |
10 | @import "markdown";
11 | @import "shortcodes";
12 |
13 | // Custom defined styles
14 | @import "custom";
15 |
--------------------------------------------------------------------------------
/website/themes/book/assets/search-data.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | (function() {
4 | const indexCfg = {{ with .Scratch.Get "bookSearchConfig" }}
5 | {{ . }};
6 | {{ else }}
7 | {};
8 | {{ end }}
9 |
10 | indexCfg.doc = {
11 | id: 'id',
12 | field: ['title', 'content'],
13 | store: ['title', 'href'],
14 | };
15 |
16 | const index = FlexSearch.create('balance', indexCfg);
17 | window.bookSearchIndex = index;
18 |
19 | {{ range $index, $page := .Site.Pages }}
20 | index.add({
21 | 'id': {{ $index }},
22 | 'href': '{{ $page.RelPermalink }}',
23 | 'title': {{ (partial "zh-cn/title" $page) | jsonify }},
24 | 'content': {{ $page.Plain | jsonify }}
25 | });
26 | {{- end -}}
27 | })();
28 |
--------------------------------------------------------------------------------
/website/themes/book/i18n/cn.yaml:
--------------------------------------------------------------------------------
1 | - id: Search
2 | translation: 搜索
3 |
4 | - id: Edit this page
5 | translation: Edit this page
6 |
7 | - id: Last modified by
8 | translation: Last modified by
9 |
10 | - id: bookSearchConfig
11 | translation: |
12 | {
13 | encode: false,
14 | tokenize: function(str) {
15 | return str.replace(/[\x00-\x7F]/g, '').split('');
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/website/themes/book/i18n/en.yaml:
--------------------------------------------------------------------------------
1 | - id: Search
2 | translation: Search
3 |
4 | - id: Edit this page
5 | translation: Edit this page
6 |
7 | - id: Last modified by
8 | translation: Last modified by
9 |
10 | - id: bookSearchConfig
11 | translation: '{ cache: true }'
12 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ partial "zh-cn/html-head" . }}
6 | {{ partial "zh-cn/inject/head" . }}
7 |
8 |
9 |
10 |
11 | 404 Not Found
12 |
13 |
14 | {{ partial "zh-cn/inject/body" . }}
15 | {{ template "_internal/google_analytics_async.html" . }}
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/home.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ partial "zh-cn/html-head" . }}
6 | {{ partial "zh-cn/inject/head" . }}
7 |
8 | {{ $content := `
9 | # Hugo Book Theme
10 |
11 | This is a placeholder for home page.
12 | You can override this page in:
13 |
14 | - `/content/_index.md`
15 | - `/layouts/home.html`
16 | ` }}
17 |
18 |
19 |
20 | {{ replace $content "`" "`" | markdownify }}
21 |
22 |
23 |
24 | {{ partial "zh-cn/inject/body" . }}
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/inject/body.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/layouts/partials/zh-cn/inject/body.html
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/inject/head.html:
--------------------------------------------------------------------------------
1 | {{ partial "zh-cn/mathjax-support.html" . }}
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/inject/menu-after.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Go Under the Hood: A source code study © 2018 - 2020 Changkun Ou
4 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/inject/menu-before.html:
--------------------------------------------------------------------------------
1 |
6 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/languages.html:
--------------------------------------------------------------------------------
1 |
2 | {{ $langs := dict }}
3 | {{ range .Site.Home.AllTranslations }}
4 | {{ $langs = merge $langs (dict .Language.Lang .) }}
5 | {{ end }}
6 | {{ range .Translations }}
7 | {{ $langs = merge $langs (dict .Language.Lang .) }}
8 | {{ end }}
9 |
10 |
11 |
12 |
13 |
14 |
15 | {{ $.Site.Language.LanguageName }}
16 |
17 |
18 |
19 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/menu-bundle.html:
--------------------------------------------------------------------------------
1 | {{ with .Site.GetPage .Site.Params.BookMenuBundle }}
2 | {{- $href := printf "href=\"%s\"" $.RelPermalink -}}
3 | {{- replace .Content $href (print $href "class=active") | safeHTML -}}
4 | {{ end }}
5 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/menu.html:
--------------------------------------------------------------------------------
1 |
2 | {{ partial "zh-cn/brand" . }}
3 | {{ partial "zh-cn/search" . }}
4 | {{ partial "zh-cn/inject/menu-before" . }}
5 |
6 | {{ if .Site.Params.BookMenuBundle }}
7 | {{ partial "zh-cn/menu-bundle" . }}
8 | {{ else }}
9 | {{ partial "zh-cn/menu-filetree" . }}
10 | {{ end }}
11 |
12 | {{ partial "zh-cn/inject/menu-after" . }}
13 |
14 |
15 |
16 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/mobile-header.html:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/search.html:
--------------------------------------------------------------------------------
1 | {{ if default true .Site.Params.BookSearch }}
2 |
3 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | {{ end }}
15 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/title.html:
--------------------------------------------------------------------------------
1 | {{ $title := "Changkun Ou" }}
2 |
3 | {{ if .Title }}
4 | {{ $title = .Title }}
5 | {{ else if and .IsSection .File }}
6 | {{ $sections := split (trim .File.Dir "/") "/" }}
7 | {{ $title = index ($sections | last 1) 0 | humanize | title }}
8 | {{ else if and .IsPage .File }}
9 | {{ $title = .File.BaseFileName | humanize | title }}
10 | {{ end }}
11 |
12 | {{ return $title }}
13 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/partials/zh-cn/toc.html:
--------------------------------------------------------------------------------
1 | {{ $tocLevels := default (default 6 .Site.Params.BookToC) .Params.BookToC }}
2 | {{ if and $tocLevels .Page.TableOfContents }}
3 |
4 | {{ .Page.TableOfContents }}
5 |
6 | {{ end }}
7 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/posts/baseof.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ partial "zh-cn/html-head" . }}
6 | {{ partial "zh-cn/inject/head" . }}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
16 |
17 |
18 | {{ partial "zh-cn/mobile-header" . }}
19 | {{ template "main" . }}
20 | {{ partial "zh-cn/footer" . }}
21 | {{ partial "zh-cn/inject/footer" . }}
22 |
23 |
24 | {{ template "toc" . }}
25 |
26 |
27 | {{ partial "zh-cn/inject/body" . }}
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/posts/list.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 | {{ $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat }}
3 | {{ $paginator := .Paginate (where .Pages "Params.hidden" "ne" true) }}
4 | {{ range sort .Paginator.Pages }}
5 |
6 |
9 |
10 | {{ .Date.Format $dateFormat }}
11 |
12 |
13 | {{- .Summary -}}
14 | {{ if .Truncated }}
15 | ...
16 | {{ end }}
17 |
18 |
19 | {{ end }}
20 | {{ template "_internal/pagination.html" . }}
21 | {{ end }}
22 |
23 | {{ define "toc" }}
24 |
25 | {{ end }}
26 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/posts/single.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 | {{ $dateFormat := default "January 2, 2006" .Site.Params.BookDateFormat }}
3 |
4 | {{ .Title }}
5 |
6 | {{ .Date.Format $dateFormat }}
7 |
8 |
9 |
10 | {{- .Content -}}
11 |
12 | {{ end }}
13 |
14 | {{ define "toc" }}
15 | {{ partial "zh-cn/toc" . }}
16 | {{ end }}
17 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/shortcodes/button.html:
--------------------------------------------------------------------------------
1 | {{ $ref := "" }}
2 | {{ $target := "" }}
3 | {{ with .Get "href" }}
4 | {{ $ref = . }}
5 | {{ $target = "_blank" }}
6 | {{ end }}
7 | {{ with .Get "relref" }}
8 | {{ $ref = relref $ . }}
9 | {{ end }}
10 |
11 | {{ $.Inner }}
12 |
13 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/shortcodes/columns.html:
--------------------------------------------------------------------------------
1 |
2 | {{ range split .Inner "<--->" }}
3 |
4 | {{ . | markdownify }}
5 |
6 | {{ end }}
7 |
8 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/shortcodes/expand.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ default "Expand" (.Get 0) }}
5 | {{ default "↕" (.Get 1) }}
6 |
7 |
8 |
9 | {{ .Inner | markdownify }}
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/shortcodes/hint.html:
--------------------------------------------------------------------------------
1 |
2 | {{ .Inner | markdownify }}
3 |
4 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/shortcodes/mermaid.html:
--------------------------------------------------------------------------------
1 | {{ if not (.Page.Scratch.Get "mermaid") }}
2 |
3 |
4 | {{ .Page.Scratch.Set "mermaid" true }}
5 | {{ end }}
6 |
7 |
8 | {{- .Inner -}}
9 |
10 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/shortcodes/tab.html:
--------------------------------------------------------------------------------
1 | {{ if .Parent }}
2 | {{ $name := .Get 0 }}
3 | {{ $group := printf "tabs-%s" (.Parent.Get 0) }}
4 |
5 | {{ if not (.Parent.Scratch.Get $group) }}
6 | {{ .Parent.Scratch.Set $group slice }}
7 | {{ end }}
8 |
9 | {{ .Parent.Scratch.Add $group (dict "Name" $name "Content" .Inner) }}
10 | {{ else }}
11 | {{ errorf "%q: 'tab' shortcode must be inside 'tabs' shortcode" .Page.Path }}
12 | {{ end}}
13 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/shortcodes/tabs.html:
--------------------------------------------------------------------------------
1 | {{ if .Inner }}{{ end }}
2 | {{ $id := .Get 0 }}
3 | {{ $group := printf "tabs-%s" $id }}
4 |
5 |
6 | {{ range $index, $tab := .Scratch.Get $group }}
7 |
8 |
9 | {{ $tab.Name }}
10 |
11 |
12 | {{ .Content | markdownify }}
13 |
14 | {{ end }}
15 |
16 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/taxonomy/list.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/layouts/taxonomy/list.html
--------------------------------------------------------------------------------
/website/themes/book/layouts/taxonomy/taxonomy.html:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/layouts/taxonomy/taxonomy.html
--------------------------------------------------------------------------------
/website/themes/book/layouts/zh-cn/baseof.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {{ partial "zh-cn/html-head" . }}
6 | {{ partial "zh-cn/inject/head" . }}
7 |
8 |
9 |
10 |
11 |
12 |
15 |
16 |
17 | {{ partial "zh-cn/mobile-header" . }}
18 | {{ template "main" . }}
19 | {{ partial "zh-cn/footer" . }}
20 | {{ partial "zh-cn/inject/footer" . }}
21 |
22 |
23 | {{ template "toc" . }}
24 |
25 |
26 | {{ partial "zh-cn/inject/body" . }}
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/zh-cn/list.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 |
3 | {{- .Content -}}
4 |
5 | {{ end }}
6 |
7 | {{ define "toc" }}
8 | {{ partial "zh-cn/toc" . }}
9 | {{ end }}
10 |
--------------------------------------------------------------------------------
/website/themes/book/layouts/zh-cn/single.html:
--------------------------------------------------------------------------------
1 | {{ define "main" }}
2 |
3 | {{- .Content -}}
4 |
5 | {{ end }}
6 |
7 | {{ define "toc" }}
8 | {{ partial "zh-cn/toc" . }}
9 | {{ end }}
10 |
--------------------------------------------------------------------------------
/website/themes/book/static/dark.js:
--------------------------------------------------------------------------------
1 | var enabled = localStorage.getItem('dark-mode')
2 | if (enabled === null) {
3 | if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
4 | enable(); document.getElementById("dark-mode-checkbox").checked = true;
5 | }
6 | } else if (enabled === 'true') {
7 | enable(); document.getElementById("dark-mode-checkbox").checked = true;
8 | }
9 | function enable() {
10 | DarkReader.enable({brightness: 100, contrast: 85, sepia: 10});
11 | localStorage.setItem('dark-mode', 'true');
12 | }
13 | function disable() {
14 | DarkReader.disable();
15 | localStorage.setItem('dark-mode', 'false')
16 | }
17 | function darkmode() {
18 | if (localStorage.getItem('dark-mode') === 'false') { enable(); } else { disable();}
19 | }
--------------------------------------------------------------------------------
/website/themes/book/static/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/favicon.png
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-mono-v6-latin-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-mono-v6-latin-regular.woff
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-mono-v6-latin-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-mono-v6-latin-regular.woff2
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-v19-latin-300italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-v19-latin-300italic.woff
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-v19-latin-300italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-v19-latin-300italic.woff2
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-v19-latin-700.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-v19-latin-700.woff
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-v19-latin-700.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-v19-latin-700.woff2
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-v19-latin-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-v19-latin-regular.woff
--------------------------------------------------------------------------------
/website/themes/book/static/fonts/roboto-v19-latin-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/golang-design/under-the-hood/d433f404cd134605680d0572dfe5dc02e2d15dab/website/themes/book/static/fonts/roboto-v19-latin-regular.woff2
--------------------------------------------------------------------------------
/website/themes/book/static/svg/calendar.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/website/themes/book/static/svg/edit.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/website/themes/book/static/svg/menu.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/website/themes/book/static/svg/translate.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/website/themes/book/theme.toml:
--------------------------------------------------------------------------------
1 | # theme.toml template for a Hugo theme
2 | name = "Book"
3 | license = "CC-BY-ND-NC 4.0 & MIT"
4 | licenselink = "https://github.com/golang-design/under-the-hood/blob/master/LICENSE"
5 | description = "Go Under The Hood: A source code study"
6 | homepage = "https://github.com/golang-design/under-the-hood"
7 | tags = ["Go 语言原本", "Go", "源码分析", "Source code study", "书", "book", "responsive", "clean"]
8 | features = []
9 | min_version = "0.10"
10 |
11 | [author]
12 | name = "Changkun Ou"
13 | homepage = "https://changkun.de/"
14 |
--------------------------------------------------------------------------------