Package strfs provides a virtual file-system, where a fs.File can be created from a Go string, for the Go programming language.
Find a file
2025-10-04 00:01:44 -07:00
content.go pointer receiver 2025-10-04 00:01:44 -07:00
content_test.go codeberg 2025-09-30 05:47:46 -07:00
errors.go io.Seeker 2025-10-03 23:51:30 -07:00
fileinfo.go initial commits 2022-12-14 09:50:42 -08:00
go.mod codeberg 2025-09-30 05:47:46 -07:00
go.sum sourcecode.social -> github.com 2024-08-25 05:31:04 -07:00
LICENSE changelog.ca -> reiver.link 2024-08-25 05:27:57 -07:00
README.md correction 2025-09-30 06:16:03 -07:00
regularfile.go pointer receiver 2025-10-04 00:01:44 -07:00
regularfile_test.go codeberg 2025-09-30 05:47:46 -07:00

go-strfs

Package strfs provides a virtual file-system, whre a fs.File can be created from a Go string.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-strfs

GoDoc

Example fs.File

Here is an example of turning a Go string into a fs.File:

import "codeberg.org/reiver/go-strfs"

// ...

var s string = "<!DOCTYPE html>"+"\n"+"<html><body>Hello world!</body></html>"

var content strfs.Content = strfs.CreateContent(s)

var regularfile strfs.RegularFile = strfs.RegularFile{
	FileContent: content,
	FileName:    "helloworld.html",
	FileModTime: time.Date(2022, 12, 12, 10, 30, 14, 2, time.UTC),
}

var file fs.File = &regularfile

Import

To import package strfs use import code like the following:

import "codeberg.org/reiver/go-strfs"

Installation

To install package strfs do the following:

GOPROXY=direct go get codeberg.org/reiver/go-strfs

Author

Package strfs was written by Charles Iliya Krempeaux