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:
The goal is to define the globals once and then access in the loaded scripts . Is this possible?
Is it possible to pass globals to loaded scripts?
My code (main.go):
the file main.star:
and script.star:
The goal is to define the globals once and then access in the loaded scripts . Is this possible?