Skip to content

Instantly share code, notes, and snippets.

@bussiere
Created December 8, 2018 10:15
Show Gist options
  • Save bussiere/2e24efb344c672a30eb8e8d171cea4c3 to your computer and use it in GitHub Desktop.
Save bussiere/2e24efb344c672a30eb8e8d171cea4c3 to your computer and use it in GitHub Desktop.
starlight python golang
package main
import (
"fmt"
"github.com/starlight-go/starlight"
)
type contact struct {
Name string
}
func main() {
c := &contact{Name: "Bob"}
globals := map[string]interface{}{
"contact":c,
"Println":fmt.Println,
}
script := []byte(`
contact.Name = "Phil"
Println("hello " + contact.Name)
test='titi'
`)
// errors will tell you about syntax/runtime errors.
result, err := starlight.Eval(script, globals, nil)
fmt.Println(err)
fmt.Println(result)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment