package templates import ( "fmt" ) // Result list definition const result_list_open string = `
Query Error: %s
` const query_error_message_blank string = `` func ErrorQueryResults(e error) string { return result_list_open + result_list_close + fmt.Sprintf(query_error_message, e.Error()) } func ConcatResults(items []string) string { var html string = result_list_open for _, h := range items { html += h } return html + result_list_close } func QueryResult(cols []string, rows []map[string]interface{}) string { head := generateHead(cols) body := table_body_open for _, row := range rows { body += generateRow(cols, row) } body += table_body_close return fmt.Sprintf(result_item, table_open+head+body+table_close+query_error_message_blank) } // Generate the tables head row func generateHead(cols []string) string { html := table_head_open for _, col := range cols { html += fmt.Sprintf(table_head_row, col) } return html + table_head_close } func generateRow(cols []string, data map[string]interface{}) string { row := "