github.com/wasilibs/wazerox@v0.0.0-20240124024944-4923be63ab5f/fsconfig_example_test.go (about) 1 package wazero_test 2 3 import ( 4 "embed" 5 "io/fs" 6 "log" 7 8 wazero "github.com/wasilibs/wazerox" 9 ) 10 11 //go:embed testdata/index.html 12 var testdataIndex embed.FS 13 14 var moduleConfig wazero.ModuleConfig 15 16 // This example shows how to configure an embed.FS. 17 func Example_fsConfig() { 18 // Strip the embedded path testdata/ 19 rooted, err := fs.Sub(testdataIndex, "testdata") 20 if err != nil { 21 log.Panicln(err) 22 } 23 24 moduleConfig = wazero.NewModuleConfig(). 25 // Make "index.html" accessible to the guest as "/index.html". 26 WithFSConfig(wazero.NewFSConfig().WithFSMount(rooted, "/")) 27 }