You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: modelutil.go
    path of file: ./repos/termdbms/viewer
    
    the code of the file until where you have to start completion: package viewer

import (
	"database/sql"
	"encoding/json"
	"fmt"
	"os"
	"strings"

	tea "github.com/charmbracelet/bubbletea"
	"github.com/mathaou/termdbms/database"
	"github.com/mathaou/termdbms/list"
	"github.com/mathaou/termdbms/tuiutil"
)

func (m *TuiModel) WriteMessage(s string) {
	if Message == "" {
		Message = s
		MIP = true
		go Program.Send(tea.KeyMsg{}) // trigger update
		go Program.Send(tea.KeyMsg{}) // trigger update for sure hack gross but w/e
	}
}

func (m *TuiModel) CopyMap() (to map[string]interface{}) {
	from := m.Table().Data
	to = map[string]interface{}{}

	for k, v := range from {
		if copyValues, ok := v.(map[string][]interface{}); ok {
			columnNames := m.Data().TableHeaders[k]
			columnValues := make(map[string][]interface{})
			// golang wizardry
			columns := make([]interface{}, len(columnNames))

			for i := range columns {
				columns[i] = copyValues[columnNames[i]]
			}

			for i, colName := range columnNames {
				val := columns[i].([]interface{})
				buffer :=
    
func (m *TuiModel) PopulateDataForResult(c *sql.Rows, indexMap *int, schemaName string) {
	columnNames, _ := c.Columns()
	columnValues := make(map[string][]interface{})

	for c.Next() { // each row of the table
		// golang wizardry
		columns := make([]interface{}, len(columnNames))
		columnPointers := make([]interface{}, len(columnNames))
		// init interface array
		for i := range columns {
			columnPointers[i] = &columns[i]
		}

		c.Scan(columnPointers...)

		for i, colName := range columnNames {
			val := columnPointers[i].(*interface{})
			columnValues[colName] = append(columnValues[colName], *val)
		}
	}

	// onto the next schema
	*indexMap++
	if m.QueryResult != nil && m.QueryData != nil {
		m.QueryResult.Data[schemaName] = columnValues
		m.QueryData.TableHeaders[schemaName] = columnNames // headers for the schema, for later reference
		m.QueryData.TableIndexMap[*indexMap] = schemaName
		return
	}
	m.Table().Data[schemaName] = columnValues       // data for schema, organized by column
	m.Data().TableHeaders[schemaName] = columnNames // headers for the schema, for later reference
	// mapping between schema and an int ( since maps aren't deterministic), for later reference
	m.Data().TableIndexMap[*indexMap] = schemaName
}