Skip to content

Add doc comments to clarify usage of File related methods and leading slash handling#2928

Merged
aldas merged 1 commit intolabstack:masterfrom
aldas:filesystem_docs
Mar 29, 2026
Merged

Add doc comments to clarify usage of File related methods and leading slash handling#2928
aldas merged 1 commit intolabstack:masterfrom
aldas:filesystem_docs

Conversation

@aldas
Copy link
Copy Markdown
Contributor

@aldas aldas commented Mar 29, 2026

Add doc comments to clarify usage of File related methods and leading slash handling

Relates to #2922 (comment)

Example:

package main

import (
	"embed"

	"github.com/labstack/echo/v5"
)

//go:embed dist/*
var efs embed.FS

func main() {
	e := echo.New()
	e.Filesystem = efs

	e.File("/test", "dist/private.txt") // <--- file path must not have a leading slash

	if err := e.Start(":8080"); err != nil {
		e.Logger.Error("failed to start server", "error", err)
	}
}

and

package main

import (
	"os"

	"github.com/labstack/echo/v5"
)

func main() {
	e := echo.New()
	e.Filesystem = os.DirFS("/")

	e.File("/test.jpg", "opt/app/assets/test.jpg") // <--- file path must not have a leading slash

	if err := e.Start(":8080"); err != nil {
		e.Logger.Error("failed to start server", "error", err)
	}
}

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.01%. Comparing base (19364e2) to head (3d2e6b3).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2928   +/-   ##
=======================================
  Coverage   93.01%   93.01%           
=======================================
  Files          43       43           
  Lines        4496     4498    +2     
=======================================
+ Hits         4182     4184    +2     
  Misses        196      196           
  Partials      118      118           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aldas aldas merged commit a0e5ff7 into labstack:master Mar 29, 2026
10 checks passed
@aldas aldas deleted the filesystem_docs branch March 29, 2026 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant