From b01d08b1e1b0f6bb79b832416aa8c523d327e392 Mon Sep 17 00:00:00 2001 From: Esa Kataja Date: Sat, 5 Sep 2026 13:53:04 +0300 Subject: [PATCH] Move the package into src/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thirty-seven entries in the root, most of them .go files. The assets had to come along: //go:embed cannot reach outside its own directory, so templates/, static/ and migrations/ live beside the code that embeds them, and testdata/ beside the test that reads it. storage/ stays put — runtime data, not source. go build now needs -o. Without it the output would be named after the package directory and collide with src/ itself. --- Dockerfile | 2 +- Makefile | 4 +++- README.md | 6 +++++- admin.go => src/admin.go | 0 auth.go => src/auth.go | 0 auth_test.go => src/auth_test.go | 0 lyrics.go => src/lyrics.go | 0 lyrics_test.go => src/lyrics_test.go | 0 main.go => src/main.go | 0 main_test.go => src/main_test.go | 0 media.go => src/media.go | 0 media_test.go => src/media_test.go | 0 migrate.go => src/migrate.go | 0 {migrations => src/migrations}/001_init.sql | 0 .../migrations}/002_users_is_admin.sql | 0 profile.go => src/profile.go | 0 ratelimit.go => src/ratelimit.go | 0 ratelimit_test.go => src/ratelimit_test.go | 0 render.go => src/render.go | 0 reports.go => src/reports.go | 0 reviews.go => src/reviews.go | 0 songs.go => src/songs.go | 0 songs_test.go => src/songs_test.go | 0 {static => src/static}/favicon.svg | 0 {static => src/static}/fonts/oswald.woff2 | Bin {static => src/static}/htmx.min.js | 0 {static => src/static}/lyrics.js | 0 {static => src/static}/player.js | 0 {static => src/static}/style.css | 0 stats.go => src/stats.go | 0 stats_test.go => src/stats_test.go | 0 submit.go => src/submit.go | 0 submit_test.go => src/submit_test.go | 0 {templates => src/templates}/admin.html | 0 {templates => src/templates}/admin_reports.html | 0 {templates => src/templates}/layout.html | 0 {templates => src/templates}/login.html | 0 {templates => src/templates}/partials/player.html | 0 {templates => src/templates}/profile.html | 0 {templates => src/templates}/queue.html | 0 {templates => src/templates}/register.html | 0 {templates => src/templates}/report.html | 0 {templates => src/templates}/song.html | 0 {templates => src/templates}/songs.html | 0 {templates => src/templates}/stats.html | 0 {templates => src/templates}/submission.html | 0 {templates => src/templates}/submit.html | 0 {testdata => src/testdata}/ytdlp-noose.json | 0 48 files changed, 9 insertions(+), 3 deletions(-) rename admin.go => src/admin.go (100%) rename auth.go => src/auth.go (100%) rename auth_test.go => src/auth_test.go (100%) rename lyrics.go => src/lyrics.go (100%) rename lyrics_test.go => src/lyrics_test.go (100%) rename main.go => src/main.go (100%) rename main_test.go => src/main_test.go (100%) rename media.go => src/media.go (100%) rename media_test.go => src/media_test.go (100%) rename migrate.go => src/migrate.go (100%) rename {migrations => src/migrations}/001_init.sql (100%) rename {migrations => src/migrations}/002_users_is_admin.sql (100%) rename profile.go => src/profile.go (100%) rename ratelimit.go => src/ratelimit.go (100%) rename ratelimit_test.go => src/ratelimit_test.go (100%) rename render.go => src/render.go (100%) rename reports.go => src/reports.go (100%) rename reviews.go => src/reviews.go (100%) rename songs.go => src/songs.go (100%) rename songs_test.go => src/songs_test.go (100%) rename {static => src/static}/favicon.svg (100%) rename {static => src/static}/fonts/oswald.woff2 (100%) rename {static => src/static}/htmx.min.js (100%) rename {static => src/static}/lyrics.js (100%) rename {static => src/static}/player.js (100%) rename {static => src/static}/style.css (100%) rename stats.go => src/stats.go (100%) rename stats_test.go => src/stats_test.go (100%) rename submit.go => src/submit.go (100%) rename submit_test.go => src/submit_test.go (100%) rename {templates => src/templates}/admin.html (100%) rename {templates => src/templates}/admin_reports.html (100%) rename {templates => src/templates}/layout.html (100%) rename {templates => src/templates}/login.html (100%) rename {templates => src/templates}/partials/player.html (100%) rename {templates => src/templates}/profile.html (100%) rename {templates => src/templates}/queue.html (100%) rename {templates => src/templates}/register.html (100%) rename {templates => src/templates}/report.html (100%) rename {templates => src/templates}/song.html (100%) rename {templates => src/templates}/songs.html (100%) rename {templates => src/templates}/stats.html (100%) rename {templates => src/templates}/submission.html (100%) rename {templates => src/templates}/submit.html (100%) rename {testdata => src/testdata}/ytdlp-noose.json (100%) diff --git a/Dockerfile b/Dockerfile index e18db23..b374281 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION}" -o /levyraati . +RUN CGO_ENABLED=0 go build -ldflags "-X main.version=${VERSION}" -o /levyraati ./src FROM alpine:3.24 # yt-dlp rots against YouTube. Alpine's active branch tracks it closely (3.24 carries the current diff --git a/Makefile b/Makefile index d4c8753..322ae61 100644 --- a/Makefile +++ b/Makefile @@ -16,8 +16,10 @@ vet: test: go test ./... +# -o is required, not stylistic: the package lives in ./src, and without it `go build` would try to +# write a binary named "src" over the directory. build: - go build -o levyraati26-go . + go build -o levyraati26-go ./src # Templates and migrations are embedded, so seeing a change means rebuilding. run: build diff --git a/README.md b/README.md index 189630c..bdac664 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,13 @@ in as that account and mint invites for everyone else. The two variables are rea ```sh export ADMIN_EMAIL=dev@example.com ADMIN_PASSWORD=dev SECURE_COOKIES=false -go run . +go run ./src ``` +The package lives in `src/`, together with the `templates/`, `static/` and `migrations/` it embeds — +`//go:embed` cannot reach outside its own directory, so the assets live beside the code that reads +them. `storage/` stays at the root, since it is runtime data rather than source. + Requires Go 1.27+, plus `ffmpeg`, `ffprobe`, and `yt-dlp` on `PATH`. There is nothing to start first: the database is a file under `./storage`, created on the first run. diff --git a/admin.go b/src/admin.go similarity index 100% rename from admin.go rename to src/admin.go diff --git a/auth.go b/src/auth.go similarity index 100% rename from auth.go rename to src/auth.go diff --git a/auth_test.go b/src/auth_test.go similarity index 100% rename from auth_test.go rename to src/auth_test.go diff --git a/lyrics.go b/src/lyrics.go similarity index 100% rename from lyrics.go rename to src/lyrics.go diff --git a/lyrics_test.go b/src/lyrics_test.go similarity index 100% rename from lyrics_test.go rename to src/lyrics_test.go diff --git a/main.go b/src/main.go similarity index 100% rename from main.go rename to src/main.go diff --git a/main_test.go b/src/main_test.go similarity index 100% rename from main_test.go rename to src/main_test.go diff --git a/media.go b/src/media.go similarity index 100% rename from media.go rename to src/media.go diff --git a/media_test.go b/src/media_test.go similarity index 100% rename from media_test.go rename to src/media_test.go diff --git a/migrate.go b/src/migrate.go similarity index 100% rename from migrate.go rename to src/migrate.go diff --git a/migrations/001_init.sql b/src/migrations/001_init.sql similarity index 100% rename from migrations/001_init.sql rename to src/migrations/001_init.sql diff --git a/migrations/002_users_is_admin.sql b/src/migrations/002_users_is_admin.sql similarity index 100% rename from migrations/002_users_is_admin.sql rename to src/migrations/002_users_is_admin.sql diff --git a/profile.go b/src/profile.go similarity index 100% rename from profile.go rename to src/profile.go diff --git a/ratelimit.go b/src/ratelimit.go similarity index 100% rename from ratelimit.go rename to src/ratelimit.go diff --git a/ratelimit_test.go b/src/ratelimit_test.go similarity index 100% rename from ratelimit_test.go rename to src/ratelimit_test.go diff --git a/render.go b/src/render.go similarity index 100% rename from render.go rename to src/render.go diff --git a/reports.go b/src/reports.go similarity index 100% rename from reports.go rename to src/reports.go diff --git a/reviews.go b/src/reviews.go similarity index 100% rename from reviews.go rename to src/reviews.go diff --git a/songs.go b/src/songs.go similarity index 100% rename from songs.go rename to src/songs.go diff --git a/songs_test.go b/src/songs_test.go similarity index 100% rename from songs_test.go rename to src/songs_test.go diff --git a/static/favicon.svg b/src/static/favicon.svg similarity index 100% rename from static/favicon.svg rename to src/static/favicon.svg diff --git a/static/fonts/oswald.woff2 b/src/static/fonts/oswald.woff2 similarity index 100% rename from static/fonts/oswald.woff2 rename to src/static/fonts/oswald.woff2 diff --git a/static/htmx.min.js b/src/static/htmx.min.js similarity index 100% rename from static/htmx.min.js rename to src/static/htmx.min.js diff --git a/static/lyrics.js b/src/static/lyrics.js similarity index 100% rename from static/lyrics.js rename to src/static/lyrics.js diff --git a/static/player.js b/src/static/player.js similarity index 100% rename from static/player.js rename to src/static/player.js diff --git a/static/style.css b/src/static/style.css similarity index 100% rename from static/style.css rename to src/static/style.css diff --git a/stats.go b/src/stats.go similarity index 100% rename from stats.go rename to src/stats.go diff --git a/stats_test.go b/src/stats_test.go similarity index 100% rename from stats_test.go rename to src/stats_test.go diff --git a/submit.go b/src/submit.go similarity index 100% rename from submit.go rename to src/submit.go diff --git a/submit_test.go b/src/submit_test.go similarity index 100% rename from submit_test.go rename to src/submit_test.go diff --git a/templates/admin.html b/src/templates/admin.html similarity index 100% rename from templates/admin.html rename to src/templates/admin.html diff --git a/templates/admin_reports.html b/src/templates/admin_reports.html similarity index 100% rename from templates/admin_reports.html rename to src/templates/admin_reports.html diff --git a/templates/layout.html b/src/templates/layout.html similarity index 100% rename from templates/layout.html rename to src/templates/layout.html diff --git a/templates/login.html b/src/templates/login.html similarity index 100% rename from templates/login.html rename to src/templates/login.html diff --git a/templates/partials/player.html b/src/templates/partials/player.html similarity index 100% rename from templates/partials/player.html rename to src/templates/partials/player.html diff --git a/templates/profile.html b/src/templates/profile.html similarity index 100% rename from templates/profile.html rename to src/templates/profile.html diff --git a/templates/queue.html b/src/templates/queue.html similarity index 100% rename from templates/queue.html rename to src/templates/queue.html diff --git a/templates/register.html b/src/templates/register.html similarity index 100% rename from templates/register.html rename to src/templates/register.html diff --git a/templates/report.html b/src/templates/report.html similarity index 100% rename from templates/report.html rename to src/templates/report.html diff --git a/templates/song.html b/src/templates/song.html similarity index 100% rename from templates/song.html rename to src/templates/song.html diff --git a/templates/songs.html b/src/templates/songs.html similarity index 100% rename from templates/songs.html rename to src/templates/songs.html diff --git a/templates/stats.html b/src/templates/stats.html similarity index 100% rename from templates/stats.html rename to src/templates/stats.html diff --git a/templates/submission.html b/src/templates/submission.html similarity index 100% rename from templates/submission.html rename to src/templates/submission.html diff --git a/templates/submit.html b/src/templates/submit.html similarity index 100% rename from templates/submit.html rename to src/templates/submit.html diff --git a/testdata/ytdlp-noose.json b/src/testdata/ytdlp-noose.json similarity index 100% rename from testdata/ytdlp-noose.json rename to src/testdata/ytdlp-noose.json