Skip to content

Commit

Permalink
Renamed to litter
Browse files Browse the repository at this point in the history
  • Loading branch information
simen committed Mar 30, 2017
1 parent b685d51 commit 6bdb357
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 60 deletions.
32 changes: 16 additions & 16 deletions README.md
@@ -1,6 +1,6 @@
# go-squirt
# go-litter

Go-squirt implements a deep pretty printer for Go data structures to aid in debugging. It is a limited
Go-litter implements a deep pretty printer for Go data structures to aid in debugging. It is a limited
replacement for `go-spew` with focus on terseness in output to make life simpler when debugging complex
data structures. Its main reason for being is that it will detect circular references or aliasing and
replace additional references to the same object with aliases. Like this:
Expand All @@ -14,7 +14,7 @@ type Circular struct {
selfref := Circular{}
selfref.Self = &selfref

squirt.Dump(selfref)
litter.Dump(selfref)
```

will output:
Expand All @@ -29,43 +29,43 @@ Circular { // p0
## Installation

```bash
$ go get -u github.com/sanity-io/go-squirt/squirt
$ go get -u github.com/sanity-io/go-litter/litter
```

## Quick Start

Add this import line to the file you're working in:

```go
import "github.com/sanity-io/go-squirt/squirt"
import "github.com/sanity-io/go-litter/litter"
```

To dump a variable with full newlines, indentation, type, and aliasing
information use Dump or Sdump:

```go
squirt.Dump(myVar1)
str := squirt.Sdump(myVar1)
litter.Dump(myVar1)
str := litter.Sdump(myVar1)
```
## `squirt.Dump(value)`
## `litter.Dump(value)`
Dumps the data structure to STDOUT.

## `squirt.Sdump(value)`
## `litter.Sdump(value)`
Returns the dump as a string

## Configuration
You can configure squirt globally by modifying the default `squirt.Config`
You can configure litter globally by modifying the default `litter.Config`

```go
squirt.Config.StripPackageNames = true // strip all package names from types
squirt.Config.HidePrivateFields = true // hide private struct fields from dumped structs
squirt.Config.HomePackage = "mypackage" // sets a "home" pacage. The package name will be stripped from all its types
litter.Config.StripPackageNames = true // strip all package names from types
litter.Config.HidePrivateFields = true // hide private struct fields from dumped structs
litter.Config.HomePackage = "mypackage" // sets a "home" pacage. The package name will be stripped from all its types
```
## `squirt.Options`
Allows you to configure a local configuration of squirt to allow for proper compartmentalization of state at the expense of some comfort:
## `litter.Options`
Allows you to configure a local configuration of litter to allow for proper compartmentalization of state at the expense of some comfort:

``` go
sq := squirt.Options {
sq := litter.Options {
HidePrivateFields: true,
HomePackage: "thispack",
})
Expand Down
4 changes: 2 additions & 2 deletions squirt/dump.go → dump.go
@@ -1,4 +1,4 @@
package squirt
package litter

import (
"bytes"
Expand All @@ -12,7 +12,7 @@ import (

var packageNameStripperRegexp = regexp.MustCompile("\\b[a-zA-Z_]+[a-zA-Z_0-9]+\\.")

// Options represents configuration options for squirt
// Options represents configuration options for litter
type Options struct {
StripPackageNames bool
HidePrivateFields bool
Expand Down
18 changes: 9 additions & 9 deletions squirt/dump_test.go → dump_test.go
@@ -1,4 +1,4 @@
package squirt_test
package litter_test

import (
"fmt"
Expand All @@ -7,7 +7,7 @@ import (
"os/exec"
"testing"

"github.com/sanity-io/go-squirt/squirt"
"github.com/sanity-io/litter"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand All @@ -27,9 +27,9 @@ type RecursiveStruct struct {
Ptr *RecursiveStruct
}

var standardCfg = squirt.Options{}
var standardCfg = litter.Options{}

func performDumpTestsWithCfg(t *testing.T, suiteName string, cfg *squirt.Options, cases interface{}) {
func performDumpTestsWithCfg(t *testing.T, suiteName string, cfg *litter.Options, cases interface{}) {
referenceFileName := "testdata/" + suiteName + ".dump"
dump := cfg.Sdump(cases)
reference, err := ioutil.ReadFile(referenceFileName)
Expand Down Expand Up @@ -101,17 +101,17 @@ func TestDump_nilIntefacesInStructs(t *testing.T) {

func TestDump_config(t *testing.T) {
data := []interface{}{
squirt.Config,
litter.Config,
&BasicStruct{1, 2},
}
performDumpTestsWithCfg(t, "config_HidePrivateFields", &squirt.Options{
performDumpTestsWithCfg(t, "config_HidePrivateFields", &litter.Options{
HidePrivateFields: true,
}, data)
performDumpTestsWithCfg(t, "config_StripPackageNames", &squirt.Options{
performDumpTestsWithCfg(t, "config_StripPackageNames", &litter.Options{
StripPackageNames: true,
}, data)
performDumpTestsWithCfg(t, "config_HomePackage", &squirt.Options{
HomePackage: "squirt_test",
performDumpTestsWithCfg(t, "config_HomePackage", &litter.Options{
HomePackage: "litter_test",
}, data)
}

Expand Down
2 changes: 1 addition & 1 deletion squirt/mapper.go → mapper.go
@@ -1,4 +1,4 @@
package squirt
package litter

import "reflect"

Expand Down
2 changes: 1 addition & 1 deletion squirt/print.go → print.go
@@ -1,4 +1,4 @@
package squirt
package litter

import (
"io"
Expand Down
10 changes: 0 additions & 10 deletions squirt/testdata/nilIntefacesInStructs.dump

This file was deleted.

12 changes: 0 additions & 12 deletions squirt/testdata/pointerAliasing.dump

This file was deleted.

@@ -1,10 +1,10 @@
[]interface {}{
squirt.Options{
litter.Options{
StripPackageNames: false,
HidePrivateFields: true,
HomePackage: "",
},
squirt_test.BasicStruct{
litter_test.BasicStruct{
Public: 1,
},
}
@@ -1,5 +1,5 @@
[]interface {}{
squirt.Options{
litter.Options{
StripPackageNames: false,
HidePrivateFields: true,
HomePackage: "",
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions squirt/testdata/maps.dump → testdata/maps.dump
Expand Up @@ -6,7 +6,7 @@
1: "one",
2: "two",
},
map[int]*squirt_test.BlankStruct{
2: squirt_test.BlankStruct{},
map[int]*litter_test.BlankStruct{
2: litter_test.BlankStruct{},
},
}
10 changes: 10 additions & 0 deletions testdata/nilIntefacesInStructs.dump
@@ -0,0 +1,10 @@
[]*litter_test.InterfaceStruct{
litter_test.InterfaceStruct{ // p0
Ifc: nil,
},
litter_test.InterfaceStruct{
Ifc: p0,
},
p0,
nil,
}
12 changes: 12 additions & 0 deletions testdata/pointerAliasing.dump
@@ -0,0 +1,12 @@
[]*litter_test.RecursiveStruct{
litter_test.RecursiveStruct{ // p0
Ptr: nil,
},
p0,
litter_test.RecursiveStruct{
Ptr: p0,
},
litter_test.RecursiveStruct{ // p1
Ptr: p1,
},
}
6 changes: 3 additions & 3 deletions squirt/testdata/primitives.dump → testdata/primitives.dump
Expand Up @@ -22,9 +22,9 @@
3,
},
"hello from interface",
squirt_test.BlankStruct{},
squirt_test.BlankStruct{},
squirt_test.BasicStruct{
litter_test.BlankStruct{},
litter_test.BlankStruct{},
litter_test.BasicStruct{
Public: 1,
private: 2,
},
Expand Down
2 changes: 1 addition & 1 deletion squirt/util.go → util.go
@@ -1,4 +1,4 @@
package squirt
package litter

import "reflect"

Expand Down

0 comments on commit 6bdb357

Please sign in to comment.