davecgh / go-spew

Implements a deep pretty printer for Go data structures to aid in debugging
ISC License
5.97k stars 361 forks source link

Add support for limited mode without unsafe pkg. #38

Closed davecgh closed 9 years ago

davecgh commented 9 years ago

This pull request 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.

dmitshur commented 9 years ago

Your .travis.yml file currently has:

- go test -v -tags=testcgo ./spew -covermode=count -coverprofile=profile.cov

I suggest adding a second entry to have Travis run tests for "disableunsafe" path as well:

- go test -v -tags=testcgo ./spew -covermode=count -coverprofile=profile.cov
- go test -v -tags=disableunsafe ./spew
davecgh commented 9 years ago

Good suggestion. I ran them all locally, but it would be good to have Travis run them as well.

davecgh commented 9 years ago

Updated.

pjebs commented 9 years ago

Test and it works. safe to merge

davecgh commented 9 years ago

Thanks for confirming.