forked from starlight-go/starlight
-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Is it possible to pass globals to loaded scripts?
My code (main.go):
package main
import (
"fmt"
"log"
"os"
"github.com/1set/starlight"
)
func dothings() error {
globals := map[string]interface{}{
"A": func(in string) { fmt.Println(in) },
}
wd, err := os.Getwd()
if err != nil {
return err
}
c := starlight.New(wd)
_, err = c.Run("main.star", globals)
return err
}
func main() {
if err := dothings(); err != nil {
log.Fatal(err)
}
}the file main.star:
load("script.star","foo")
foo()and script.star:
def foo():
A("hello")The goal is to define the globals once and then access in the loaded scripts . Is this possible?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels