Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
c8c2c58a
Commit
c8c2c58a
authored
Mar 21, 2016
by
Joe Finney
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bump spew godep to make hash tests pass on go 1.6.
parent
bc791cbd
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
223 additions
and
138 deletions
+223
-138
Godeps.json
Godeps/Godeps.json
+1
-1
bypass.go
.../_workspace/src/github.com/davecgh/go-spew/spew/bypass.go
+151
-0
bypasssafe.go
...rkspace/src/github.com/davecgh/go-spew/spew/bypasssafe.go
+37
-0
common.go
.../_workspace/src/github.com/davecgh/go-spew/spew/common.go
+13
-122
config.go
.../_workspace/src/github.com/davecgh/go-spew/spew/config.go
+4
-1
dump.go
...ps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
+17
-14
No files found.
Godeps/Godeps.json
View file @
c8c2c58a
...
@@ -381,7 +381,7 @@
...
@@ -381,7 +381,7 @@
},
},
{
{
"ImportPath"
:
"github.com/davecgh/go-spew/spew"
,
"ImportPath"
:
"github.com/davecgh/go-spew/spew"
,
"Rev"
:
"
3e6e67c4dcea3ac2f25fd4731abc0e1deaf36216
"
"Rev"
:
"
5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
"
},
},
{
{
"ImportPath"
:
"github.com/daviddengcn/go-colortext"
,
"ImportPath"
:
"github.com/daviddengcn/go-colortext"
,
...
...
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/bypass.go
0 → 100644
View file @
c8c2c58a
// Copyright (c) 2015 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when the code is not running on Google App Engine and "-tags disableunsafe"
// is not added to the go build command line.
// +build !appengine,!disableunsafe
package
spew
import
(
"reflect"
"unsafe"
)
const
(
// UnsafeDisabled is a build-time constant which specifies whether or
// not access to the unsafe package is available.
UnsafeDisabled
=
false
// ptrSize is the size of a pointer on the current arch.
ptrSize
=
unsafe
.
Sizeof
((
*
byte
)(
nil
))
)
var
(
// offsetPtr, offsetScalar, and offsetFlag are the offsets for the
// internal reflect.Value fields. These values are valid before golang
// commit ecccf07e7f9d which changed the format. The are also valid
// after commit 82f48826c6c7 which changed the format again to mirror
// the original format. Code in the init function updates these offsets
// as necessary.
offsetPtr
=
uintptr
(
ptrSize
)
offsetScalar
=
uintptr
(
0
)
offsetFlag
=
uintptr
(
ptrSize
*
2
)
// flagKindWidth and flagKindShift indicate various bits that the
// reflect package uses internally to track kind information.
//
// flagRO indicates whether or not the value field of a reflect.Value is
// read-only.
//
// flagIndir indicates whether the value field of a reflect.Value is
// the actual data or a pointer to the data.
//
// These values are valid before golang commit 90a7c3c86944 which
// changed their positions. Code in the init function updates these
// flags as necessary.
flagKindWidth
=
uintptr
(
5
)
flagKindShift
=
uintptr
(
flagKindWidth
-
1
)
flagRO
=
uintptr
(
1
<<
0
)
flagIndir
=
uintptr
(
1
<<
1
)
)
func
init
()
{
// Older versions of reflect.Value stored small integers directly in the
// ptr field (which is named val in the older versions). Versions
// between commits ecccf07e7f9d and 82f48826c6c7 added a new field named
// scalar for this purpose which unfortunately came before the flag
// field, so the offset of the flag field is different for those
// versions.
//
// This code constructs a new reflect.Value from a known small integer
// and checks if the size of the reflect.Value struct indicates it has
// the scalar field. When it does, the offsets are updated accordingly.
vv
:=
reflect
.
ValueOf
(
0xf00
)
if
unsafe
.
Sizeof
(
vv
)
==
(
ptrSize
*
4
)
{
offsetScalar
=
ptrSize
*
2
offsetFlag
=
ptrSize
*
3
}
// Commit 90a7c3c86944 changed the flag positions such that the low
// order bits are the kind. This code extracts the kind from the flags
// field and ensures it's the correct type. When it's not, the flag
// order has been changed to the newer format, so the flags are updated
// accordingly.
upf
:=
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
vv
))
+
offsetFlag
)
upfv
:=
*
(
*
uintptr
)(
upf
)
flagKindMask
:=
uintptr
((
1
<<
flagKindWidth
-
1
)
<<
flagKindShift
)
if
(
upfv
&
flagKindMask
)
>>
flagKindShift
!=
uintptr
(
reflect
.
Int
)
{
flagKindShift
=
0
flagRO
=
1
<<
5
flagIndir
=
1
<<
6
// Commit adf9b30e5594 modified the flags to separate the
// flagRO flag into two bits which specifies whether or not the
// field is embedded. This causes flagIndir to move over a bit
// and means that flagRO is the combination of either of the
// original flagRO bit and the new bit.
//
// This code detects the change by extracting what used to be
// the indirect bit to ensure it's set. When it's not, the flag
// order has been changed to the newer format, so the flags are
// updated accordingly.
if
upfv
&
flagIndir
==
0
{
flagRO
=
3
<<
5
flagIndir
=
1
<<
7
}
}
}
// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
// the typical safety restrictions preventing access to unaddressable and
// unexported data. It works by digging the raw pointer to the underlying
// value out of the protected value and generating a new unprotected (unsafe)
// reflect.Value to it.
//
// This allows us to check for implementations of the Stringer and error
// interfaces to be used for pretty printing ordinarily unaddressable and
// inaccessible values such as unexported struct fields.
func
unsafeReflectValue
(
v
reflect
.
Value
)
(
rv
reflect
.
Value
)
{
indirects
:=
1
vt
:=
v
.
Type
()
upv
:=
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
v
))
+
offsetPtr
)
rvf
:=
*
(
*
uintptr
)(
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
v
))
+
offsetFlag
))
if
rvf
&
flagIndir
!=
0
{
vt
=
reflect
.
PtrTo
(
v
.
Type
())
indirects
++
}
else
if
offsetScalar
!=
0
{
// The value is in the scalar field when it's not one of the
// reference types.
switch
vt
.
Kind
()
{
case
reflect
.
Uintptr
:
case
reflect
.
Chan
:
case
reflect
.
Func
:
case
reflect
.
Map
:
case
reflect
.
Ptr
:
case
reflect
.
UnsafePointer
:
default
:
upv
=
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
v
))
+
offsetScalar
)
}
}
pv
:=
reflect
.
NewAt
(
vt
,
upv
)
rv
=
pv
for
i
:=
0
;
i
<
indirects
;
i
++
{
rv
=
rv
.
Elem
()
}
return
rv
}
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/bypasssafe.go
0 → 100644
View file @
c8c2c58a
// Copyright (c) 2015 Dave Collins <dave@davec.name>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
// NOTE: Due to the following build constraints, this file will only be compiled
// when either the code is running on Google App Engine or "-tags disableunsafe"
// is added to the go build command line.
// +build appengine disableunsafe
package
spew
import
"reflect"
const
(
// UnsafeDisabled is a build-time constant which specifies whether or
// not access to the unsafe package is available.
UnsafeDisabled
=
true
)
// unsafeReflectValue typically converts the passed reflect.Value into a one
// that bypasses the typical safety restrictions preventing access to
// unaddressable and unexported data. However, doing this relies on access to
// the unsafe package. This is a stub version which simply returns the passed
// reflect.Value when the unsafe package is not available.
func
unsafeReflectValue
(
v
reflect
.
Value
)
reflect
.
Value
{
return
v
}
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/common.go
View file @
c8c2c58a
...
@@ -23,116 +23,8 @@ import (
...
@@ -23,116 +23,8 @@ import (
"reflect"
"reflect"
"sort"
"sort"
"strconv"
"strconv"
"unsafe"
)
)
const
(
// ptrSize is the size of a pointer on the current arch.
ptrSize
=
unsafe
.
Sizeof
((
*
byte
)(
nil
))
)
var
(
// offsetPtr, offsetScalar, and offsetFlag are the offsets for the
// internal reflect.Value fields. These values are valid before golang
// commit ecccf07e7f9d which changed the format. The are also valid
// after commit 82f48826c6c7 which changed the format again to mirror
// the original format. Code in the init function updates these offsets
// as necessary.
offsetPtr
=
uintptr
(
ptrSize
)
offsetScalar
=
uintptr
(
0
)
offsetFlag
=
uintptr
(
ptrSize
*
2
)
// flagKindWidth and flagKindShift indicate various bits that the
// reflect package uses internally to track kind information.
//
// flagRO indicates whether or not the value field of a reflect.Value is
// read-only.
//
// flagIndir indicates whether the value field of a reflect.Value is
// the actual data or a pointer to the data.
//
// These values are valid before golang commit 90a7c3c86944 which
// changed their positions. Code in the init function updates these
// flags as necessary.
flagKindWidth
=
uintptr
(
5
)
flagKindShift
=
uintptr
(
flagKindWidth
-
1
)
flagRO
=
uintptr
(
1
<<
0
)
flagIndir
=
uintptr
(
1
<<
1
)
)
func
init
()
{
// Older versions of reflect.Value stored small integers directly in the
// ptr field (which is named val in the older versions). Versions
// between commits ecccf07e7f9d and 82f48826c6c7 added a new field named
// scalar for this purpose which unfortunately came before the flag
// field, so the offset of the flag field is different for those
// versions.
//
// This code constructs a new reflect.Value from a known small integer
// and checks if the size of the reflect.Value struct indicates it has
// the scalar field. When it does, the offsets are updated accordingly.
vv
:=
reflect
.
ValueOf
(
0xf00
)
if
unsafe
.
Sizeof
(
vv
)
==
(
ptrSize
*
4
)
{
offsetScalar
=
ptrSize
*
2
offsetFlag
=
ptrSize
*
3
}
// Commit 90a7c3c86944 changed the flag positions such that the low
// order bits are the kind. This code extracts the kind from the flags
// field and ensures it's the correct type. When it's not, the flag
// order has been changed to the newer format, so the flags are updated
// accordingly.
upf
:=
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
vv
))
+
offsetFlag
)
upfv
:=
*
(
*
uintptr
)(
upf
)
flagKindMask
:=
uintptr
((
1
<<
flagKindWidth
-
1
)
<<
flagKindShift
)
if
(
upfv
&
flagKindMask
)
>>
flagKindShift
!=
uintptr
(
reflect
.
Int
)
{
flagKindShift
=
0
flagRO
=
1
<<
5
flagIndir
=
1
<<
6
}
}
// unsafeReflectValue converts the passed reflect.Value into a one that bypasses
// the typical safety restrictions preventing access to unaddressable and
// unexported data. It works by digging the raw pointer to the underlying
// value out of the protected value and generating a new unprotected (unsafe)
// reflect.Value to it.
//
// This allows us to check for implementations of the Stringer and error
// interfaces to be used for pretty printing ordinarily unaddressable and
// inaccessible values such as unexported struct fields.
func
unsafeReflectValue
(
v
reflect
.
Value
)
(
rv
reflect
.
Value
)
{
indirects
:=
1
vt
:=
v
.
Type
()
upv
:=
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
v
))
+
offsetPtr
)
rvf
:=
*
(
*
uintptr
)(
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
v
))
+
offsetFlag
))
if
rvf
&
flagIndir
!=
0
{
vt
=
reflect
.
PtrTo
(
v
.
Type
())
indirects
++
}
else
if
offsetScalar
!=
0
{
// The value is in the scalar field when it's not one of the
// reference types.
switch
vt
.
Kind
()
{
case
reflect
.
Uintptr
:
case
reflect
.
Chan
:
case
reflect
.
Func
:
case
reflect
.
Map
:
case
reflect
.
Ptr
:
case
reflect
.
UnsafePointer
:
default
:
upv
=
unsafe
.
Pointer
(
uintptr
(
unsafe
.
Pointer
(
&
v
))
+
offsetScalar
)
}
}
pv
:=
reflect
.
NewAt
(
vt
,
upv
)
rv
=
pv
for
i
:=
0
;
i
<
indirects
;
i
++
{
rv
=
rv
.
Elem
()
}
return
rv
}
// Some constants in the form of bytes to avoid string overhead. This mirrors
// Some constants in the form of bytes to avoid string overhead. This mirrors
// the technique used in the fmt package.
// the technique used in the fmt package.
var
(
var
(
...
@@ -194,9 +86,14 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
...
@@ -194,9 +86,14 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
// We need an interface to check if the type implements the error or
// We need an interface to check if the type implements the error or
// Stringer interface. However, the reflect package won't give us an
// Stringer interface. However, the reflect package won't give us an
// interface on certain things like unexported struct fields in order
// interface on certain things like unexported struct fields in order
// to enforce visibility rules. We use unsafe to bypass these restrictions
// to enforce visibility rules. We use unsafe, when it's available,
// since this package does not mutate the values.
// to bypass these restrictions since this package does not mutate the
// values.
if
!
v
.
CanInterface
()
{
if
!
v
.
CanInterface
()
{
if
UnsafeDisabled
{
return
false
}
v
=
unsafeReflectValue
(
v
)
v
=
unsafeReflectValue
(
v
)
}
}
...
@@ -206,21 +103,15 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
...
@@ -206,21 +103,15 @@ func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool)
// mutate the value, however, types which choose to satisify an error or
// mutate the value, however, types which choose to satisify an error or
// Stringer interface with a pointer receiver should not be mutating their
// Stringer interface with a pointer receiver should not be mutating their
// state inside these interface methods.
// state inside these interface methods.
var
viface
interface
{}
if
!
cs
.
DisablePointerMethods
&&
!
UnsafeDisabled
&&
!
v
.
CanAddr
()
{
if
!
cs
.
DisablePointerMethods
{
v
=
unsafeReflectValue
(
v
)
if
!
v
.
CanAddr
()
{
}
v
=
unsafeReflectValue
(
v
)
if
v
.
CanAddr
()
{
}
v
=
v
.
Addr
()
viface
=
v
.
Addr
()
.
Interface
()
}
else
{
if
v
.
CanAddr
()
{
v
=
v
.
Addr
()
}
viface
=
v
.
Interface
()
}
}
// Is it an error or Stringer?
// Is it an error or Stringer?
switch
iface
:=
v
iface
.
(
type
)
{
switch
iface
:=
v
.
Interface
()
.
(
type
)
{
case
error
:
case
error
:
defer
catchPanic
(
w
,
v
)
defer
catchPanic
(
w
,
v
)
if
cs
.
ContinueOnMethod
{
if
cs
.
ContinueOnMethod
{
...
...
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/config.go
View file @
c8c2c58a
...
@@ -61,7 +61,10 @@ type ConfigState struct {
...
@@ -61,7 +61,10 @@ type ConfigState struct {
// with a pointer receiver could technically mutate the value, however,
// with a pointer receiver could technically mutate the value, however,
// in practice, types which choose to satisify an error or Stringer
// in practice, types which choose to satisify an error or Stringer
// interface with a pointer receiver should not be mutating their state
// interface with a pointer receiver should not be mutating their state
// inside these interface methods.
// inside these interface methods. As a result, this option relies on
// access to the unsafe package, so it will not have any effect when
// running in environments without access to the unsafe package such as
// Google App Engine or with the "disableunsafe" build tag specified.
DisablePointerMethods
bool
DisablePointerMethods
bool
// ContinueOnMethod specifies whether or not recursion should continue once
// ContinueOnMethod specifies whether or not recursion should continue once
...
...
Godeps/_workspace/src/github.com/davecgh/go-spew/spew/dump.go
View file @
c8c2c58a
...
@@ -181,25 +181,28 @@ func (d *dumpState) dumpSlice(v reflect.Value) {
...
@@ -181,25 +181,28 @@ func (d *dumpState) dumpSlice(v reflect.Value) {
// Try to use existing uint8 slices and fall back to converting
// Try to use existing uint8 slices and fall back to converting
// and copying if that fails.
// and copying if that fails.
case
vt
.
Kind
()
==
reflect
.
Uint8
:
case
vt
.
Kind
()
==
reflect
.
Uint8
:
// We need an addressable interface to convert the type back
// We need an addressable interface to convert the type
// into a byte slice. However, the reflect package won't give
// to a byte slice. However, the reflect package won't
// us an interface on certain things like unexported struct
// give us an interface on certain things like
// fields in order to enforce visibility rules. We use unsafe
// unexported struct fields in order to enforce
// to bypass these restrictions since this package does not
// visibility rules. We use unsafe, when available, to
// bypass these restrictions since this package does not
// mutate the values.
// mutate the values.
vs
:=
v
vs
:=
v
if
!
vs
.
CanInterface
()
||
!
vs
.
CanAddr
()
{
if
!
vs
.
CanInterface
()
||
!
vs
.
CanAddr
()
{
vs
=
unsafeReflectValue
(
vs
)
vs
=
unsafeReflectValue
(
vs
)
}
}
vs
=
vs
.
Slice
(
0
,
numEntries
)
if
!
UnsafeDisabled
{
vs
=
vs
.
Slice
(
0
,
numEntries
)
// Use the existing uint8 slice if it can be type
// asserted.
// Use the existing uint8 slice if it can be
iface
:=
vs
.
Interface
()
// type asserted.
if
slice
,
ok
:=
iface
.
([]
uint8
);
ok
{
iface
:=
vs
.
Interface
()
buf
=
slice
if
slice
,
ok
:=
iface
.
([]
uint8
);
ok
{
doHexDump
=
true
buf
=
slice
break
doHexDump
=
true
break
}
}
}
// The underlying data needs to be converted if it can't
// The underlying data needs to be converted if it can't
...
...
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