我正在嘗試使用 tabwriter 列印幫助訊息:
func printHelp() {
writer := tabwriter.NewWriter(os.Stdout, 100, 8, 1, ' ', 0)
fmt.Println(writer, "uni outputs Unicode information for characters.")
fmt.Println(writer, "USAGE:")
fmt.Println(writer, " uni <input>\tOutputs Unicode info for the input.\t")
fmt.Println(writer, "\tProcesses U xxxx sequences into the appropriate characters and treats control characters as control.\t")
fmt.Println(writer, " uni raw <input>\tOutputs Unicode info on the raw unporocessed input.\t")
fmt.Println(writer, " uni decomp <input\tOutputs the input with all characters decomposed.\t")
fmt.Println(writer, " uni comp <input>\tOutputs the input with all characters composed.\t")
fmt.Println(writer, " uni short <input>\tOutputs basic info about the input, one character per line.\t")
fmt.Println(writer, " uni rawshort <input>\tOutputs basic info about the raw unprocessed input, one character per line.\t")
fmt.Println(writer, " uni help\tPrints this help message.\t")
writer.Flush()
}
但是,輸出都包含大量不應列印的內部垃圾,并且未正確對齊列。
這是我得到的:
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni outputs Unicode information for characters.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} USAGE:
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni <input> Outputs Unicode info for the input.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} Processes U xxxx sequences into the appropriate characters and treats control characters as control.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni raw <input> Outputs Unicode info on the raw unporocessed input.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni decomp <input Outputs the input with all characters decomposed.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni comp <input> Outputs the input with all characters composed.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni short <input> Outputs basic info about the input, one character per line.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni rawshort <input> Outputs basic info about the raw unprocessed input, one character per line.
&{0xc000006018 100 8 1 [32 32 32 32 32 32 32 32] 0 [] 0 {0 0 false} 0 [[]] []} uni help Prints this help message.
這大概就是我想要的
uni outputs Unicode information for characters.
USAGE:
uni <input> Outputs Unicode info for the input.
Processes U xxxx sequences into the appropriate characters and treats control characters as control.
uni raw <input> Outputs Unicdoe info on the raw unporocessed input.
uni decomp <input Outputs the input with all characters decomposed.
uni comp <input> Outputs the input with all characters composed.
uni short <input> Outputs basic info about the input, one character per line.
uni rawshort <input> Outputs basic info about the raw unprocessed input, one character per line.
uni help Prints this help message.
我已經嘗試將最小單元格寬度更改為各種值,從 0 到數百個,它改變了對齊方式,但沒有達到正常作業的程度。我嘗試過制表符與空格分隔符和右對齊與默認(左)對齊,沒有區別。
uj5u.com熱心網友回復:
要寫入io.Writer使用fmt.Fprintln(或fmt.Fprintf)而不是fmt.Println:
// fmt.Println(writer, "uni outputs Unicode information for characters.")
fmt.Fprintln(writer, "uni outputs Unicode information for characters.")
fmt.Println將盡最大努力呈現每個引數 - 因此您會看到制表符的內部反射狀態。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/429836.html
標籤:走
下一篇:在goland反序列化php
