go-strfs/README.md

33 lines
834 B
Markdown
Raw Normal View History

2022-12-14 03:36:32 +00:00
# go-strfs
Package **strfs** provides a virtual file-system, whre a `fs.File` can be created from a Go `string`.
## Documention
2024-08-25 12:31:04 +00:00
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-strfs
2022-12-14 03:36:32 +00:00
2024-08-25 12:31:04 +00:00
[![GoDoc](https://godoc.org/github.com/reiver/go-strfs?status.svg)](https://godoc.org/github.com/reiver/go-strfs)
2022-12-14 12:33:57 +00:00
## Example fs.File
Here is an example of turning a Go `string` into a `fs.File`:
```go
2024-08-25 12:31:04 +00:00
import "github.com/reiver/go-strfs"
2022-12-14 12:33:57 +00:00
// ...
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),
2022-12-14 12:33:57 +00:00
}
var file fs.FS = &regularfile
```