Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
godebug
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
godebug
Commits
fffda665
Commit
fffda665
authored
Apr 04, 2016
by
Kyle Lemons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reverse the TextMarshaler default
parent
6105c208
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
15 deletions
+9
-15
pretty/public.go
pretty/public.go
+4
-4
pretty/reflect.go
pretty/reflect.go
+1
-1
pretty/reflect_test.go
pretty/reflect_test.go
+4
-10
No files found.
pretty/public.go
View file @
fffda665
...
...
@@ -33,10 +33,10 @@ type Config struct {
Diffable
bool
// Adds extra newlines for more easily diffable output.
// Field and value options
IncludeUnexported
bool
// Include unexported fields in output
PrintStringers
bool
// Call String on a fmt.Stringer
NoTextMarshalers
bool
// Don't automatically call MarshalText
SkipZeroFields
bool
// Skip struct fields that have a zero value.
IncludeUnexported
bool
// Include unexported fields in output
PrintStringers
bool
// Call String on a fmt.Stringer
PrintTextMarshalers
bool
// Call MarshalText on an encoding.TextMarshaler
SkipZeroFields
bool
// Skip struct fields that have a zero value.
// Output transforms
ShortList
int
// Maximum character length for short lists if nonzero.
...
...
pretty/reflect.go
View file @
fffda665
...
...
@@ -41,7 +41,7 @@ func (c *Config) val2node(val reflect.Value) node {
if
s
,
ok
:=
v
.
(
fmt
.
Stringer
);
ok
&&
c
.
PrintStringers
{
return
stringVal
(
s
.
String
())
}
if
t
,
ok
:=
v
.
(
encoding
.
TextMarshaler
);
ok
&&
!
c
.
No
TextMarshalers
{
if
t
,
ok
:=
v
.
(
encoding
.
TextMarshaler
);
ok
&&
c
.
Print
TextMarshalers
{
if
raw
,
err
:=
t
.
MarshalText
();
err
==
nil
{
// if NOT an error
return
stringVal
(
string
(
raw
))
}
...
...
pretty/reflect_test.go
View file @
fffda665
...
...
@@ -15,7 +15,6 @@
package
pretty
import
(
"net"
"reflect"
"testing"
"time"
...
...
@@ -94,11 +93,6 @@ func TestVal2nodeDefault(t *testing.T) {
raw
:
3
,
want
:
rawVal
(
"3"
),
},
{
desc
:
"TextMarshaler"
,
raw
:
net
.
ParseIP
(
"dead:beef::1"
),
want
:
stringVal
(
"dead:beef::1"
),
},
}
for
_
,
test
:=
range
tests
{
...
...
@@ -141,17 +135,17 @@ func TestVal2node(t *testing.T) {
raw
:
struct
{
Date
time
.
Time
}{
time
.
Unix
(
1234567890
,
0
)
.
UTC
()},
cfg
:
DefaultConfig
,
want
:
keyvals
{
{
"Date"
,
stringVal
(
"2009-02-13T23:31:30Z"
)
},
{
"Date"
,
keyvals
{}
},
},
},
{
desc
:
"time w/
o
TextMarshalers"
,
desc
:
"time w/
Print
TextMarshalers"
,
raw
:
struct
{
Date
time
.
Time
}{
time
.
Unix
(
1234567890
,
0
)
.
UTC
()},
cfg
:
&
Config
{
No
TextMarshalers
:
true
,
Print
TextMarshalers
:
true
,
},
want
:
keyvals
{
{
"Date"
,
keyvals
{}
},
{
"Date"
,
stringVal
(
"2009-02-13T23:31:30Z"
)
},
},
},
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment