diff --git a/cmd/main/main.go b/cmd/main/main.go index 5201187..576c91b 100644 --- a/cmd/main/main.go +++ b/cmd/main/main.go @@ -6,6 +6,7 @@ import ( "fmt" "log" "os" + "reflect" "time" "unicode/utf8" @@ -102,11 +103,18 @@ func main() { if !ok { fmt.Printf("Missing key for multitype array") } + // Get an interface that we can work with to access the sub elements vslice := vislice.([]interface{}) + // Check that the first element is what we expected + if _, ok := vslice[0].(orderedmap.OrderedMap); !ok { + error := fmt.Sprintf("Type of first vslice element is not an ordered map. It appears to be '%v'\n", reflect.TypeOf(vslice[0])) + panic(error) + } // Get the keys for the first element so we know what the column names will be columnMap := vslice[0].(orderedmap.OrderedMap) + fmt.Printf("First vslice element is an ordered map") columnNames := columnMap.Keys() // Run code to add column names to the first row of the workbook