亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
archive archive/tar archive/zip bufio bufio(緩存) builtin builtin(內(nèi)置包) bytes bytes(包字節(jié)) compress compress/bzip2(壓縮/bzip2) compress/flate(壓縮/flate) compress/gzip(壓縮/gzip) compress/lzw(壓縮/lzw) compress/zlib(壓縮/zlib) container container/heap(容器數(shù)據(jù)結(jié)構(gòu)heap) container/list(容器數(shù)據(jù)結(jié)構(gòu)list) container/ring(容器數(shù)據(jù)結(jié)構(gòu)ring) context context(上下文) crypto crypto(加密) crypto/aes(加密/aes) crypto/cipher(加密/cipher) crypto/des(加密/des) crypto/dsa(加密/dsa) crypto/ecdsa(加密/ecdsa) crypto/elliptic(加密/elliptic) crypto/hmac(加密/hmac) crypto/md5(加密/md5) crypto/rand(加密/rand) crypto/rc4(加密/rc4) crypto/rsa(加密/rsa) crypto/sha1(加密/sha1) crypto/sha256(加密/sha256) crypto/sha512(加密/sha512) crypto/subtle(加密/subtle) crypto/tls(加密/tls) crypto/x509(加密/x509) crypto/x509/pkix(加密/x509/pkix) database database/sql(數(shù)據(jù)庫/sql) database/sql/driver(數(shù)據(jù)庫/sql/driver) debug debug/dwarf(調(diào)試/dwarf) debug/elf(調(diào)試/elf) debug/gosym(調(diào)試/gosym) debug/macho(調(diào)試/macho) debug/pe(調(diào)試/pe) debug/plan9obj(調(diào)試/plan9obj) encoding encoding(編碼) encoding/ascii85(編碼/ascii85) encoding/asn1(編碼/asn1) encoding/base32(編碼/base32) encoding/base64(編碼/base64) encoding/binary(編碼/binary) encoding/csv(編碼/csv) encoding/gob(編碼/gob) encoding/hex(編碼/hex) encoding/json(編碼/json) encoding/pem(編碼/pem) encoding/xml(編碼/xml) errors errors(錯(cuò)誤) expvar expvar flag flag(命令行參數(shù)解析flag包) fmt fmt go go/ast(抽象語法樹) go/build go/constant(常量) go/doc(文檔) go/format(格式) go/importer go/parser go/printer go/scanner(掃描儀) go/token(令牌) go/types(類型) hash hash(散列) hash/adler32 hash/crc32 hash/crc64 hash/fnv html html html/template(模板) image image(圖像) image/color(顏色) image/color/palette(調(diào)色板) image/draw(繪圖) image/gif image/jpeg image/png index index/suffixarray io io io/ioutil log log log/syslog(日志系統(tǒng)) math math math/big math/big math/bits math/bits math/cmplx math/cmplx math/rand math/rand mime mime mime/multipart(多部分) mime/quotedprintable net net net/http net/http net/http/cgi net/http/cookiejar net/http/fcgi net/http/httptest net/http/httptrace net/http/httputil net/http/internal net/http/pprof net/mail net/mail net/rpc net/rpc net/rpc/jsonrpc net/smtp net/smtp net/textproto net/textproto net/url net/url os os os/exec os/signal os/user path path path/filepath(文件路徑) plugin plugin(插件) reflect reflect(反射) regexp regexp(正則表達(dá)式) regexp/syntax runtime runtime(運(yùn)行時(shí)) runtime/debug(調(diào)試) runtime/internal/sys runtime/pprof runtime/race(競爭) runtime/trace(執(zhí)行追蹤器) sort sort(排序算法) strconv strconv(轉(zhuǎn)換) strings strings(字符串) sync sync(同步) sync/atomic(原子操作) syscall syscall(系統(tǒng)調(diào)用) testing testing(測(cè)試) testing/iotest testing/quick text text/scanner(掃描文本) text/tabwriter text/template(定義模板) text/template/parse time time(時(shí)間戳) unicode unicode unicode/utf16 unicode/utf8 unsafe unsafe
characters

  • import "text/tabwriter"

  • 概觀

  • 索引

  • 示例

概觀

