本文整理匯總了Golang中encoding/csv.Writer.UseCRLF方法的典型用法代碼示例。如果您正苦於以下問題:Golang Writer.UseCRLF方法的具體用法?Golang Writer.UseCRLF怎麽用?Golang Writer.UseCRLF使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類encoding/csv.Writer
的用法示例。
在下文中一共展示了Writer.UseCRLF方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: executeDiff
//.........這裏部分代碼省略.........
}
// Diff Mode.
if oneFi.Mode != otherFi.Mode {
q <- info{
path: args[i],
index: i,
full: oneFi.Full,
diff: FileMode,
value: oneFi.Mode,
ford: oneFi.Type,
}
}
} else {
q <- info{
path: args[i],
index: i,
full: oneFi.Full,
diff: FileFull,
value: oneFi.Full,
ford: oneFi.Type,
}
}
}
}
}(i, one)
}
// Async wait.
go func() {
wg.Wait()
close(q)
}()
// Receive diff and store to array.
for info := range q {
cnt++
if !silent {
fmt.Fprintf(os.Stderr, "Count: %d\r", cnt)
}
key := info.full + fmt.Sprint(info.diff)
if _, ok := csvMap[key]; ok {
csvMap[key][info.index+3] = info.value
} else {
s := make([]string, len(args)+3)
s[0] = info.full
s[1] = info.ford
s[2] = fmt.Sprint(info.diff)
s[info.index+3] = info.value
csvMap[key] = s
}
}
if len(csvMap) == 0 {
fmt.Println("There is no difference !")
return
}
// Output to csv.
os.MkdirAll(filepath.Dir(out), os.ModePerm)
c, err := os.Create(out)
if err != nil {
log.Fatalln(err)
}
defer c.Close()
var writer *csv.Writer
if sjisOut {
writer = csv.NewWriter(transform.NewWriter(c, japanese.ShiftJIS.NewEncoder()))
} else {
writer = csv.NewWriter(c)
}
writer.Comma = '\t'
writer.UseCRLF = true
// Write header.
err = writer.Write(append(strings.Split(DiffHeader, "\t"), args...))
if err != nil {
log.Fatalln(err)
}
// map to array.
var csvArray records
for _, v := range csvMap {
csvArray = append(csvArray, v)
}
// sort
if sorts == "" {
sorts = "0,2"
}
sort.Sort(csvArray)
for _, v := range csvArray {
err = writer.Write(v)
if err != nil {
log.Fatalln(err)
}
}
writer.Flush()
fmt.Printf("Write to [%s]. ([%d] row)\n", out, cnt)
}