<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          ffmtgolang 更友好的格式化輸出

          聯(lián)合創(chuàng)作 · 2023-10-02 02:53

           

          安裝

          go get -u -v gopkg.in/ffmt.v1

          用法

          API 文檔

          示例

          package main
          
          import (
          	ffmt "gopkg.in/ffmt.v1"
          )
          
          func main() {
          	example()
          }
          
          func example() {
          	m := struct {
          		String string
          		Int    int
          		Slice  []int
          		Map    map[string]interface{}
          	}{
          		"hello world",
          		100,
          		[]int{1, 2, 3, 4, 5, 6},
          		map[string]interface{}{
          			"A":  123,
          			"BB": 456,
          		},
          	}
          
          	fmt.Println(m) // fmt 默認(rèn)輸出
          	/*
          		{hello world 100 [1 2 3 4 5 6] map[BB:456 A:123]}
          	*/
          
          	ffmt.Puts(m) // 較為友好的輸出
          	/*
          		{
          		 String: "hello world"
          		 Int:    100
          		 Slice:  [
          		  1 2 3
          		  4 5 6
          		 ]
          		 Map: {
          		  "A":  123
          		  "BB": 456
          		 }
          		}
          	*/
          
          	ffmt.Print(m) // 同 Puts 但是字符串不加引號(hào)
          	/*
          		{
          		 String: hello world
          		 Int:    100
          		 Slice:  [
          		  1 2 3
          		  4 5 6
          		 ]
          		 Map: {
          		  A:  123
          		  BB: 456
          		 }
          		}
          	*/
          
          	ffmt.P(m) // 友好格式化加上類(lèi)型
          	/*
          		struct{
          		 String: string(hello world)
          		 Int:    int(100)
          		 Slice:  slice[
          		  int(1) int(2) int(3)
          		  int(4) int(5) int(6)
          		 ]
          		 Map: map{
          		  string(A):  int(123)
          		  string(BB): int(456)
          		 }
          		}
          	*/
          
          	ffmt.Pjson(m) // 以 json 風(fēng)格輸出
          	/*
          		{
          		 "Int": 100
          		,"Map": {
          		  "A":  123
          		 ,"BB": 456
          		 }
          		,"Slice": [
          		  1,2,3
          		 ,4,5,6
          		 ]
          		,"String": "hello world"
          		}
          	*/
          
          	m0 := ffmt.ToTable(m, m) // 按字段拆成表
          	ffmt.Puts(m0)
          	/*
          		[
          		 [
          		  "String" "Int"
          		  "Slice"  "Map"
          		 ]
          		 [
          		  "hello world"   "100"
          		  "[1 2 3 4 5 6]" "map[A:123 BB:456]"
          		 ]
          		]
          	*/
          
          	m1 := ffmt.FmtTable(m0) // [][]string 表格式化
          	ffmt.Puts(m1)
          	/*
          		[
          		 "String      Int Slice         Map               "
          		 "hello world 100 [1 2 3 4 5 6] map[A:123 BB:456] "
          		]
          	*/
          
          	ffmt.Mark("hello") // 標(biāo)記輸出位置
          	/*
          		main.go:122  hello
          	*/
          }

           

          瀏覽 21
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  青娱乐亚洲无码 | 大香蕉东京热 | 亚洲 在线视频 | 豆花视频成人版视频在线观看 | 新天堂网|