fsnet

package module
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2024 License: MIT Imports: 7 Imported by: 1

README

Description

wasi network over file system, like bash /dev/tcp or /dev/udp

Usage

// see dev/tcp_test.go
func TestFsNet(t *testing.T) {
	client := &http.Client{Transport: dev.Transport}
	addr := l.Addr().String()
	addr = fmt.Sprintf("http://%s", addr)
	req := try.To1(http.NewRequest(http.MethodGet, addr, nil))
	resp := try.To1(client.Do(req))
	b := try.To1(io.ReadAll(resp.Body))
	assert.Equal(string(b), word)
}

Documentation

Index

Constants

View Source
const ModeType = fs.ModeType & ^fs.ModeDir

Variables

This section is empty.

Functions

func New

func New(dir string) fs.FS

Types

type File

type File struct {
	// contains filtered or unexported fields
}

func NewFile

func NewFile(name string, rwc io.ReadWriteCloser) *File

func (*File) Close

func (fc *File) Close() (err error)

func (*File) IsDir

func (info *File) IsDir() bool

func (*File) ModTime

func (info *File) ModTime() time.Time

func (*File) Mode

func (info *File) Mode() fs.FileMode

func (*File) Name

func (info *File) Name() string

func (*File) Read

func (fc *File) Read(p []byte) (n int, err error)

func (*File) Size

func (info *File) Size() int64

func (*File) Stat

func (fc *File) Stat() (fs.FileInfo, error)

func (*File) Sys

func (info *File) Sys() any

func (*File) Write

func (fc *File) Write(p []byte) (n int, err error)

type Net

type Net struct {
	// contains filtered or unexported fields
}

func (*Net) Open

func (n *Net) Open(name string) (f fs.File, err error)

Directories

Path Synopsis
dev
net

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL