This commit starts the migration to remove the environment package. It introduced an abstraction that is not being used, and removing it makes the code simpler to maintain. This commit removes all 'exec' related package.
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
package environment
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"io/fs"
|
|
"net"
|
|
"time"
|
|
)
|
|
|
|
// Environment represents an environment that a program can run it.
|
|
// It mostly mimics the interfaces of the [os] package.
|
|
type Environment interface {
|
|
isEnv()
|
|
|
|
GetEnv(name string) string
|
|
|
|
Stat(path string) (fs.FileInfo, error)
|
|
Lstat(path string) (fs.FileInfo, error)
|
|
|
|
Readlink(path string) (string, error)
|
|
Symlink(oldname, newname string) error
|
|
|
|
ReadDir(name string) ([]fs.DirEntry, error)
|
|
|
|
Open(path string) (fs.File, error)
|
|
Chtimes(name string, atime time.Time, mtime time.Time) error
|
|
SameFile(f1, f2 fs.FileInfo) bool
|
|
|
|
Create(path string, mode fs.FileMode) (WritableFile, error)
|
|
|
|
Mkdir(path string, mode fs.FileMode) error
|
|
MkdirAll(path string, mode fs.FileMode) error
|
|
|
|
Remove(path string) error
|
|
RemoveAll(path string) error
|
|
|
|
WalkDir(root string, fn fs.WalkDirFunc) error
|
|
|
|
Abs(path string) (string, error)
|
|
|
|
Listen(network, address string) (net.Listener, error)
|
|
DialContext(context context.Context, network, address string) (net.Conn, error)
|
|
}
|
|
|
|
type WritableFile interface {
|
|
fs.File
|
|
io.Writer
|
|
}
|
|
|
|
func init() {
|
|
var _ Environment = new(Native)
|
|
}
|