package
0.0.0-20240228044302-56ad08b2fa1c
Repository: https://github.com/parsiya/parsia-code.git
Documentation: pkg.go.dev
# README
Gophercises - 14 - Panic/Recover Middleware
Problem
Solution
- main.go: Implemented everything including Flusher and Hijack.
Lessons Learned
Print Stacktrace
- debug.Stack(): Returns a
[]byte
(remember to convert to string before printing). - runtime.Stack(buf []byte, all bool) int: Pass a
[]byte
that gets filled.
Custom http.ResponseWriter
See this:
Embed
Embed stuff in structs to use them.
type myRW struct {
http.ResponseWriter
}
Type Assertion
t, ok := i.(T)
if ok {
// i.T is implemented and stored in T
}