FreeThreads
Published in

FreeThreads

“respError”: “json: unsupported type: func() (io.ReadCloser, error)”

zap library in Golang hit the error on logging a field of the function type.

{"level":"info","msg":"non-200 response","respError":"json: unsupported type: func() (io.ReadCloser, error)"}

The problem is with the type of logger used.

Source code for the above log is:

package mainimport (
"fmt"
"go.uber.org/zap"
"log"
"net/http"
"net/http/httptest"
)
func main() {
const body = "Go is…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store