Created
December 8, 2018 10:15
-
-
Save bussiere/2e24efb344c672a30eb8e8d171cea4c3 to your computer and use it in GitHub Desktop.
starlight python golang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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