-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasi: replaces existing filesystem apis with fs.FS
This adds WASIConfig.WithFS, which allows end users to leverage standard libraries that adhere to this, including OS, HTTP and embedded filesystems. For example, here's how you can allow WebAssembly modules to read "/work/home/a.txt" as "a.txt": ```go wasiConfig := wazero.NewWASIConfig(). WithFS(os.DirFS("/work/home")) wasi, err := r.InstantiateModule(wazero.WASISnapshotPreview1WithConfig(wasiConfig)) ... ``` Signed-off-by: Adrian Cole <[email protected]>
Adrian Cole
committed
Mar 18, 2022
1 parent
b160cb6
commit 840a7fd
Showing
15 changed files
with
449 additions
and
628 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
) | ||
|
||
// main is the same as cat. | ||
func main() { | ||
for _, file := range os.Args { | ||
bytes, err := os.ReadFile(file) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "couldn't read %s: %v", file, err) | ||
os.Exit(1) | ||
} | ||
|
||
// Use write to avoid needing to worry about Windows newlines. | ||
os.Stdout.Write(bytes) | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters