Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare gop with litter #4

Closed
ysmood opened this issue Mar 23, 2022 · 0 comments
Closed

Compare gop with litter #4

ysmood opened this issue Mar 23, 2022 · 0 comments
Labels
question Further information is requested

Comments

@ysmood
Copy link
Owner

ysmood commented Mar 23, 2022

litter doesn't support colorized output, I created this issue 3 years ago on it, still unresolved: sanity-io/litter#27

Let's use real data to compare them, below is the data to print:

val := map[string]interface{}{
	"bool":   true,
	"number": 1 + 1i,
	"bytes":  []byte{97, 98, 99},
	"lines":  "multiline string\nline two",
	"slice":  []interface{}{1, 2},
	"time":   time.Now(),
	"struct": struct{ test int32 }{
		test: 13,
	},
}
val["slice"].([]interface{})[1] = val["slice"]

litter will output:

map[string]interface {}{
  "bool": true,
  "bytes": []uint8{
    97,
    98,
    99,
  },
  "lines": "multiline string\nline two",
  "number": complex128(1+1i),
  "slice": []interface {}{ // p0
    1,
    p0,
  },
  "struct": struct { test int32 }{},
  "time": time.Time{},
}

gop will output:

map[string]interface {}/* len=7 */{
    "bool": true,
    "bytes": []byte("abc")/* len=3 */,
    "lines": "" +
        "multiline string\n" +
        "line two"/* len=25 */,
    "number": 1+1i,
    "slice": []interface {}/* len=2 cap=2 */{
        1,
        gop.Circular("slice").([]interface {}),
    },
    "struct": struct { test int32 }{
        test: int32(13),
    },
    "time": gop.Time("2022-03-23T10:25:54.424021+08:00"),
}
  • litter doesn't support colorized output
  • litter doesn't print readable []byte
  • litter is not able to print time data
  • litter's output for circular data is not compilable, because p0 is undefined, and they have to guess the meaning of p0, but with gop user can jump to the definition of gop.Cyclic to read the doc.
  • litter is not able to print the nested value of struct{ test int32 }
  • litter doesn't use the shortest form to print the complex number
  • litter doesn't split the multiline text block
  • litter doesn't print the length of long string, map, and slice, etc
@ysmood ysmood added the question Further information is requested label Mar 23, 2022
@ysmood ysmood closed this as completed Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant