gherkin/types.go
func (t TabularData) ToMap() TabularDataMap {
	m := TabularDataMap{}
	if len(t) > 1 {
		for _, th := range t[0] {
			m[th] = []string{}
		}
		for _, tr := range t[1:] {
			for c, td := range tr {
				m[t[0][c]] = append(m[t[0][c]], td)
			}
		}
	}
	return m
}
func (t TabularData) ToMap() TabularDataMap {
	m := TabularDataMap{}
	if len(t) > 1 {
		for _, th := range t[0] {
			m[th] = []string{}
		}
		for _, tr := range t[1:] {
			for c, td := range tr {
				m[t[0][c]] = append(m[t[0][c]], td)
			}
		}
	}
	return m
}
func ( t TabularData ) ToMap ( ) TabularDataMap { m := TabularDataMap { } if len ( t ) > 1 { for _ , th := range t [ 0 ] { m [ th ] = [ ] string { } } for _ , tr := range t [ 1 : ] { for c , td := range tr { m [ t [ 0 ] [ c ] ] = append ( m [ t [ 0 ] [ c ] ] , td ) } } } return m }
// ToMap converts a regular table to a map of header names to their row data.
// For example:
//
//     t := TabularData{[]string{"header1", "header2"}, []string{"col1", "col2"}}
//     t.ToMap()
//     // Output:
//     //   map[string][]string{
//     //     "header1": []string{"col1"},
//     //     "header2": []string{"col2"},
//     //   }
ToMap converts a regular table to a map of header names to their row data . For example : t : = TabularData { [] string { header1 header2 } [] string { col1 col2 }} t . ToMap () // Output : // map [ string ] [] string { // header1 : [] string { col1 } // header2 : [] string { col2 } // }