repositorypackage
0.0.0-20251010133025-e981cb72cad3
Repository: https://github.com/hattya/otto.module.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
otto.module
An implementation of the Node.js module loading system for otto.
Installation
$ go get github.com/hattya/otto.module
Usage
package main
import (
"fmt"
"os"
"github.com/hattya/otto.module"
)
func main() {
vm, err := module.New()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
file := new(module.FileLoader)
folder := &module.FolderLoader{File: file}
vm.Register(file)
vm.Register(folder)
vm.Register(&module.NodeModulesLoader{
File: file,
Folder: folder,
})
vm.Run(`
var path = require('path');
console.log(path.extname('module.go'));
`)
}
License
otto.module is distributed under the terms of the MIT License.