Skip to content

format.Object: indendation changes how structs are formatted #886

@pohly

Description

@pohly

https://go.dev/play/p/LXbkvF1LXba

package main

import (
	"errors"
	"fmt"

	"github.com/onsi/gomega/format"
)

func main() {
	err := errors.New("fake")
	fmt.Println(format.Object(err, 1))
	fmt.Println(format.Object(err, 0))
}

This should print the same content, just with different indentation. But in practice the "fake" string is only enclosed with quotation marks (which I prefer) inside the struct dump when indentation > 0:

    <*errors.errorString | 0xc000014070>: 
    fake
    {s: "fake"}
<*errors.errorString | 0xc000014070>: 
fake
{s: fake}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions