diff --git a/Makefile b/Makefile index d2f9a51cb4..0b1663f41d 100644 --- a/Makefile +++ b/Makefile @@ -187,7 +187,7 @@ golangci_lint_goarch ?= $(shell go env GOARCH) .PHONY: lint lint: $(golangci_lint_path) - @GOARCH=$(golangci_lint_goarch) CGO_ENABLED=0 $(golangci_lint_path) run --timeout 5m + @GOARCH=$(golangci_lint_goarch) CGO_ENABLED=0 $(golangci_lint_path) run --timeout 5m -E testableexamples .PHONY: format format: diff --git a/experimental/close_example_test.go b/experimental/close_example_test.go index 59eb08e89c..ebb701c29c 100644 --- a/experimental/close_example_test.go +++ b/experimental/close_example_test.go @@ -12,7 +12,7 @@ var ctx context.Context func Example_closeNotifier() { closeCh := make(chan struct{}) ctx = experimental.WithCloseNotifier( - ctx, + context.Background(), experimental.CloseNotifyFunc(func(context.Context, uint32) { close(closeCh) }), ) @@ -24,4 +24,6 @@ func Example_closeNotifier() { default: // do some more work with the module } + + // Output: } diff --git a/experimental/sysfs/config_example_test.go b/experimental/sysfs/config_example_test.go index 6c54a449fe..021a3c491d 100644 --- a/experimental/sysfs/config_example_test.go +++ b/experimental/sysfs/config_example_test.go @@ -20,6 +20,8 @@ func ExampleAdaptFS() { moduleConfig = wazero.NewModuleConfig(). WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(root, "/")) + + // Output: } // This example shows how to configure a sysfs.DirFS @@ -28,6 +30,8 @@ func ExampleDirFS() { moduleConfig = wazero.NewModuleConfig(). WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(root, "/")) + + // Output: } // This example shows how to configure a sysfs.ReadFS @@ -37,4 +41,6 @@ func ExampleReadFS() { moduleConfig = wazero.NewModuleConfig(). WithFSConfig(wazero.NewFSConfig().(sysfs.FSConfig).WithSysFSMount(readOnly, "/")) + + // Output: } diff --git a/fsconfig_example_test.go b/fsconfig_example_test.go index 882e152b49..0315c8c1b0 100644 --- a/fsconfig_example_test.go +++ b/fsconfig_example_test.go @@ -24,4 +24,6 @@ func Example_fsConfig() { moduleConfig = wazero.NewModuleConfig(). // Make "index.html" accessible to the guest as "/index.html". WithFSConfig(wazero.NewFSConfig().WithFSMount(rooted, "/")) + + // Output: } diff --git a/sys/stat_example_test.go b/sys/stat_example_test.go deleted file mode 100644 index 9b75eb58cf..0000000000 --- a/sys/stat_example_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package sys_test - -import ( - "io/fs" - "math" - - "github.com/tetratelabs/wazero/sys" -) - -var ( - walltime sys.Walltime - info fs.FileInfo - st sys.Stat_t -) - -// This shows typical conversions to sys.EpochNanos type, for sys.Stat_t fields. -func Example_epochNanos() { - // Convert an adapted fs.File's fs.FileInfo to Mtim. - st.Mtim = info.ModTime().UnixNano() - - // Generate a fake Atim using sys.Walltime passed to wazero.ModuleConfig. - sec, nsec := walltime() - st.Atim = sec*1e9 + int64(nsec) -} - -type fileInfoWithSys struct { - fs.FileInfo - st sys.Stat_t -} - -func (f *fileInfoWithSys) Sys() any { return &f.st } - -// This shows how to return data not defined in fs.FileInfo, notably sys.Inode. -func Example_inode() { - st := sys.NewStat_t(info) - st.Ino = math.MaxUint64 // arbitrary non-zero value - info = &fileInfoWithSys{info, st} -}