Package tabwriter實(shí)現(xiàn)了一個(gè)寫入過濾器(tabwriter.Writer),它將輸入中的選項(xiàng)卡式列轉(zhuǎn)換為正確對(duì)齊的文本。

文本/制表程序包被凍結(jié),并且不接受新功能。

示例(彈性)

package mainimport ("fmt""os""text/tabwriter")func main() {// Observe how the b's and the d's, despite appearing in the// second cell of each line, belong to different columns.
	w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, '.', tabwriter.AlignRight|tabwriter.Debug)
	fmt.Fprintln(w, "a\tb\tc")
	fmt.Fprintln(w, "aa\tbb\tcc")
	fmt.Fprintln(w, "aaa\t") // trailing tab
	fmt.Fprintln(w, "aaaa\tdddd\teeee")
	w.Flush()}

示例(TrailingTab)

package mainimport ("fmt""os""text/tabwriter")func main() {// Observe that the third line has no trailing tab,// so its final cell is not part of an aligned column.const padding = 3
	w := tabwriter.NewWriter(os.Stdout, 0, 0, padding, '-', tabwriter.AlignRight|tabwriter.Debug)
	fmt.Fprintln(w, "a\tb\taligned\t")
	fmt.Fprintln(w, "aa\tbb\taligned\t")
	fmt.Fprintln(w, "aaa\tbbb\tunaligned") // no trailing tab
	fmt.Fprintln(w, "aaaa\tbbbb\taligned\t")
	w.Flush()}

索引

  • 常量

  • 鍵入Writer

  • func NewWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *Writer

  • func (b *Writer) Flush() error

  • func (b *Writer) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *Writer

  • func (b *Writer) Write(buf []byte) (n int, err error)

示例

Writer.Init Package (Elastic) Package (TrailingTab)

打包文件

tabwriter.go

常量

格式化可以用這些標(biāo)志進(jìn)行控制。

const (        // Ignore html tags and treat entities (starting with '&'        // and ending in ';') as single characters (width = 1).
        FilterHTML uint = 1 << iota        // Strip Escape characters bracketing escaped text segments        // instead of passing them through unchanged with the text.
        StripEscape        // Force right-alignment of cell content.        // Default is left-alignment.
        AlignRight        // Handle empty columns as if they were not present in        // the input in the first place.
        DiscardEmptyColumns        // Always use tabs for indentation columns (i.e., padding of        // leading empty cells on the left) independent of padchar.
        TabIndent        // Print a vertical bar ('|') between columns (after formatting).        // Discarded columns appear as zero-width columns ("||").
        Debug)

要轉(zhuǎn)義文本段,請(qǐng)使用轉(zhuǎn)義字符進(jìn)行包圍。例如,此字符串中的選項(xiàng)卡“忽略此選項(xiàng)卡:  \xff\t\xff ”不會(huì)終止單元格,并且為了格式化目的而構(gòu)成寬度為1的單個(gè)字符。

值 0xff 被選中是因?yàn)樗荒芤杂行У?UTF-8 序列出現(xiàn)。

const Escape = '\xff'

鍵入Writer

Writer是一個(gè)過濾器,用于在其輸入中的制表符分隔列中插入填充以將其與輸出對(duì)齊。

Writer將傳入的字節(jié)視為由水平 ('\t') 或垂直 ('\v') 制表符以及換行符 ('\n') 或換頁符 ('\f') 組成的單元組成的 UTF-8 編碼文本。字符; 換行符和換頁符都是換行符。

連續(xù)行中制表符終止的單元格構(gòu)成列。 Writer 根據(jù)需要插入填充以使列中的所有單元格具有相同的寬度,從而有效地對(duì)齊列。它假定所有字符都具有相同的寬度,但必須指定 tabwidth 的制表符除外。列單元格必須是制表符終止的,而不是制表符分隔的:行結(jié)尾處的非制表符終止的結(jié)尾文本形成單元格,但該單元格不是對(duì)齊列的一部分。例如,在本例中(其中|代表水平制表符):

aaaa|bbb|d
aa  |b  |dd
a   |aa  |cccc|eee

b 和 c 在不同的列中(b 列在所有方面都不是連續(xù)的)。d 和 e 根本不在列中(沒有終止標(biāo)簽,列也不是連續(xù)的)。

