mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-14 12:23:43 +00:00
31 lines
438 B
Go
31 lines
438 B
Go
//go:build moejs
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/MoeForge/moejs"
|
|
"os"
|
|
)
|
|
|
|
func main() {
|
|
source := "1+1"
|
|
if len(os.Args) > 1 {
|
|
source = os.Args[1]
|
|
}
|
|
rt := moejs.NewRuntime(moejs.Options{MutableIntrinsics: true})
|
|
script, e := moejs.CompileScript("size", source)
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
v, e := rt.RunScript(script)
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
out, e := rt.ToGo(v)
|
|
if e != nil {
|
|
panic(e)
|
|
}
|
|
fmt.Println(out)
|
|
}
|