{"id":13515074,"url":"https://github.com/novalagung/go-eek","last_synced_at":"2026-03-16T18:02:13.123Z","repository":{"id":77555351,"uuid":"205790237","full_name":"novalagung/go-eek","owner":"novalagung","description":"Blazingly fast and safe Go evaluation library, created on top of Go pkg/plugin package","archived":false,"fork":false,"pushed_at":"2020-04-17T21:42:46.000Z","size":124,"stargazers_count":38,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-29T21:05:25.947Z","etag":null,"topics":["evaluation","go","golang"],"latest_commit_sha":null,"homepage":"http://godoc.org/github.com/novalagung/go-eek","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/novalagung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-09-02T06:24:04.000Z","updated_at":"2023-03-13T01:51:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"9063c21c-7e4e-4893-b03c-68ca649874bf","html_url":"https://github.com/novalagung/go-eek","commit_stats":{"total_commits":33,"total_committers":2,"mean_commits":16.5,"dds":0.09090909090909094,"last_synced_commit":"32291c7c1d8e5a9a726e3613f40f097cf200ce14"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novalagung%2Fgo-eek","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novalagung%2Fgo-eek/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novalagung%2Fgo-eek/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/novalagung%2Fgo-eek/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/novalagung","download_url":"https://codeload.github.com/novalagung/go-eek/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246531968,"owners_count":20792736,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["evaluation","go","golang"],"created_at":"2024-08-01T05:01:06.006Z","updated_at":"2026-03-16T18:02:13.035Z","avatar_url":"https://github.com/novalagung.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# go-eek\n\nBlazingly fast and safe go evaluation library, created on top of [Go `pkg/plugin` package](https://golang.org/pkg/plugin/).\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/novalagung/go-eek?nocache=1)](https://goreportcard.com/report/github.com/novalagung/go-eek?nocache=1)\n[![Build Status](https://travis-ci.org/novalagung/go-eek.svg?branch=master)](https://travis-ci.org/novalagung/go-eek)\n[![Coverage Status](https://coveralls.io/repos/github/novalagung/go-eek/badge.svg?branch=master)](https://coveralls.io/github/novalagung/go-eek?branch=master)\n\nOn go-eek, the eval expression is encapsulated into a single function, and stored in a go file. The go file later on will be build into a plugin file (`*.so` file). And then next, for every evaluation call, it will happen in the plugin file. This is why go-eek is insanely fast.\n\ngo-eek accept standar Go syntax expression.\n\n## Example\n\n#### Simple Example\n\n```go\nimport . \"github.com/novalagung/go-eek\"\n\n// create new eek object and name it\nobj := New()\nobj.SetName(\"simple operation\")\n\n// define variables (and default value of particular variable if available)\nobj.DefineVariable(Var{Name: \"VarA\", Type: \"int\"})\nobj.DefineVariable(Var{Name: \"VarB\", Type: \"float64\", DefaultValue: 10.5})\n\n// specify the evaluation expression in go standard syntax\nobj.PrepareEvaluation(`\n    castedVarA := float64(VarA)\n    VarC := castedVarA + VarB\n    return VarC\n`)\n\n// build only need to happen once\nerr := obj.Build()\nif err != nil {\n    log.Fatal(err)\n}\n\n// evaluate!\noutput1, _ := obj.Evaluate(ExecVar{ \"VarA\": 9 })\nfmt.Println(\"with VarA = 9, the result will be\", output1)\noutput2, _ := obj.Evaluate(ExecVar{ \"VarA\": 12, \"VarB\": 12.4 })\nfmt.Println(\"with VarA = 12 and VarB = 12.4, the result will be\", output2)\n```\n\n#### More Complex Example\n\n```go\nobj := eek.New(\"evaluation with 3rd party library\")\n\nobj.ImportPackage(\"fmt\")\nobj.ImportPackage(\"github.com/novalagung/gubrak\")\n\nobj.DefineVariable(eek.Var{Name: \"VarMessageWin\", Type: \"string\", DefaultValue: \"Congrats! You win the lottery!\"})\nobj.DefineVariable(eek.Var{Name: \"VarMessageLose\", Type: \"string\", DefaultValue: \"You lose\"})\nobj.DefineVariable(eek.Var{Name: \"VarYourLotteryCode\", Type: \"int\"})\nobj.DefineVariable(eek.Var{Name: \"VarRepeatUntil\", Type: \"int\", DefaultValue: 5})\n\nobj.PrepareEvaluation(`\n    generateRandomNumber := func() int {\n        return gubrak.RandomInt(0, 10)\n    }\n\n    i := 0\n    for i \u003c VarRepeatUntil {\n        if generateRandomNumber() == VarYourLotteryCode {\n            return fmt.Sprintf(\"%s after %d tried\", VarMessageWin, i + 1)\n        }\n\n        i++\n    }\n    \n    return VarMessageLose\n`)\n\nerr := obj.Build()\nif err != nil {\n    log.Fatal(err)\n}\n\noutput, _ = obj.Evaluate(eek.ExecVar{\n    \"VarYourLotteryCode\": 3,\n    \"VarRepeatUntil\":     10,\n})\nfmt.Println(\"output:\", output)\n```\n\n#### Arithmethic expression Example\n\n```go\nobj := New(\"aritmethic expressions\")\nobj.DefineVariable(eek.Var{Name: \"VarN\", Type: \"int\"})\nobj.DefineFunction(eek.Func{\n    Name: \"IF\",\n    BodyFunction: `\n        func(cond bool, ok, nok string) string {\n            if cond {\n                return ok\n            } else {\n                return nok\n            }\n        }\n    `,\n})\nobj.DefineFunction(eek.Func{\n    Name: \"OR\",\n    BodyFunction: `\n        func(cond1, cond2 bool) bool {\n            return cond1 || cond2\n        }\n    `,\n})\nobj.DefineFunction(eek.Func{\n    Name:         \"NOT\",\n    BodyFunction: `func(cond bool) bool { return !cond }`,\n})\nobj.PrepareEvaluation(`\n    result := IF(VarN\u003e20,IF(OR(VarN\u003e40,N==40),IF(VarN\u003e60,IF(NOT(VarN\u003e80),\"good\",IF(VarN==90,\"perfect\",\"terrific\")),\"ok\"),\"ok, but still bad\"),\"bad\")\n    \n    return result\n`)\n\nerr := obj.Build()\nif err != nil {\n    log.Fatal(err)\n}\n\noutput, _ := obj.Evaluate(eek.ExecVar{\"VarN\": 76})\nfmt.Println(output)\n```\n\nMore example available on the `*_test.go` file.\n\n## Documentation\n\n[Godoc documentation](http://godoc.org/github.com/novalagung/go-eek)\n\n## Author\n\nNoval Agung Prayog\n\n## License\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovalagung%2Fgo-eek","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnovalagung%2Fgo-eek","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnovalagung%2Fgo-eek/lists"}