Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] panic when the len(footers) is less than the columns #214

Open
eryx opened this issue Apr 8, 2023 · 0 comments
Open

[bug] panic when the len(footers) is less than the columns #214

eryx opened this issue Apr 8, 2023 · 0 comments

Comments

@eryx
Copy link
Contributor

eryx commented Apr 8, 2023

code

func main() {

	data := [][]string{
		[]string{"A", "The Good", "500"},
		[]string{"B", "The Very very Bad Man", "288"},
		[]string{"C", "The Ugly", "120"},
		[]string{"D", "The Gopher", "800"},
	}

	table := tablewriter.NewWriter(os.Stdout)
	table.SetHeader([]string{"Name", "Sign", "Rating"})

	table.SetFooter([]string{"Name", "Sign"})

	for _, v := range data {
		table.Append(v)
	}
	table.Render() // Send output
}

go run output:

+------+-----------------------+--------+
| NAME |         SIGN          | RATING |
+------+-----------------------+--------+
| A    | The Good              |    500 |
| B    | The Very very Bad Man |    288 |
| C    | The Ugly              |    120 |
| D    | The Gopher            |    800 |
+------+-----------------------+--------+
| NAME |         SIGN          |panic: runtime error: index out of range [2] with length 2

goroutine 1 [running]:
github.com/olekukonko/tablewriter.(*Table).printFooter(0xc000130000)
	/opt/workspace/pkg/mod/github.com/olekukonko/[email protected]/table.go:563 +0xa8a
github.com/olekukonko/tablewriter.(*Table).Render(0xc000130000)
	/opt/workspace/pkg/mod/github.com/olekukonko/[email protected]/table.go:138 +0xeb
main.main()
...
eryx added a commit to eryx/tablewriter that referenced this issue Apr 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant