Skip to content

heitormbonfim/go-desktop-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskFlow - Professional Go Desktop App Template

TaskFlow is a modern, well-structured desktop todo list application built with Go and the Fyne UI toolkit. It serves as a professional template showcasing best practices for building desktop applications with clean architecture, data persistence, and smart UI/UX features.

✨ Features

  • Smart Todo Management: Create, complete, and delete tasks with ease
  • Data Persistence: All tasks are automatically saved and restored between sessions
  • Window State Memory: Remembers your window size and position preferences
  • Responsive Design: Adapts intelligently to different screen sizes
  • Tabbed Interface: Filter tasks by All, Active, or Completed
  • Professional UI: Clean, modern design with smooth interactions
  • Statistics Dashboard: Real-time overview of your tasks
  • Clean Architecture: Complete separation between UI and business logic

🗂️ Project Structure

The project follows the standard Go layout for maintainability and scalability:

  • cmd/todo/main.go: The application entry point. Initializes the Fyne application, manages window state persistence, and coordinates between Core Logic and UI components.

  • internal/application/application.go: Contains the Core Application Logic (CoreApp). This layer is completely UI-agnostic (knows nothing about Fyne widgets). All business logic (CRUD operations, data persistence, statistics) lives here.

  • internal/ui/ui.go: Contains the User Interface components. Creates Fyne widgets, defines visual styles, and calls methods from CoreApp when user interactions occur.


⚙️ Prerequisites

Go Dependency

This project requires Go version 1.24.4 (or any version 1.18+).

For Linux (Debian/Ubuntu-based Distributions):

Since Fyne uses C libraries (like GLFW, which relies on OpenGL and X11/Wayland backends) to draw graphics, you must install the necessary development headers on your Linux system before Go can successfully compile the application.

Use this command to install all required C development packages:

sudo apt update
sudo apt install libgl1-mesa-dev xorg-dev libxcursor-dev libxi-dev

Note on Safety: Installing these -dev packages is safe. They only provide compiler-time resources (header files), not runtime system changes, and will not conflict with your Wayland environment.

For macOS:

On macOS, dependencies are often handled automatically by the operating system, especially if you have Xcode Command Line Tools installed.

If you encounter compilation errors (related to libraries like pkg-config), installing the necessary tools via Homebrew is the best fix:

brew install pkg-config

🛠️ Installing Go

If you do not have Go installed, follow the recommended method for your platform:

1. Linux (Recommended: Official Binary)

  1. Download the official tarball from the Go Downloads page.
  2. Extract the archive to /usr/local (this is the standard location):
    sudo rm -rf /usr/local/go
    sudo tar -C /usr/local -xzf go<version>.linux-amd64.tar.gz
  3. Add the Go binary directory to your $PATH environment variable in your shell configuration file (e.g., ~/.bashrc or ~/.zshrc):
    export PATH=$PATH:/usr/local/go/bin
  4. Restart your shell or run source ~/.bashrc (or equivalent) and verify:
    go version

2. macOS (Recommended: Homebrew)

Use Homebrew for the easiest installation:

brew install go

3. Windows (Recommended: Official Installer)

Download the official MSI installer from the Go Downloads page. The installer automatically handles the installation and sets up the necessary environment variables for you.


🚀 Setup and Run

Follow these steps from the project root directory:

1. Install Dependencies

make install

Or manually:

go mod download

2. Run the Application

Development mode (run without building):

make dev

Or build and run:

make run

Or manually:

go run cmd/todo/main.go

The application will automatically:

  • Create a configuration directory at ~/.config/taskflow/ (Linux) or equivalent on your OS
  • Save your todos to ~/.config/taskflow/todos.json
  • Remember your window size and position in ~/.config/taskflow/window_state.json

🛠️ Makefile Commands

The project includes a Makefile for easy building and development:

Command Description
make build Build the application
make run Build and run the application
make dev Run in development mode (no build)
make install Install dependencies
make test Run tests
make clean Remove build artifacts
make build-linux Build for Linux
make build-macos Build for macOS Intel
make build-macos-arm Build for macOS Apple Silicon
make build-windows Build for Windows
make build-all Build for all platforms
make help Show help message

📦 Building Executables

Using Makefile (Recommended)

Build for your current system:

make build

Build for all platforms at once:

make build-all

Or build for specific platforms:

make build-linux
make build-macos
make build-macos-arm
make build-windows

All builds will be placed in the build/ directory.

Manual Building

Build for your current system:

go build -o taskflow ./cmd/todo

Cross-compile for other platforms:

Target OS Command Output
Linux (64-bit) GOOS=linux GOARCH=amd64 go build -o taskflow-linux ./cmd/todo taskflow-linux
macOS (Intel) GOOS=darwin GOARCH=amd64 go build -o taskflow-macos-intel ./cmd/todo taskflow-macos-intel
macOS (Apple Silicon) GOOS=darwin GOARCH=arm64 go build -o taskflow-macos-arm ./cmd/todo taskflow-macos-arm
Windows (64-bit) GOOS=windows GOARCH=amd64 go build -o taskflow.exe ./cmd/todo taskflow.exe

📂 Data Storage

TaskFlow stores all application data in your system's standard configuration directory:

  • Linux: ~/.config/taskflow/
  • macOS: ~/Library/Application Support/taskflow/
  • Windows: %APPDATA%\taskflow\

Files stored:

  • todos.json - Your task data
  • window_state.json - Window size and position preferences

🎨 Customization

This template is designed to be easily customizable:

  1. Change the Application Name: Update references to "TaskFlow" in main.go and UI files
  2. Modify the Core Logic: Edit internal/application/application.go to add new features
  3. Customize the UI: Adjust colors, layouts, and components in internal/ui/ui.go
  4. Add New Features: The clean architecture makes it easy to extend functionality

🏗️ Architecture Highlights

Separation of Concerns: The UI layer (internal/ui/) knows about the Core layer (internal/application/), but the Core layer is completely independent of the UI. This means you could swap Fyne for another UI toolkit without changing your business logic.

Data Persistence: The CoreApp handles all file I/O operations transparently. The UI simply calls methods like AddTodo() and the persistence happens automatically.

Window State Management: The main.go handles saving and restoring window preferences, demonstrating professional application behavior.


🤝 Contributing

This is a template project designed to help developers kickstart their Go desktop applications. Feel free to fork it, customize it, and make it your own!

About

A Task management application

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors