Commit Graph

129 Commits

Author SHA1 Message Date
Dave Collins 8aeb47a9ec Update license copyright years.
Several files had been updated since the listed years.  This updates
them accordingly.
2016-10-29 15:38:27 -05:00
Dave Collins bae5ef75ff Update doc.go/README.md with new config options. 2016-10-29 15:03:44 -05:00
Alexander Staubo 04cdfd4297 Adds new config options:
DisablePointerAddresses: Specifies whether to disable the printing of
pointer addresses.

DisableCapacities specifies whether to disable the printing of capacities
for arrays, slices, maps and channels.

These are useful when diffing data structures in tests. Printing pointers
and capacities would otherwise lead to false negatives.
2016-10-28 13:58:48 -04:00
Dave Collins 6d212800a4 Deprecate "disableunsafe" tag in favor of "safe".
This adds a new build tag named "safe" which serves the exact same
purpose as the current "disableunsafe" tag.  This is being done, as
recommended by @shurcooL, since it is emerging as the standard way to do
it in several high profile packages, it mirrors the "unsafe" package
nicely, it is shorter, and users generally seem to prefer it.

However, to avoid breaking existing infrastructure, the disableunsafe
tag is still available and simply is being deprecated.
2016-09-07 12:06:01 -05:00
Jonathan Hall 66f99a29a0 Disable unsafe for GopherJS compiler.
* Disable unsafe for GopherJS compiler.
* Update comments to reflect GopherJS build constraints
2016-09-07 11:16:42 -05:00
anatoly techtonik 3838b6852d Link missing blog post to web archive (fixes #46 and #41) 2016-09-02 21:58:02 +03:00
David Hill 6cf5744a04 Update Travis to test multiple golang versions. 2016-08-16 12:40:47 -05:00
Waldir Pimenta f438166ffd Add license title. 2016-08-16 12:35:55 -05:00
Dave Collins 5215b55f46 Add logic to deal with reflect pkg changes on tip.
This commit adds logic to gracefully the internal reflect.Value flag bit
changes as of golang commit adf9b30e5594 while maintaining support all
the back to Go 1.0.

It accomplishes this by adding code to the init time inspection to
detect the change and set the flag positions accordingly.

While here, also removes a TODO comment since it was already done
previously.
2015-11-05 15:13:17 -06:00
Dave Collins 2df174808e Add support for limited mode without unsafe pkg.
This commit adds support for compiling spew without the unsafe package.
When compiled without the unsafe package, some of the more advanced
features such as invoking stringers on pointers from non-pointer
variables and unexported struct fields are not available.

By default, spew will be compiled in the limited mode for Google App
Engine since the unsafe package is not available there.  Additionally,
spew can be compiled without the unsafe package manually by specifying
the "disableunsafe" build tag.

Finally, a new package-level constant named "UnsafeDisabled" has been
exposed which can be used to programmatically determine if spew was
compiled with access to the unsafe package.
2015-06-19 15:29:34 -05:00
Jason Buberel f9f629a1d0 Provide an example on how to debug a web app.
Update README.md

Removing extra line.
2015-05-25 14:24:11 -07:00
Brian Dorsey a6eef0c3a9 Removed spurious "spew". 2015-05-17 16:54:58 -07:00
Brian Dorsey c15d848066 Add import line to README.md quickstart 2015-05-03 18:18:55 -07:00
Tim Hockin 3e6e67c4dc Enable methods to sort map keys and spew itself as last resort
If enabled by flags, try to use methods to stringify map keys and sort on that.

If we can't use primitive sorting and we can't use methods, we can still fall
back on spew itself.  If SpewKeys is enabled, use Sprintf("%#v") to generate a
string and sort by that.
2015-04-10 08:46:42 -07:00
Dave Collins fc32781af5 Add -u to the README installation instructions.
This will allow the command to update the package if an old one happens to
be present while still fetching it if it's missing.

Suggested by @shurcooL in #28.
2015-02-23 15:20:11 -06:00
Anaminus a4b53deb9b Add support for sorting keys that are arrays. 2015-02-23 15:16:52 -06:00
deads2k 1aaf839fb0 make nil maps appear different than empty maps 2015-01-19 11:34:19 -05:00
Dave Collins 83f84dc933 Improve unsafe reflect value handling.
This commit modifies the unsafeReflectValue function to recognize
reference types even when the indirection flag is not set for the series
of golang commits after ecccf07e7f9d and before 82f48826c6c7 which
introduced the additional scalar field in the reflect.Value struct.  That
additional field has since been removed, but the intention of this code is
to work properly across all Go versions and other packages make use of the
logic.

Thanks to @shurcooL for providing example code which wasn't working
properly with the function when it was exported and therefore being called
in ways which spew itself does not.
2014-11-15 20:01:10 -06:00
Dave Collins 128854244a Add logic to deal with reflect pkg changes on tip.
This commit adds logic to gracefully handle the new internal reflect.Value
structure on tip as of golang commit 82f48826c6c7 as well as the internal
reflect.Value flag bit changes as of golang commit 90a7c3c86944.

It accomplishes this by doing some inspection at init time and choosing
the appropriate offsets and flag positions accordingly.  There was some
previous logic which dealt with a similar issue for golang commit
ecccf07e7f9d.  However, since the more recent commits essentially reverted
the change and also modify the flag bit positions, it made more sense to
rework the detection logic.  In particular, the new logic examines the
size of the reflect.Value struct to determine the difference and extracts
the kind from the flags to determine if the flags have been changed.

As a result, this commit allows spew to work properly with tip all the
back to Go 1.0.
2014-10-24 18:49:38 -05:00
Josh Rickmar 3fdaf5cea8 Dump non-zero len and cap for applicable types.
Closes #16.
2014-05-05 22:39:05 -05:00
Dave Collins 9ed19f9b0c Point test coverage badge at master branch. 2014-03-27 05:31:30 -05:00
Dave Collins 96dfb77570 Configure TravisCI to test with testcgo tag. 2014-03-27 05:26:53 -05:00
Dave Collins 4451e342b3 Add coveralls.io test coverage badge. 2014-03-27 05:20:20 -05:00
Dave Collins 55afdd1e0d Don't change to spew dir before invoking goveralls. 2014-03-27 05:13:54 -05:00
Dave Collins 053ad9b77a Correct TravisCI .yml file. 2014-03-27 05:08:45 -05:00
Dave Collins 2d30de540a Configure TravisCI goveralls call correctly.
By default goveralls tries to use gocov.  This modifies it to use the
cover profile provided by go test instead.
2014-03-27 05:05:19 -05:00
Dave Collins 8ae4f2591e Setup TravisCI to report cov stats to coveralls.io. 2014-03-27 04:58:48 -05:00
Dave Collins 110c37a4d1 Update TravisCI to use Go 1.2.
Also fix a comment typo in doc.go under the custom formatter section.
2014-03-27 04:46:40 -05:00
Dave Collins 65ca732a33 Add logic to deal with reflect pkg changes on tip.
This commit adds logic to gracefully handle the new internal reflect.Value
structure on tip as of golang commit ecccf07e7f9d.  It accomplishes this
by doing some inspection at init time and choosing the appropriate offsets
as well as modifying which offset is used for the value accordingly.  As a
result, this allows spew to work properly with both the current release
version of Go as well as tip.

Fixes #15.
2014-01-08 02:01:15 -06:00
Dave Collins bde46cf02b Merge pull request #14 from pmezard/fix-sorting-test-on-32bits
tests: fix TestSortValues on 32-bits platforms
2013-12-02 00:50:11 -08:00
Patrick Mezard 264fa19def tests: fix TestSortValues on 32-bits platforms
reflect.DeepEqual fails when comparing reflect.Value containing float64. I
think it cannot make sense of reflect.Value pointer tricks and directly
compare reflect.Value.val fields which contain the float value in 64 bits,
but a pointer to the float in 32 bits.

Fortunately, interface{} which have a similar memory layout, compare correctly,
so we just turn the []reflect.Value into []interface{}.
2013-12-01 16:46:38 +01:00
Dave Collins e762b3d132 Make build status badge only apply to master branch. 2013-11-16 22:24:52 -06:00
Dave Collins 7b68a4a09a Add TravisCI build status badge to README.md. 2013-11-16 21:44:48 -06:00
Dave Collins 4d8bf045f7 Require Go 1.1 for TravisCI. 2013-11-16 21:33:05 -06:00
Dave Collins 67dc83c7e5 Add TravisCI support. 2013-11-16 21:28:36 -06:00
Dave Collins 1a05ce86a9 Add SortKeys option to doco for NewDefaultConfig. 2013-11-16 20:45:52 -06:00
Dave Collins b5585b0bfd Add godoc reference badge to README.md. 2013-11-16 16:10:27 -06:00
Dave Collins 550ce83cb9 Update README and doc.go with new SortKeys option. 2013-11-16 16:05:42 -06:00
Dave Collins 92b7ef315a Add additional tests for new sortValues code.
This brings the test coverage back to 100%.
2013-11-14 22:22:17 -06:00
Dave Collins 3b4a2055ce Correct valuesSorter.Less function for uintptr.
The function sort be sorting the uintptr itself, not the address of it.
Also, the previous code could easily panic on an unaddressable
reflect.Value since it was trying to take an address.
2013-11-14 22:03:41 -06:00
Dave Collins 67c401cf12 Reorder Less function cases to consistent order. 2013-11-14 21:53:06 -06:00
Dave Collins e0d93cdf8b Update imports for previous. 2013-11-14 21:46:27 -06:00
Dave Collins fab1d2b55f Move TestSortValues to common_test.go.
This commit moves the TestSortValues function from dump_test.go to
common_test.go to mirror the new implementation location.  It also
slightly formats the tests to be consistent with the rest of the package.
2013-11-14 21:44:13 -06:00
Dave Collins de6d1a24a0 Reorganize the new map key sorting functionality.
This commit moves the new code related to sorting reflect.Value items into
common.go since it is accessed by both the formatter and the dumper.  It
also adds comments to the new functions and unexports SortValues since it
should be an internal function only.
2013-11-14 21:39:21 -06:00
Dave Collins f0ba95e184 Fix a few style issues pointed out by golint. 2013-11-14 21:19:56 -06:00
Dave Collins f13f098c7a Merge pull request #13 from pmezard/add-option-to-sort-map-keys
config: add SortKeys option to sort native map keys before display
2013-11-14 19:11:52 -08:00
Patrick Mezard 8e1b34364f dump: make SortKeys default to string representation instead of nothing
The previous version of SortKeys was sorting only native types. Now, if
the type is unknown it defaults to its reflect.Value.String()
representation which at least guarantees display stability.
2013-10-28 14:35:33 +01:00
Patrick Mezard 1fdf49f1b9 config: add SortKeys option to sort native map keys before display
If ConfigState.SortKeys is true, then dump and format will sort map keys
before displaying them. Only native types (bool, ints, uint, uintptr,
string) are supported, other slices are left unchanged.

The motivation is to have more diffable output, mostly for test purpose.
2013-10-27 23:44:49 +01:00
Dave Collins 1fe9f5ca4b Update test coverage for cgo handling updates.
This commit updates the test coverage report in include the latest
tests for the recent cgo handling updates for char, unsigned char,
and uint8_t arrays.
2013-09-21 21:57:46 -05:00
Dave Collins ee37a939d0 Add a script to generate test coverage report.
This commit adds a script which can be used to generate the test coverage
report.  It detects whether or not gcc is installed and adds the necessary
build tag to enable the new cgo tests when gcc is available.
2013-09-21 21:54:56 -05:00