8000 Arrays don't round-trip · Issue #36 · kr/pretty · GitHub
[go: up one dir, main page]

Skip to content

Arrays don't round-trip #36

Open

Description

@snadrus

package main

import (
"fmt"
"github.com/kr/pretty"
)

type Foo struct {
S []string
}

func main() {
actual := Foo{
S: []string{"a", "b", "c"},
}

fmt.Println(pretty.Sprint(actual))
/* Prints:
main.Foo{
    S:  {"a", "b", "c"},
}
*/

// Would error:
/*
  result := Foo{
      S:  {"a", "b", "c"},
  }
*/

}

Activity

  1. kr commented on Jun 22, 2016

    @kr
    Owner

    The output of this package is for humans, not compilers.

    I admit, this purpose isn't clearly stated anywhere. I consider this a documentation bug.

  2. snadrus commented on Jun 23, 2016

    @snadrus
    Author

    I've been using this package to print complex objects, visually verify
    them, and copy-paste them into a unit test as an expected result.

    Would you accept a PR for this, or should I fork the repo for my needs?
    On Jun 22, 2016 3:21 PM, "Keith Rarick" notifications@github.com wrote:

    The output of this package is for humans, not compilers.

    I admit, this purpose isn't clearly stated anywhere. I consider this a
    documentation bug.

    —
    You are receiving this because you authored the thread.
    Reply to this email directly, view it on GitHub
    #36 (comment), or mute
    the thread
    https://github.com/notifications/unsubscribe/AB1OLsPK7E1kRoPi4NftgQbAo-Y_pnWYks5qObVTgaJpZM4I8QXL
    .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0