go内置的fmt.sprintf已经很强大了,但是和spew比起来还是相形见绌,这里来一个例子.

import (
	"fmt"

	"github.com/davecgh/go-spew/spew"
)

func main() {
	scs := spew.ConfigState{Indent: "\t"}

	// Output using the ConfigState instance.
	v := map[string]int{"one": 1}
	fmt.Printf("v: %v\n", v)
	scs.Dump(v)
}

对比一下,看看输出有多美:

v: map[one:1]
(map[string]int) (len=1) {
	(string) (len=3) "one": (int) 1
}

相关文章:

  • 2022-01-08
  • 2021-05-14
  • 2022-01-29
  • 2021-06-05
  • 2021-09-02
  • 2021-12-30
  • 2021-11-27
  • 2021-12-24
猜你喜欢
  • 2022-12-23
  • 2021-12-15
  • 2021-12-02
  • 2021-07-30
  • 2021-12-31
  • 2022-12-23
相关资源
相似解决方案