From 88918add2cf9e63fb90478d8a3bb25434c452a51 Mon Sep 17 00:00:00 2001 From: Komu Wairagu Date: Sat, 2 Mar 2024 14:37:21 +0300 Subject: [PATCH] Add example (#77) --- CHANGELOG.md | 3 +++ e2e_test.go | 8 ++++++++ example_test.go | 36 ------------------------------------ 3 files changed, 11 insertions(+), 36 deletions(-) delete mode 100644 example_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 99187bb..5c2ab27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ Most recent version is listed first. +# v0.0.24 +- Add example: https://github.com/komuw/kama/pull/77 + # v0.0.23 - Make stacktrace colorization configurable: https://github.com/komuw/kama/pull/76 diff --git a/e2e_test.go b/e2e_test.go index b16ef4a..6eb82f8 100644 --- a/e2e_test.go +++ b/e2e_test.go @@ -478,3 +478,11 @@ func TestAllAboutInterfaces(t *testing.T) { } }) } + +func ExampleDirp() { + req, _ := http.NewRequest("GET", "https://example.com", nil) + req.Header.Set("Content-Type", "application/octet-stream") + req.AddCookie(&http.Cookie{Name: "hello", Value: "world"}) + + kama.Dirp(req, kama.Config{NoColor: true}) +} diff --git a/example_test.go b/example_test.go deleted file mode 100644 index 247facb..0000000 --- a/example_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package kama_test - -// import ( -// "log" -// "net/http" -// ) - -// type myHandler struct{ Logger *log.Logger } - -// func (h myHandler) ServeHTTP(http.ResponseWriter, *http.Request) { -// } - -// This is blocked on: -// 1. https://github.com/golang/go/issues/41980 -// 2. https://github.com/golang/go/issues/5128#issuecomment-708940093 -// func ExampleDirp() { -// h := myHandler{Logger: log.New(os.Stderr, "", 0)} -// kama.Dirp(h) - -// // Output: -// // [ -// // NAME: github.com/komuw/kama_test.myHandler -// // KIND: struct -// // SIGNATURE: [kama_test.myHandler *kama_test.myHandler] -// // FIELDS: [ -// // Logger -// // ] -// // METHODS: [ -// // ServeHTTP func(*kama_test.myHandler, http.ResponseWriter, *http.Request) -// // ServeHTTP func(kama_test.myHandler, http.ResponseWriter, *http.Request) -// // ] -// // SNIPPET: myHandler{ -// // Logger: &Logger{}, -// // } -// // ] -// }