Skip to content

JekaMas/pretty

 
 

Repository files navigation

package pretty

    import "github.com/kr/pretty"

    Package pretty provides pretty-printing for Go values.

Documentation

    http://godoc.org/github.com/kr/pretty

Example:
```
package main

import (
 "bytes"
 "fmt"

 "github.com/JekaMas/pretty"
)

func logDiff(obtained, expected interface{}) {
 var failMessage bytes.Buffer
 diffs := pretty.Diff(obtained, expected)

 if len(diffs) > 0 {
  failMessage.WriteString("Obtained:\t\tExpected:")
  for _, singleDiff := range diffs {
   failMessage.WriteString(fmt.Sprintf("\n%v", singleDiff))
  }
 }

 fmt.Printf("... %s", failMessage.String())
}

func main() {
 v1 := []int{0, 1, 2, 3}
 v2 := []int{0, 1, 4}
 logDiff(v1, v2)
}
```

About

Pretty printing for Go values

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%