JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • io/fs: interfaces fs.FS, fs.File, fs.ReadFileFS

    Go SELF
    43 level,0 lecture
    We break down the io/fs package as a “language of contracts” for files: the minimal fs.FS interface (only Open), the resource model of fs.File (why Close and defer matter), the narrow contract fs.ReadFileFS, and also practice: reading files without a direct dependency on os.ReadFile, smart implementation selection via type assertion, and the key difference between path vs path/filepath (FS path with / versus OS path).
    Open
  • os.DirFS: working with a subtree as a virtual FS

    Go SELF
    43 level,1 lecture
    We break down how os.DirFS turns a directory into an implementation of the fs.FS interface, why this kind of FS uses “FS paths” internally (always with a slash /), how to read files correctly via fs.ReadFile, build names via path.Join (not filepath.Join), and how to correctly recognize “file not found” using errors.Is and fs.ErrNotExist. At the end: DirFS limitations, security nuances, and common mistakes.
    Open
  • testing/fstest — testing file logic without a disk

    Go SELF
    43 level,2 lecture
    Let’s break down how to test file logic in Go without a real disk: write functions that accept fs.FS, substitute fstest.MapFS in tests, verify error causes via errors.Is and fs.ErrNotExist, and also use fstest.TestFS as a quick “inspection” for a virtual file system.
    Open
  • fs.ValidPath and protection against path traversal

    Go SELF
    43 level,3 lecture
    We break down why a “user-provided path” is a potential vulnerability, how OS paths differ from paths inside fs.FS, what exactly fs.ValidPath checks, and why path.Clean is not a defense. We will build a safe template-reading function via os.DirFS + name validation, add a prefix-based access policy, and lock everything down with tests on fstest.MapFS, including blocking traversal attempts via ...
    Open
  • API design — accept fs.FS in functions

    Go SELF
    43 level,4 lecture
    We break down a practical approach to API design in Go: why it’s better to make functions depend on fs.FS (or the narrower fs.ReadFileFS), and push disk access to the application boundary ( main + os.DirFS). We discuss the filename contract (FS path vs OS path: path.Join and filepath.Join), validation via fs.ValidPath, “optional” capabilities via type assertion, diskless testing with fstest.MapFS, and intentional error wrapping via %w for compatibility with errors.Is/ errors.As.
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush