# Building Geek-life for Windows

This document explains how to build and run Geek-life on Windows systems.

## Prerequisites

- Go 1.14 or later installed on your system
- PowerShell (comes with Windows)

## Building the Application

### Option 1: Using the Windows Build Script (Recommended)

Run the PowerShell build script to build for all Windows architectures:

```powershell
.\build-windows.ps1
```

This will create optimized executables for:
- Windows AMD64 (64-bit) - `geek-life_windows-amd64.exe`
- Windows 386 (32-bit) - `geek-life_windows-386.exe`  
- Windows ARM64 - `geek-life_windows-arm64.exe`

### Option 2: Manual Build

For a simple build without optimization:
```powershell
go build -o builds/geek-life.exe ./app
```

For an optimized build (smaller file size):
```powershell
$env:GOOS="windows"
$env:GOARCH="amd64"
go build -ldflags="-s -w" -o builds/geek-life_windows-amd64.exe ./app
```

## Running the Application

After building, you can run the application:

```powershell
# For the optimized AMD64 version (recommended for most users)
.\builds\geek-life_windows-amd64.exe

# For 32-bit systems
.\builds\geek-life_windows-386.exe

# For ARM64 systems
.\builds\geek-life_windows-arm64.exe
```

## Command Line Options

```powershell
.\builds\geek-life_windows-amd64.exe --help
```

Available options:
- `-d, --db-file string`: Specify DB file path manually

## File Structure

The main entry point is located in `app/cli.go` (not in a traditional `main.go` file at the root).

## Build Optimization

The build script uses the following optimization flags:
- `-ldflags="-s -w"`: Strips debug information and symbol table to reduce file size
- Results in approximately 30% smaller executable files

## Troubleshooting

1. **"go: command not found"**: Make sure Go is installed and added to your PATH
2. **Permission denied**: Run PowerShell as Administrator if needed
3. **Execution policy**: If you can't run the build script, run: `Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser`

## Cross-compilation from Other Platforms

You can also build Windows executables from Linux/macOS:

```bash
# From Linux/macOS
env GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o builds/geek-life_windows-amd64.exe ./app
env GOOS=windows GOARCH=386 go build -ldflags="-s -w" -o builds/geek-life_windows-386.exe ./app
```