{"id":13393772,"url":"https://github.com/davecgh/go-spew","last_synced_at":"2025-05-13T17:04:13.982Z","repository":{"id":6281310,"uuid":"7515336","full_name":"davecgh/go-spew","owner":"davecgh","description":"Implements a deep pretty printer for Go data structures to aid in debugging","archived":false,"fork":false,"pushed_at":"2024-04-06T10:36:47.000Z","size":215,"stargazers_count":6224,"open_issues_count":66,"forks_count":376,"subscribers_count":69,"default_branch":"master","last_synced_at":"2025-05-06T16:13:49.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davecgh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-01-09T05:18:22.000Z","updated_at":"2025-05-06T08:27:33.000Z","dependencies_parsed_at":"2024-06-18T10:58:37.372Z","dependency_job_id":null,"html_url":"https://github.com/davecgh/go-spew","commit_stats":{"total_commits":143,"total_committers":20,"mean_commits":7.15,"dds":0.2027972027972028,"last_synced_commit":"d8f796af33cc11cb798c1aaeb27a4ebc5099927d"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davecgh%2Fgo-spew","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davecgh%2Fgo-spew/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davecgh%2Fgo-spew/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davecgh%2Fgo-spew/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davecgh","download_url":"https://codeload.github.com/davecgh/go-spew/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253317168,"owners_count":21889530,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T17:01:00.047Z","updated_at":"2025-05-13T17:04:13.949Z","avatar_url":"https://github.com/davecgh.png","language":"Go","funding_links":[],"categories":["Misc","Logging","开源类库","日志","Relational Databases","Go","Open source library","Language-Specific Tools","\u003cspan id=\"日志-logging\"\u003e日志 Logging\u003c/span\u003e","Logging 日志库","日志记录","Golang生态圈Dev\u0026Ops工具与服务"],"sub_categories":["Search and Analytic Databases","调试","Advanced Console UIs","Debugging","Go","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","SQL 查询语句构建库","检索及分析资料库","交流"],"readme":"go-spew\n=======\n\n[![Build Status](https://img.shields.io/travis/davecgh/go-spew.svg)](https://travis-ci.org/davecgh/go-spew)\n[![ISC License](http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org)\n[![Coverage Status](https://img.shields.io/coveralls/davecgh/go-spew.svg)](https://coveralls.io/r/davecgh/go-spew?branch=master)\n\nGo-spew implements a deep pretty printer for Go data structures to aid in\ndebugging.  A comprehensive suite of tests with 100% test coverage is provided\nto ensure proper functionality.  See `test_coverage.txt` for the gocov coverage\nreport.  Go-spew is licensed under the liberal ISC license, so it may be used in\nopen source or commercial projects.\n\nIf you're interested in reading about how this package came to life and some\nof the challenges involved in providing a deep pretty printer, there is a blog\npost about it\n[here](https://web.archive.org/web/20160304013555/https://blog.cyphertite.com/go-spew-a-journey-into-dumping-go-data-structures/).\n\n## Documentation\n\n[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/davecgh/go-spew/spew)\n\nFull `go doc` style documentation for the project can be viewed online without\ninstalling this package by using the excellent GoDoc site here:\nhttp://godoc.org/github.com/davecgh/go-spew/spew\n\nYou can also view the documentation locally once the package is installed with\nthe `godoc` tool by running `godoc -http=\":6060\"` and pointing your browser to\nhttp://localhost:6060/pkg/github.com/davecgh/go-spew/spew\n\n## Installation\n\n```bash\n$ go get -u github.com/davecgh/go-spew/spew\n```\n\n## Quick Start\n\nAdd this import line to the file you're working in:\n\n```Go\nimport \"github.com/davecgh/go-spew/spew\"\n```\n\nTo dump a variable with full newlines, indentation, type, and pointer\ninformation use Dump, Fdump, or Sdump:\n\n```Go\nspew.Dump(myVar1, myVar2, ...)\nspew.Fdump(someWriter, myVar1, myVar2, ...)\nstr := spew.Sdump(myVar1, myVar2, ...)\n```\n\nAlternatively, if you would prefer to use format strings with a compacted inline\nprinting style, use the convenience wrappers Printf, Fprintf, etc with %v (most\ncompact), %+v (adds pointer addresses), %#v (adds types), or %#+v (adds types\nand pointer addresses): \n\n```Go\nspew.Printf(\"myVar1: %v -- myVar2: %+v\", myVar1, myVar2)\nspew.Printf(\"myVar3: %#v -- myVar4: %#+v\", myVar3, myVar4)\nspew.Fprintf(someWriter, \"myVar1: %v -- myVar2: %+v\", myVar1, myVar2)\nspew.Fprintf(someWriter, \"myVar3: %#v -- myVar4: %#+v\", myVar3, myVar4)\n```\n\n## Debugging a Web Application Example\n\nHere is an example of how you can use `spew.Sdump()` to help debug a web application. Please be sure to wrap your output using the `html.EscapeString()` function for safety reasons. You should also only use this debugging technique in a development environment, never in production.\n\n```Go\npackage main\n\nimport (\n    \"fmt\"\n    \"html\"\n    \"net/http\"\n\n    \"github.com/davecgh/go-spew/spew\"\n)\n\nfunc handler(w http.ResponseWriter, r *http.Request) {\n    w.Header().Set(\"Content-Type\", \"text/html\")\n    fmt.Fprintf(w, \"Hi there, %s!\", r.URL.Path[1:])\n    fmt.Fprintf(w, \"\u003c!--\\n\" + html.EscapeString(spew.Sdump(w)) + \"\\n--\u003e\")\n}\n\nfunc main() {\n    http.HandleFunc(\"/\", handler)\n    http.ListenAndServe(\":8080\", nil)\n}\n```\n\n## Sample Dump Output\n\n```\n(main.Foo) {\n unexportedField: (*main.Bar)(0xf84002e210)({\n  flag: (main.Flag) flagTwo,\n  data: (uintptr) \u003cnil\u003e\n }),\n ExportedField: (map[interface {}]interface {}) {\n  (string) \"one\": (bool) true\n }\n}\n([]uint8) {\n 00000000  11 12 13 14 15 16 17 18  19 1a 1b 1c 1d 1e 1f 20  |............... |\n 00000010  21 22 23 24 25 26 27 28  29 2a 2b 2c 2d 2e 2f 30  |!\"#$%\u0026'()*+,-./0|\n 00000020  31 32                                             |12|\n}\n```\n\n## Sample Formatter Output\n\nDouble pointer to a uint8:\n```\n\t  %v: \u003c**\u003e5\n\t %+v: \u003c**\u003e(0xf8400420d0-\u003e0xf8400420c8)5\n\t %#v: (**uint8)5\n\t%#+v: (**uint8)(0xf8400420d0-\u003e0xf8400420c8)5\n```\n\nPointer to circular struct with a uint8 field and a pointer to itself:\n```\n\t  %v: \u003c*\u003e{1 \u003c*\u003e\u003cshown\u003e}\n\t %+v: \u003c*\u003e(0xf84003e260){ui8:1 c:\u003c*\u003e(0xf84003e260)\u003cshown\u003e}\n\t %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)\u003cshown\u003e}\n\t%#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)\u003cshown\u003e}\n```\n\n## Configuration Options\n\nConfiguration of spew is handled by fields in the ConfigState type. For\nconvenience, all of the top-level functions use a global state available via the\nspew.Config global.\n\nIt is also possible to create a ConfigState instance that provides methods\nequivalent to the top-level functions. This allows concurrent configuration\noptions. See the ConfigState documentation for more details.\n\n```\n* Indent\n\tString to use for each indentation level for Dump functions.\n\tIt is a single space by default.  A popular alternative is \"\\t\".\n\n* MaxDepth\n\tMaximum number of levels to descend into nested data structures.\n\tThere is no limit by default.\n\n* DisableMethods\n\tDisables invocation of error and Stringer interface methods.\n\tMethod invocation is enabled by default.\n\n* DisablePointerMethods\n\tDisables invocation of error and Stringer interface methods on types\n\twhich only accept pointer receivers from non-pointer variables.  This option\n\trelies on access to the unsafe package, so it will not have any effect when\n\trunning in environments without access to the unsafe package such as Google\n\tApp Engine or with the \"safe\" build tag specified.\n\tPointer method invocation is enabled by default.\n\n* DisablePointerAddresses\n\tDisablePointerAddresses specifies whether to disable the printing of\n\tpointer addresses. This is useful when diffing data structures in tests.\n\n* DisableCapacities\n\tDisableCapacities specifies whether to disable the printing of capacities\n\tfor arrays, slices, maps and channels. This is useful when diffing data\n\tstructures in tests.\n\n* ContinueOnMethod\n\tEnables recursion into types after invoking error and Stringer interface\n\tmethods. Recursion after method invocation is disabled by default.\n\n* SortKeys\n\tSpecifies map keys should be sorted before being printed. Use\n\tthis to have a more deterministic, diffable output.  Note that\n\tonly native types (bool, int, uint, floats, uintptr and string)\n\tand types which implement error or Stringer interfaces are supported,\n\twith other types sorted according to the reflect.Value.String() output\n\twhich guarantees display stability.  Natural map order is used by\n\tdefault.\n\n* SpewKeys\n\tSpewKeys specifies that, as a last resort attempt, map keys should be\n\tspewed to strings and sorted by those strings.  This is only considered\n\tif SortKeys is true.\n\n```\n\n## Unsafe Package Dependency\n\nThis package relies on the unsafe package to perform some of the more advanced\nfeatures, however it also supports a \"limited\" mode which allows it to work in\nenvironments where the unsafe package is not available.  By default, it will\noperate in this mode on Google App Engine and when compiled with GopherJS.  The\n\"safe\" build tag may also be specified to force the package to build without\nusing the unsafe package.\n\n## License\n\nGo-spew is licensed under the [copyfree](http://copyfree.org) ISC License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavecgh%2Fgo-spew","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavecgh%2Fgo-spew","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavecgh%2Fgo-spew/lists"}