操作环境为:Golang 1.5版本,其他版本未验证

1. 修改了C:\Go\src\下的源码,只要执行命令 go install -a -v std cmd 即可生效

E:\gopro\src\tvdatatools>go install -a -v std cmd
runtime
errors
unicode/utf8
unicode
sync/atomic
math
unicode/utf16
sort
container/heap
sync
container/list
container/ring
crypto/subtle
io
此次省略一堆

也可以指定包(比如仅仅修改了一个包的源码)go install -a -v encoding/csv 则可以这样:

E:\gopro\src\tvdatatools>go install -a -v encoding/csv
runtime
sync/atomic
errors
unicode
unicode/utf8
math
unicode/utf16
sync
io
syscall
bytes
strings
bufio
internal/syscall/windows
internal/syscall/windows/registry
time
os
strconv
reflect
fmt
encoding/csv

2. 举例说明 CSV如何跳过CSV文件中的脏数据(不合法的数据)

源码地址:C:\Go\src\encoding\csv\reader.go

// ReadAll reads all the remaining records from r.
// Each record is a slice of fields.
// A successful call returns err == nil, not err == EOF. Because ReadAll is
// defined to read until EOF, it does not treat end of file as an error to be
// reported.
func (r *Reader) ReadAll() (records [][]string, err error) {
	//原始版本
	//	for {
	//		record, err := r.Read()
	//		if err == io.EOF {
	//			return records, nil
	//		}
	//		if err != nil {
	//			return nil, err
	//		}
	//		records = append(records, record)
	//	}

	//自动跳过异常数据 更新版本
	for {
		record, err := r.Read()
		if err == io.EOF {
			return records, nil
		}
		if err == nil {
			records = append(records, record)
		}
	}
}

go install -a -v encoding/csv 编译之后即可生效