🌐 **English** | [日本語](./README.ja.md)

# README Viewer

![ ](./www.jpg)

## Overview

README Viewer is a simple app for viewing Markdown files such as `README.md`. It does not include editing functionality.
It uses `go:embed` to embed static resources (HTML, CSS, JS, and the Markdown file itself) into the binary, resulting in a single file.
The rendering engine used internally varies by operating system (Edge/WebView2 on Windows, WebKit on macOS, and WebKitGTK on Linux).


The goal is to allow anyone to easily read `README.md` with the same visual appearance by distributing it alongside your own applications.



## Main Features

- **File List & Sidebar**: Automatically detects `.md` files in the same directory and allows you to switch between them from the list
- **Real-time Search**: Search within the text and cross-file search (multiple files)
- **Page Navigation**: Back, Forward, and Refresh
- **Print**: Print the entire currently displayed file


## Prerequisites

- Go 1.20 or later
- A GCC compiler such as Mingw-w64 (Windows)
- `github.com/webview/webview_go` must be installed (automatically fetched by `go mod tidy`)
- On Windows, WebView2 Runtime must be installed
- Since localhost:8080 is used to transfer .md files, you may be prompted for network access permission upon startup.


## How to Use

1. When launched, the program displays the `README.md` file in the current directory, if one exists. If none exists, it displays the first `.md` file in the same directory.
2. You can specify a Markdown file as a command-line argument.
   - Windows: `readme-viewer.exe README.md`
   - Linux/macOS: `./readme-viewer README.md`
3. You can switch between `.md` files in the same directory using the left sidebar.
4. Use the search bar at the top of the screen to search for text; check the `Cross-file Search` box to search across multiple files.
5. Click the **🖨 Print** button on the menu bar to print the entire current file.


## Build & Run Instructions

### Preparation

```bash
# Clone the repository
git clone https://github.com/nyorotan/readme-viewer.git
cd readme-viewer

# Fetch dependencies
go mod tidy
```

### Windows

```cmd
# Build (generate a single executable file)
set CGO_ENABLED=1
set GOOS=windows
set GOARCH=amd64
set CXX=x86_64-w64-mingw32-g++
set CC=x86_64-w64-mingw32-gcc
go build -trimpath -ldflags="-H windowsgui -s -w" -o readme-viewer.exe ./

# Run
./readme-viewer.exe
```

### Linux

```bash
# Build (generate a single executable file)
export CGO_ENABLED=1
export GOOS=linux
export GOARCH=amd64
go build -trimpath -ldflags="-s -w" -o readme-viewer ./

# Run
./readme-viewer
```


## About Embedded Resources

HTML, CSS, JS, image, and Markdown files located under the `static/` directory are embedded using the following code.

```go
//go:embed static
var staticFS embed.FS
```

The binary generated by `go:embed` can be distributed as a single file.

## Troubleshooting

- On Windows, the application may not launch if the WebView2 Runtime is missing.
- On Linux, dependencies such as WebKitGTK may be required.
- If you encounter build errors, first run `go mod tidy`.

## License

MIT License © 2026 nyorotan
