Skip to content

Getting Started

Welcome to goTableView! This guide will help you install and create your first table in just a few minutes.

What You'll Learn

  • How to install goTableView
  • System requirements
  • Creating your first table
  • Understanding the basics

Prerequisites

Before you begin, make sure you have:

  • Go 1.18 or higher installed (Download Go)
  • Windows OS (Windows 10 or 11 recommended)
  • Basic familiarity with Go programming

Why Windows Only?

goTableView uses the native Windows ListView control through direct Windows API calls. This provides excellent performance and a familiar interface, but limits us to Windows platforms.

Installation

Installing goTableView is simple. Open your terminal and run:

bash
go get github.com/mansoldof/goTableView

This will download the package and its only dependency: golang.org/x/sys/windows.

Verifying Installation

Create a new directory for testing:

bash
mkdir gotableview-test
cd gotableview-test
go mod init example
go get github.com/mansoldof/goTableView

Create a file named main.go:

go
package main

import "github.com/mansoldof/goTableView"

func main() {
    gotableview.New("Hello goTableView").
        Columns("Message").
        Row("Installation successful!").
        Show()
}

Run it:

bash
go run main.go

You should see a window appear with your first table! 🎉

goTableView basic usage

Your First Real Table

Now let's create something more useful. Update your main.go:

go
package main

import "github.com/mansoldof/goTableView"

func main() {
    // Create a table with employee data
    gotableview.New("Employee List").
        Columns("Name", "Department", "Age", "Salary").
        Row("Alice Johnson", "Engineering", "30", "$75,000").
        Row("Bob Smith", "Marketing", "25", "$60,000").
        Row("Carol White", "Sales", "28", "$65,000").
        Row("David Brown", "Engineering", "35", "$85,000").
        Show()
}

Run it again:

bash
go run main.go
goTableView basic usage

Understanding the Code

Let's break down what's happening:

go
gotableview.New("Employee List")  // Create a new table with a title
    .Columns("Name", "Department", "Age", "Salary")  // Define column headers
    .Row("Alice Johnson", "Engineering", "30", "$75,000")  // Add a row
    .Row("Bob Smith", "Marketing", "25", "$60,000")  // Add another row
    .Show()  // Display the table window

Key Concepts

  1. Fluent API: Methods return *Table, allowing you to chain calls
  2. Title: The window's title bar shows "Employee List"
  3. Columns: Define headers once with Columns()
  4. Rows: Add data with Row(), one call per row
  5. Show: Must be called last to display the window

Common First Steps

Adding Multiple Rows at Once

Instead of calling Row() multiple times, you can use Rows():

go
data := [][]string{
    {"Alice Johnson", "Engineering", "30", "$75,000"},
    {"Bob Smith", "Marketing", "25", "$60,000"},
    {"Carol White", "Sales", "28", "$65,000"},
}

gotableview.New("Employee List").
    Columns("Name", "Department", "Age", "Salary").
    Rows(data).
    Show()

Working with CSV Data

Reading from a CSV file:

go
package main

import (
    "encoding/csv"
    "os"
    "github.com/mansoldof/goTableView"
)

func main() {
    file, _ := os.Open("employees.csv")
    defer file.Close()
    
    reader := csv.NewReader(file)
    records, _ := reader.ReadAll()
    
    // First row is headers
    headers := records[0]
    data := records[1:]
    
    gotableview.New("CSV Data").
        Columns(headers...).
        Rows(data).
        Show()
}

Troubleshooting

"Package not found" Error

If you see package github.com/mansoldof/goTableView is not in GOROOT, run:

bash
go mod tidy

"Cannot find module" Error

Make sure you initialized a Go module:

bash
go mod init your-project-name

Window Doesn't Appear

  • Ensure you're running on Windows
  • Check that Show() is the last method called
  • Verify no errors in your code

Data Not Displaying

  • Make sure column count matches data count in each row
  • Check that Columns() is called before Row() or Rows()

What's Next?

Now that you have goTableView installed and running, you can:

Need Help?

If you're stuck, check the GitHub Issues or create a new one. We're here to help!

Released under the MIT License.