Skip to content

Tree-Tables: Added *Table as a table cell type: tables within tables

Pre-release
Pre-release
Compare
Choose a tag to compare
@urban-wombat urban-wombat released this 21 Feb 06:17
· 151 commits to master since this release

Tree-Tables

This is what I am calling tree-tables: recursively nested tables with tables in cells in tables.

Tables all the way down.

The string representation of a table has been extended to allow:-

  • *Table or *gotables.Table as a column type (it's the same type)
  • [MyTableName] syntax as a cell entry
  • [] syntax as a Go nil entry (when a table is printed)
  • [] syntax as a NilTable entry (when a table is printed)
  • [] syntax will be interpreted by NewTableFromString() as a NilTable, and not as Go nil

Note: there is no nested string representation of nested tables. Tables as strings will retain
only the names of the nested tables, and none of their content. The nested tables need to
be printed separately. This should be no problem in practice.

NilTable

NilTable is a strange one. It's intended to act as a kind of zero-value *Table value.

It has no name and cannot be mutated, except for giving it a name: table.SetName("MyName")

Giving it a name sets its state to not-NilTable which can then be mutated.

A NilTable is constructed with: NewNilTable() which takes no table name argument (it doesn't have a name
until it is de-Nilled) and does not return an error. It is a single-context return function.

Util

I have become fed up with keeping urban-wombat/gotables and urban-wombat/util consistent with each other.

I have incorporated all the util functions and methods into gotables, giving them the prefix Util to help
visually separate them from the other functions and methods. I hope this doesn't bother anyone. The
existing util package remains unchanged, so nothing should break.

The latest gotables godoc

https://godoc.org/github.com/urban-wombat/gotables

Here are some links from the godoc with Example code:-