Writer 假定所有的 Unicode 代碼點(diǎn)具有相同的寬度;在某些字體中或者字符串包含組合字符時(shí),這可能不是真的。

如果設(shè)置了 DiscardEmptyColumns ,則會(huì)放棄完全由垂直(或“軟”)選項(xiàng)卡終止的空列。水平(或“硬”)選項(xiàng)卡終止的列不受此標(biāo)志的影響。

如果 Writer 配置為過濾 HTML ,則會(huì)傳遞 HTML 標(biāo)記和實(shí)體。為了格式化目的,標(biāo)簽和實(shí)體的寬度被假定為零(標(biāo)簽)和一個(gè)(實(shí)體)。

一段文字可以通過用 Escape 字符括起來進(jìn)行轉(zhuǎn)義。制表人通過不變的方式傳遞轉(zhuǎn)義文本段。特別是,它不解釋段中的任何制表符或換行符。如果設(shè)置了 StripEscape 標(biāo)志,則 Escape 字符將從輸出中剝離; 否則它們也會(huì)通過。為了格式化,轉(zhuǎn)義字符的寬度始終計(jì)算,不包括轉(zhuǎn)義字符。

換頁字符就像換行符,但它也會(huì)終止當(dāng)前行中的所有列(有效地調(diào)用 Flush )。下一行中以制表符結(jié)尾的單元格開始新列。除非在 HTML 標(biāo)簽內(nèi)或轉(zhuǎn)義文本段內(nèi)發(fā)現(xiàn),否則換頁字符在輸出中顯示為換行符。

寫入器必須在內(nèi)部緩沖輸入,因?yàn)橐粭l線的適當(dāng)間距可能取決于未來線中的單元。完成調(diào)用寫入后,客戶端必須調(diào)用 Flush  。

type Writer struct {        // contains filtered or unexported fields}

func NewWriter

func NewWriter(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *Writer

NewWriter 分配并初始化一個(gè)新的 Tabwriter.Writer 。參數(shù)與 Init 函數(shù)相同。

func (*Writer) Flush

func (b *Writer) Flush() error

在上次調(diào)用 Write 之后應(yīng)該調(diào)用 Flush ,以確保寫入器中緩沖的任何數(shù)據(jù)都寫入輸出。出于格式化目的,任何不完整的轉(zhuǎn)義序列都視為完成。

func (*Writer) Init

func (b *Writer) Init(output io.Writer, minwidth, tabwidth, padding int, padchar byte, flags uint) *Writer

寫入器必須通過對(duì) Init 的調(diào)用進(jìn)行初始化。第一個(gè)參數(shù)(輸出)指定了過濾器輸出。其余參數(shù)控制格式:

minwidth	minimal cell width including any padding
tabwidth	width of tab characters (equivalent number of spaces)padding		padding added to a cell before computing its width
padchar		ASCII char used for paddingif padchar == '\t', the Writer will assume that the
		width of a '\t' in the formatted output is tabwidth,
		and cells are left-aligned independent of align_left(for correct-looking results, tabwidth must correspond
		to the tab width in the viewer displaying the result)flags		formatting control

示例

package mainimport ("fmt""os""text/tabwriter")func main() {
	w := new(tabwriter.Writer)// Format in tab-separated columns with a tab stop of 8.
	w.Init(os.Stdout, 0, 8, 0, '\t', 0)
	fmt.Fprintln(w, "a\tb\tc\td\t.")
	fmt.Fprintln(w, "123\t12345\t1234567\t123456789\t.")
	fmt.Fprintln(w)
	w.Flush()// Format right-aligned in space-separated columns of minimal width 5// and at least one blank of padding (so wider column entries do not// touch each other).
	w.Init(os.Stdout, 5, 0, 1, ' ', tabwriter.AlignRight)
	fmt.Fprintln(w, "a\tb\tc\td\t.")
	fmt.Fprintln(w, "123\t12345\t1234567\t123456789\t.")
	fmt.Fprintln(w)
	w.Flush()}

func (*Writer) Write

func (b *Writer) Write(buf []byte) (n int, err error)

寫入器寫 buf 給寫入器 b 。返回的唯一錯(cuò)誤是在寫入底層輸出流時(shí)遇到的錯(cuò)誤。

Previous article: Next article: