Introducing the Go Race Detector 26 June 2013 Introduction Race conditions are among the most insidious and elusive programming errors. They typically cause erratic and mysterious failures, often long after the code has been deployed to production. W…
Data Race Detector 数据种类探测器:数据种类探测器手册 Introduction Usage Report Format Options Excluding Tests How To Use Typical Data Races Race on loop counter Accidentally shared variable Unprotected global variable Primitive unprotected variable Supported Systems…
golang中的race检测 由于golang中的go是非常方便的,加上函数又非常容易隐藏go. 所以很多时候,当我们写出一个程序的时候,我们并不知道这个程序在并发情况下会不会出现什么问题. 所以在本质上说,goroutine的使用增加了函数的危险系数论go语言中goroutine的使用.比如一个全局变量,如果没有加上锁,我们写一个比较庞大的项目下来,就根本不知道这个变量是不是会引起多个goroutine竞争. 官网的文章Introducing the Go Race Detector给出的例子…
Godoc: documenting Go code 编写良好的文档关于godoc 31 March 2011 The Go project takes documentation seriously. Documentation is a huge part of making software accessible and maintainable. Of course it must be well-written and accurate, but it also must be ea…
Profiling Go Programs 分析go语言项目 24 June 2011 At Scala Days 2011, Robert Hundt presented a paper titled Loop Recognition in C++/Java/Go/Scala. The paper implemented a specific loop finding algorithm, such as you might use in a flow analysis pass of a…
C? Go? Cgo! 17 March 2011 Introduction Cgo lets Go packages call C code. Given a Go source file written with some special features, cgo outputs Go and C files that can be combined into a single Go package. To lead with an example, here's a Go package…
The Go image/draw package go图片/描绘包:图片/描绘包的基本原理 29 September 2011 Introduction Package image/draw defines only one operation: drawing a source image onto a destination image, through an optional mask image. This one operation is surprisingly versatil…
The Go image package go图片包:图片包的基本原理 21 September 2011 Introduction The image and image/color packages define a number of types: color.Color and color.Model describe colors, image.Point and image.Rectangle describe basic 2-D geometry, and image.Image…
The Laws of Reflection 反射定律:反射包的基本原理 6 September 2011 Introduction 介绍 Reflection in computing is the ability of a program to examine its own structure, particularly through types; it's a form of metaprogramming. It's also a great source of confusion…
Gobs of data 24 March 2011 Introduction To transmit a data structure across a network or to store it in a file, it must be encoded and then decoded again. There are many encodings available, of course: JSON, XML, Google's protocol buffers, and more.…
Error handling and Go go语言错误处理 12 July 2011 Introduction If you have written any Go code you have probably encountered the built-in error type. Go code uses error values to indicate an abnormal state. For example, the os.Openfunction returns a non-ni…
Organizing Go code 16 August 2012 Introduction Go code is organized differently to that of other languages. This post discusses how to name and package the elements of your Go program to best serve its users. Choose good names The names you choose af…
JSON and Go 25 January 2011 Introduction JSON (JavaScript Object Notation) is a simple data interchange format. Syntactically it resembles the objects and lists of JavaScript. It is most commonly used for communication between web back-ends and JavaS…
Go Slices: usage and internals GO语言切片: 使用和内部 5 January 2011 Introduction Go's slice type provides a convenient and efficient means of working with sequences of typed data. Slices are analogous to arrays in other languages, but have some unusual prop…
A GIF decoder: an exercise in Go interfaces 一个GIF解码器:go语言接口训练 25 May 2011 Introduction At the Google I/O conference in San Francisco on May 10, 2011, we announced that the Go language is now available on Google App Engine. Go is the first language t…
Defer, Panic, and Recover 4 August 2010 Go has the usual mechanisms for control flow: if, for, switch, goto. It also has the go statement to run code in a separate goroutine. Here I'd like to discuss some of the less common ones: defer, panic, and re…
Go Concurrency Patterns: Timing out, moving on GO并发模式: 超时, 继续前进 23 September 2010 Concurrent programming has its own idioms. A good example is timeouts. Although Go's channels do not support them directly, they are easy to implement. Say we want to…
JSON-RPC: a tale of interfaces 27 April 2010 Here we present an example where Go's interfaces made it easy to refactor some existing code to make it more flexible and extensible. Originally, the standard library's RPC package used a custom wire forma…
Documentation文档 The Go programming language is an open source project to make programmers more productive. go语言是一个开源项目,是程序员开发更有效率. Go is expressive, concise, clean, and efficient. Its concurrency mechanisms make it easy to write programs that get t…
https://blog.golang.org/pipelines Go Concurrency Patterns: Pipelines and cancellation Sameer Ajmani13 March 2014 Introduction Go's concurrency primitives make it easy to construct streaming data pipelines that make efficient use of I/O and multiple C…
小结: 1. Background is the root of any Context tree; it is never canceled: 2. https://blog.golang.org/context Sameer Ajmani29 July 2014 Introduction In Go servers, each incoming request is handled in its own goroutine. Request handlers often start…
https://mp.weixin.qq.com/s/pVJiFdDDKVx707eKL19bjA 谈谈 Golang 中的 Data Race 原创 ms2008 poslua 2019-05-13 Any race is a bug 我在接手其他同事的 golang 项目时,一般都会习惯性的做一个竞态检测.有时总会得到一些"惊喜",比如像下面这段代码: package main import ( "fmt" "runtime" "…
小结: 1. conflicting access 2.性能危害 优化 The cost of race detection varies by program, but for a typical program, memory usage may increase by 5-10x and execution time by 2-20x. 3.典型案例与修复 Accidentally shared variable // ParallelWrite writes data to file1…
Contents Tutorial Hello, World Command-Line Arguments Finding Duplicate Lines A Web Server Loose Ends Program Structure Names Declarations Variables Assignments Type Declarations Packages and Files Scope Basic Data Types Integers Floating-Point Numbe…
https://ttboj.wordpress.com/2016/02/15/debugging-golang-programs/ I’ve been writing a lot of golang lately. I’ve hit painful problems in the past. Here are some debugging tips. Hopefully they help you out. I bet you don’t know #2. #0 Use log.Printf:…