fmtx

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 7 Imported by: 0

README

fmtx

Better Formatting and Printing in Golang

go get github.com/mengdu/fmtx
func main() {
  // fmtx.EnableColor = false
  // fmtx.Options.MaxDepth = 5

  fmtx.Println(123, 3.14, ptr(124), MyInt(123), ptr(MyInt(123)))
  fmtx.Println([]int{1, 2, 3, -1, -2})
  fmtx.Println([]string{"a", "b", "c", "Hello \n \"world\"."})
}

Benchmark

go test -bench=^Benchmark -benchtime=5s
goos: darwin
goarch: amd64
pkg: github.com/mengdu/fmtx
cpu: Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz
BenchmarkString-16                         23042            265536 ns/op
BenchmarkStringDisableColor-16             42644            139462 ns/op
BenchmarkSprintf-16                       965110              6172 ns/op
PASS
ok      github.com/mengdu/fmtx  22.468s

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnableColor = true
View Source
var ForceColor = false
View Source
var Options options = options{
	MaxDepth: 3,
	MaxArray: 50,
	ColorMap: colorMap{
		Int:      [2]string{"34", "39;49"},
		Float:    [2]string{"36", "39;49"},
		String:   [2]string{"32", "39;49"},
		Bool:     [2]string{"33", "39;49"},
		Ptr:      [2]string{"33", "39;49"},
		Property: [2]string{"90", "39;49"},
		Func:     [2]string{"3;94", "39;49;23"},
	},
}

Functions

func Println

func Println(a ...any) (n int, err error)

func String

func String(o any) string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL