Skip to content

Panic: integer divide by zero when setting a style #167

Closed
@droslean

Description

@droslean
panic: runtime error: integer divide by zero

goroutine 1 [running]:
github.com/jedib0t/go-pretty/v6/text.RepeatAndTrim(0x0, 0x0, 0x5, 0x0, 0x0)
	/home/user/go/pkg/mod/github.com/jedib0t/go-pretty/[email protected]/text/string.go:110 +0x12d
github.com/jedib0t/go-pretty/v6/table.(*Table).initForRenderRowSeparator(0xc00018f5b0)
	/home/user/go/pkg/mod/github.com/jedib0t/go-pretty/[email protected]/table/table.go:746 +0x1a5
github.com/jedib0t/go-pretty/v6/table.(*Table).initForRender(0xc00018f5b0)
	/home/user/go/pkg/mod/github.com/jedib0t/go-pretty/[email protected]/table/table.go:569 +0x65
github.com/jedib0t/go-pretty/v6/table.(*Table).Render(0xc00018f5b0, 0xc000128640, 0x4)
	/home/user/go/pkg/mod/github.com/jedib0t/go-pretty/[email protected]/table/render.go:22 +0x45
main.main.func2(0xc000039140, 0x0, 0x0)

My code:

t := table.NewWriter()
style := table.Style{
	Name:    "my-style",
}
t.SetStyle(style)
t.SetOutputMirror(os.Stdout)
t.AppendHeader(table.Row{"#", "Name", "Address", "Phone", "Birthday"})

for i, info := range data.Items {
	t.AppendRows([]table.Row{{i, info.Name, info.Address, info.Phone, info.Birthday}})
}
t.AppendSeparator()
t.AppendFooter(table.Row{"Total", len(data.Items), "", ""})
t.Render()

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