''' Go를 설치하고 .vimrc에 Plugin 'fatih/vim-go' 와 Plugin 'zchee/deoplete-go' 를 추가하고 :PluginInstall 을 합시다. 이후에 :GoInstallBinaries 을 입력해서 Go관련 실행 파일들을 받습니다. '''
- Gopher Guides
- How to code in go
- An Introduction to Go(CERN)
- Understanding Go Map
- Understanding Go Pointers
- go walkthrough io package
- Learning go by Miek Gieben : this site is good for quick speedup of go programming experience.
Creating an empty hash map. Which ensures that you will never get a runtime panic.
var dictionary = map[string]string{}
// OR
var dictionary = make(map[string]string)
- Go Interface Internals(https://research.swtch.com/interfaces)
- 50 common gotchas in go
- bad go with slice
- bad go slice of pointers
- Golang tips: why the pointer to slice is useful & tricky bugs
- Einstein Analytics Migration from python to Go
- Go benchmark & Assembly level analysis : A tale of two copies
Our team created a proof of concept (POC) that achieved near parity in performance with the C engine,
but only if we used the right programming patterns:
- Buffer all IO to reduce the overhead on Go system calls.
On a system call, current Goroutines yield to that call.
- When possible in tight loops, use structs instead of interfaces
to minimize the interface methods indirection overhead.
- Use pre-allocated buffers within tight loops (similarly to how io.Reader works)
to minimize garbage collection pressure.
- Process data rows in batches as a workaround to poor compiler inlining,
as to move the actual computation closer to the data and minimize
the overhead on each function call.
- 작고 가벼운 Go Container 뛰우기
- Containerize This! How to build Golang Dockerfiles
- Docker file example
- Build docker container image in go
- $ godoc builtin | more
- $ godoc net/http | more
$ go tool compile unsafe.go (object file 생성)
$ go tool compile -pack unsafe.go (archive file 생성)
$ go tool compile -race unsafe.go (race condition 감지)
$ go tool compile -S unsafe.go (assembly)
$ go tool compile -W hello.go (node tree 생성)
$ go build -o add.a
$ go tool objdump add.a
- example runtime_trace.go file for trace
package main
import (
"os"
"runtime/trace"
)
func main() {
trace.Start(os.Stderr)
defer trace.Stop()
ch := make(chan int)
go func() {
ch <-42
}()
<-ch
}
-executing go tool trace
$ go run runtime_trace.go 2>trace.out
$ go tool trace trace.out
CopherCon2019 : Dave Cheney - Two Go programs, Three Different Profiling Techniques
func main() {
defer profile.Start(profile.CPUProfile, profile.ProfilePath(".")).Stop() // Add this line to programe
f, err := os.Open(os.Args[1])
if err != nil {
...
}
}
:Goimports
<< after execution >>
$ go tool pprof cpu.pprof
$ go tool pprof -http=:8080 cpu.pprof
func main() {
defer profile.Start(profile.MemProfile, profile.MemProfileRate(1),profile.ProfilePath(".")).Stop() // Add this line to programe
f, err := os.Open(os.Args[1])
if err != nil {
...
}
}
:Goimports
<< after execution >>
$ go tool pprof mem.pprof
$ go tool pprof -http=:8080 mem.pprof
Most of the leak in go program
– Creating substrings and subslices.
– Wrong use of the defer statement.
– Unclosed HTTP response bodies (or unclosed resources in general).
– Orphaned hanging go routines.
– Global variables.
- Twelve Go Best Practices
- Andrew Gerrand’s idiomatic Naming Convention
- Peter Bourgon's Go best practices, six years in
- Phil Estes's 4 tips for learning Golang
- Visual Studio Code + vscode-go
- Unknow/go-code-convention : For production level coding
- Advanced Go Concurrency
- Visualizing Go Concurrency
- Visualizing Go Concurrency(YouTube)
- 3D gotrace tool
- Go 로 1M request 처리하기
$GODEBUG=gctrace=1 go run gColl.go
- PlanetScale's CTO on go parser
- GopherCon 2018 - How to Write a Parser in Go
- GopherAcademy : Parsing with ANTLR 4 and Go
- GopherAcademy : Handwritten Parsers & Lexers in Go
- Quick guide to assembly
- Rob Pike's talk on go assembly
- go asm complete reference
- SIMD optimization in go
- go assembly related blog
- go Compiler Explorer
- assembly method : $go tool compile -S <go_src.go>
- tricolor mark-and-sweep algorithm (GO GC algorithm)
- On-the-fly Garbage Collection: An Exercise in Cooperation 논문에서 처음 발표됨
check runtime Garbage Stats implementation
printStats(mem runtime.MemStats) {
runtime.ReadMemStats(&mem)
...
}