mirror of
https://github.com/jimeh/go-render.git
synced 2026-02-18 19:06:39 +00:00
chore: correct typos and align struct field tags (#12)
Fixes typos in package documentation and variable names. Aligns struct field tags in examples and tests for better readability.
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// Binary can render values which implment the encoding.BinaryMarshaler
|
||||
// Binary can render values which implement the encoding.BinaryMarshaler
|
||||
// interface.
|
||||
type Binary struct{}
|
||||
|
||||
@@ -15,8 +15,8 @@ var (
|
||||
_ FormatsHandler = (*Binary)(nil)
|
||||
)
|
||||
|
||||
// Render writes result of calling MarshalBinary() on v. If v does not implment
|
||||
// encoding.BinaryMarshaler the ErrCannotRander error will be returned.
|
||||
// Render writes result of calling MarshalBinary() on v. If v does not implement
|
||||
// encoding.BinaryMarshaler the ErrCannotRender error will be returned.
|
||||
func (br *Binary) Render(w io.Writer, v any) error {
|
||||
x, ok := v.(encoding.BinaryMarshaler)
|
||||
if !ok {
|
||||
|
||||
@@ -3,7 +3,7 @@ package render
|
||||
import "io"
|
||||
|
||||
// Handler interface is for single format renderers, which can only render a
|
||||
// single format. It is the basis of the multi-format support offerred by the
|
||||
// single format. It is the basis of the multi-format support offered by the
|
||||
// render package.
|
||||
type Handler interface {
|
||||
// Render writes v into w in the format that the Handler supports.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Package render provides a simple and flexible solutio to render a value to a
|
||||
// Package render provides a simple and flexible solution to render a value to a
|
||||
// io.Writer using different formats based on a format string argument.
|
||||
//
|
||||
// It is designed around using a custom type/struct to render your output.
|
||||
|
||||
@@ -132,7 +132,7 @@ type renderFormatTestCase struct {
|
||||
}
|
||||
|
||||
// "binary" format.
|
||||
var binaryFormattestCases = []renderFormatTestCase{
|
||||
var binaryFormatTestCases = []renderFormatTestCase{
|
||||
{
|
||||
name: "with binary marshaler",
|
||||
formats: []string{"binary", "bin"},
|
||||
|
||||
@@ -105,7 +105,7 @@ func (r *Renderer) Pretty(w io.Writer, format string, v any) error {
|
||||
}
|
||||
|
||||
// NewWith creates a new Renderer with the formats given, if they have handlers
|
||||
// in the currener Renderer. It essentially allows to restrict a Renderer to a
|
||||
// in the current Renderer. It essentially allows to restrict a Renderer to a
|
||||
// only a sub-set of supported formats.
|
||||
func (r *Renderer) NewWith(formats ...string) *Renderer {
|
||||
handlers := make(map[string]Handler, len(formats))
|
||||
|
||||
@@ -112,13 +112,13 @@ func TestRenderer_Add(t *testing.T) {
|
||||
want: []string{"tackle"},
|
||||
},
|
||||
{
|
||||
name: "hander with Formats",
|
||||
name: "handler with Formats",
|
||||
format: "hackle",
|
||||
handler: &mockFormatsHandler{formats: []string{"hackle"}},
|
||||
want: []string{"hackle"},
|
||||
},
|
||||
{
|
||||
name: "hander with alias formats",
|
||||
name: "handler with alias formats",
|
||||
format: "hackle",
|
||||
handler: &mockFormatsHandler{formats: []string{"hackle", "hack"}},
|
||||
want: []string{"hackle", "hack"},
|
||||
@@ -471,7 +471,7 @@ func TestRenderer_Pretty(t *testing.T) {
|
||||
|
||||
func TestRenderer_RenderAllFormats(t *testing.T) {
|
||||
tests := []renderFormatTestCase{}
|
||||
tests = append(tests, binaryFormattestCases...)
|
||||
tests = append(tests, binaryFormatTestCases...)
|
||||
tests = append(tests, jsonFormatTestCases...)
|
||||
tests = append(tests, textFormatTestCases...)
|
||||
tests = append(tests, xmlFormatTestCases...)
|
||||
@@ -540,7 +540,7 @@ func TestRenderer_RenderAllFormats(t *testing.T) {
|
||||
|
||||
func TestRenderer_CompactAllFormats(t *testing.T) {
|
||||
tests := []renderFormatTestCase{}
|
||||
tests = append(tests, binaryFormattestCases...)
|
||||
tests = append(tests, binaryFormatTestCases...)
|
||||
tests = append(tests, jsonFormatTestCases...)
|
||||
tests = append(tests, textFormatTestCases...)
|
||||
tests = append(tests, xmlFormatTestCases...)
|
||||
@@ -602,7 +602,7 @@ func TestRenderer_CompactAllFormats(t *testing.T) {
|
||||
|
||||
func TestRenderer_PrettyAllFormats(t *testing.T) {
|
||||
tests := []renderFormatTestCase{}
|
||||
tests = append(tests, binaryFormattestCases...)
|
||||
tests = append(tests, binaryFormatTestCases...)
|
||||
tests = append(tests, jsonFormatTestCases...)
|
||||
tests = append(tests, textFormatTestCases...)
|
||||
tests = append(tests, xmlFormatTestCases...)
|
||||
|
||||
Reference in New Issue
Block a user