Config File
This page explains where .webMonitor.json lives, when it is created, and what every field means.
Location and Lifecycle
go-web-monitor reads no environment variables. All state and settings live in .webMonitor.json in the current working directory (the project .gitignore already excludes it).
| When | Behavior |
|---|---|
| File missing at startup | Creates an empty list with SMTP defaults port: 587 and enabled: false |
| At startup | Loads list[].url as the watch list and config as the SMTP settings; exits with an error when the JSON fails to parse |
| While running | Overwrites the whole file after each check round, add / del, and smtp commands |
Starting the program in a different directory uses a different, independent config file.
Example
{
"list": [
{
"url": "https://example.com",
"code": 200,
"duration": 62554917,
"online": true,
"last_check": "2025-01-15T23:12:29.200334+08:00",
"expire": 87,
"count": 0
}
],
"config": {
"host": "smtp.gmail.com",
"port": 587,
"username": "your@email.com",
"password": "your_app_password",
"from": "your@email.com",
"to": ["recipient@email.com"],
"cc": "",
"enabled": true
}
}
list[] Fields (model.Website)
| Field | Type | Description |
|---|---|---|
url |
string | Normalized URL (https:// is prepended when the input does not start with http) |
code |
int | Last HTTP status code; 0 on connection failure |
duration |
int | Response time in nanoseconds (time.Duration) |
online |
bool | true when the status code is 200–399 |
last_check |
string | Last check time (RFC 3339) |
expire |
int | Days until the SSL certificate expires; 0 when unavailable |
count |
int | Consecutive offline checks, from 0 to 4 |
Startup uses only url; the other fields are a snapshot of the previous run and are overwritten after the first round.
config Fields (model.Config)
| Field | Type | Default | Description |
|---|---|---|---|
host |
string | "" |
SMTP host |
port |
int | 587 |
465 uses implicit TLS, 587 uses STARTTLS |
username |
string | "" |
Auth runs only when this and password are both set |
password |
string | "" |
Stored in plaintext in the file |
from |
string | "" |
Sender address |
to |
[]string | [] |
Recipient list |
cc |
string | "" |
CC address; no TUI command sets it, so edit it by hand |
enabled |
bool | false |
Whether alerts and test emails are sent |
password is written in plaintext and the file gets 0644 permissions; adjust the permissions yourself on a shared host.
Manual Edits
The program overwrites the whole config file while running, so make manual changes (such as cc or bulk-importing URLs) after it exits; they take effect on the next start.