easyjson
easyjson copied to clipboard
Move MarshalToHTTPResponseWriter into separate package
Easyjson provides number of so-called helpers for specific cases which are still import their dependencies by every package that depend on easyjson.
You can't avoid importing easyjson core package as noted in #331 and you can't use easyjson.Marshaler and easyjson.Unmarshaler interfaces without this import as these are one of the key interfaces in the package.
Notably, MarshalToHTTPResponseWriter imports net/http which is not a lightweight package. Contrary to encoding/json which does not depent on anything unrelated to, well, json encoding and decoding.
UnmarshalFromReader also uses io/ioutil which again requires you to import bunch of unrelated packages. It should be noted that this package is deprecated though. Since 1.16 it is possible to use just io.ReadAll.
Specific cases like this should be optional since not everyone needs net/http and not everyone need to interact with http at all.