gagent/src/picol
2021-06-03 16:15:26 -07:00
..
examples fix: (issues/9) Worker does not support port assignment for routers (#11) 2021-05-21 23:03:50 +00:00
picol_unused fix: [CI SKIP] Converting various files to the same basic format. 2021-06-03 16:15:26 -07:00
commands.go fix: [CI SKIP] Adding export comments, most are prolly wrong. 2021-06-02 05:59:48 -07:00
LICENSE fix: (issues/9) Worker does not support port assignment for routers (#11) 2021-05-21 23:03:50 +00:00
parser.go fix: [CI SKIP] Converting various files to the same basic format. 2021-06-03 16:15:26 -07:00
picol.go fix: [CI SKIP] Well, golint did not like that. :( 2021-06-02 14:11:03 -07:00
README.md fix: (issues/9) Worker does not support port assignment for routers (#11) 2021-05-21 23:03:50 +00:00

picol.go

Original http://oldblog.antirez.com/post/picol.html

Sample use:

func CommandPuts(i *picol.Interp, argv []string, pd interface{}) (string, error) {
	if len(argv) != 2 {
		return "", fmt.Errorf("Wrong number of args for %s %s", argv[0], argv)
	}
	fmt.Println(argv[1])
	return "", nil
}
...
	interp := picol.InitInterp()
	// add core functions
	interp.RegisterCoreCommands()
	// add user function
	interp.RegisterCommand("puts", CommandPuts, nil)
	// eval
	result, err := interp.Eval(string(buf))
	if err != nil {
		fmt.Println("ERROR", err, result)
	} else {
		fmt.Println(result)
	}