安装goget-u-vgopkg.i/ffmt.v1用法
API文档
示例
packagemaiimport(ffmt"gopkg.i/ffmt.v1")fucmai(){example()}fucexample(){m:=struct{StrigstrigItitSlice[]itMapmap[strig]iterface{}}{"helloworld",100,[]it{1,2,3,4,5,6},map[strig]iterface{}{"A":123,"BB":456,},}fmt.Pritl(m)//fmt默认输出/*{helloworld100[123456]map[BB:456A:123]}*/ffmt.Puts(m)//较为友好的输出/*{Strig:"helloworld"It:100Slice:[123456]Map:{"A":123"BB":456}}*/ffmt.Prit(m)//同Puts但是字符串不加引号/*{Strig:helloworldIt:100Slice:[123456]Map:{A:123BB:456}}*/ffmt.P(m)//友好格式化加上类型/*struct{Strig:strig(helloworld)It:it(100)Slice:slice[it(1)it(2)it(3)it(4)it(5)it(6)]Map:map{strig(A):it(123)strig(BB):it(456)}}*/ffmt.Pjso(m)//以jso风格输出/*{"It":100,"Map":{"A":123,"BB":456},"Slice":[1,2,3,4,5,6],"Strig":"helloworld"}*/m0:=ffmt.ToTable(m,m)//按字段拆成表ffmt.Puts(m0)/*[["Strig""It""Slice""Map"]["helloworld""100""[123456]""map[A:123BB:456]"]]*/m1:=ffmt.FmtTable(m0)//[][]strig表格式化ffmt.Puts(m1)/*["StrigItSliceMap""helloworld100[123456]map[A:123BB:456]"]*/ffmt.Mark("hello")//标记输出位置/*mai.go:122hello*/}
评论