{"id":13564510,"url":"https://github.com/risor-io/risor","last_synced_at":"2025-05-14T21:05:48.530Z","repository":{"id":62867466,"uuid":"561389689","full_name":"risor-io/risor","owner":"risor-io","description":"Fast and flexible scripting for Go developers and DevOps.","archived":false,"fork":false,"pushed_at":"2025-05-05T12:08:25.000Z","size":21094,"stargazers_count":794,"open_issues_count":15,"forks_count":34,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-11T20:44:42.037Z","etag":null,"topics":["developer-tools","devops","go","golang","scripting"],"latest_commit_sha":null,"homepage":"https://risor.io","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/risor-io.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-03T15:30:27.000Z","updated_at":"2025-05-06T07:07:00.000Z","dependencies_parsed_at":"2023-12-21T00:05:23.821Z","dependency_job_id":"814c726e-eaae-464c-85c2-e81062cc60ce","html_url":"https://github.com/risor-io/risor","commit_stats":null,"previous_names":["risor-io/risor","myzie/tamarin","cloudcmds/tamarin"],"tags_count":197,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risor-io%2Frisor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risor-io%2Frisor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risor-io%2Frisor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/risor-io%2Frisor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/risor-io","download_url":"https://codeload.github.com/risor-io/risor/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227611,"owners_count":22035669,"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":["developer-tools","devops","go","golang","scripting"],"created_at":"2024-08-01T13:01:32.381Z","updated_at":"2025-05-14T21:05:48.501Z","avatar_url":"https://github.com/risor-io.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003ch1\u003e\u003cimg src=\"https://github.com/risor-io/risor/raw/main/static/images/risor-logo-nopad.png\" alt=\"Risor logo\" height=\"64\" valign=\"middle\"\u003e Risor\u003c/h1\u003e\n\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/risor-io/risor/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/risor-io/risor/tree/main)\n[![Apache-2.0 license](https://img.shields.io/badge/License-Apache%202.0-brightgreen.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Go.Dev reference](https://img.shields.io/badge/go.dev-reference-blue?logo=go\u0026logoColor=white)](https://pkg.go.dev/github.com/risor-io/risor)\n[![Go Report Card](https://goreportcard.com/badge/github.com/risor-io/risor?style=flat-square)](https://goreportcard.com/report/github.com/risor-io/risor)\n[![Releases](https://img.shields.io/github/release/risor-io/risor/all.svg?style=flat-square)](https://github.com/risor-io/risor/releases)\n\nRisor is a fast and flexible scripting language for Go developers and DevOps.\n\nIts modules integrate the Go standard library, making it easy to use functions\nthat you're already familiar with as a Go developer.\n\nScripts are compiled to bytecode and then run on a lightweight virtual machine.\nRisor is written in pure Go.\n\n## Documentation\n\nDocumentation is available at [risor.io](https://risor.io).\n\nYou might also want to try evaluating Risor scripts [from your browser](https://risor.io/#editor).\n\n## Syntax Example\n\nHere's a short example of how Risor feels like a hybrid of Go and Python. This\ndemonstrates using Risor's pipe expressions to apply a series of transformations:\n\n```go\narray := [\"gophers\", \"are\", \"burrowing\", \"rodents\"]\n\nsentence := array | strings.join(\" \") | strings.to_upper\n\nprint(sentence)\n```\n\nOutput:\n\n```\nGOPHERS ARE BURROWING RODENTS\n```\n\n## Getting Started\n\nYou might want to head over to [Getting Started](https://risor.io/docs) in the\ndocumentation. That said, here are tips for both the CLI and the Go library.\n\n### Risor CLI and REPL\n\nIf you use [Homebrew](https://brew.sh/), you can install the\n[Risor](https://formulae.brew.sh/formula/risor) CLI as follows:\n\n```\nbrew install risor\n```\n\nHaving done that, just run `risor` to start the CLI or `risor -h` to see\nusage information.\n\nExecute a code snippet directly using the `-c` option:\n\n```go\nrisor -c \"time.now()\"\n```\n\nStart the REPL by running `risor` with no options.\n\n### Build and Install the CLI from Source\n\nBuild the CLI from source as follows:\n\n```bash\ngit clone git@github.com:risor-io/risor.git\ncd risor/cmd/risor\ngo install -tags aws,k8s,vault .\n```\n\n### Go Library\n\nUse `go get` to add Risor as a dependency of your Go program:\n\n```bash\ngo get github.com/risor-io/risor@v1.7.0\n```\n\nHere's an example of using the `risor.Eval` API to evaluate some code:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/risor-io/risor\"\n)\n\nfunc main() {\n\tctx := context.Background()\n\tscript := \"math.sqrt(input)\"\n\tresult, err := risor.Eval(ctx, script, risor.WithGlobal(\"input\", 4))\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfmt.Println(\"The square root of 4 is:\", result)\n}\n```\n\n## Built-in Functions and Modules\n\n30+ built-in functions are included and are documented [here](https://risor.io/docs/builtins).\n\nModules are included that generally wrap the equivalent Go package. For example,\nthere is direct correspondence between `base64`, `bytes`, `filepath`, `json`, `math`, `os`,\n`rand`, `regexp`, `strconv`, `strings`, and `time` Risor modules and\nthe Go standard library.\n\nRisor modules that are beyond the Go standard library currently include\n`aws`, `carbon`, `cli`, `jmespath`, `pgx`, `uuid`, `vault`, `k8s`, and more.\n\n## Go Interface\n\nIt is trivial to embed Risor in your Go program in order to evaluate scripts\nthat have access to arbitrary Go structs and other types.\n\nThe simplest way to use Risor is to call the `Eval` function and provide the script source code.\nThe result is returned as a Risor object:\n\n```go\nresult, err := risor.Eval(ctx, \"math.min([5, 2, 7])\")\n// result is 2, as an *object.Int\n```\n\nProvide input to the script using Risor options:\n\n```go\nresult, err := risor.Eval(ctx, \"input | strings.to_upper\", risor.WithGlobal(\"input\", \"hello\"))\n// result is \"HELLO\", as an *object.String\n```\n\nUse the same mechanism to inject a struct. You can then access fields or call\nmethods on the struct from the Risor script:\n\n```go\ntype Example struct {\n    Message string\n}\nexample := \u0026Example{\"abc\"}\nresult, err := risor.Eval(ctx, \"len(ex.Message)\", risor.WithGlobal(\"ex\", example))\n// result is 3, as an *object.Int\n```\n\n## Dependencies and Build Options\n\nRisor is designed to have minimal external dependencies in its core libraries.\nYou can choose to opt into various add-on modules if they are of value in your\napplication. The modules are present in this same Git repository, but must be\ninstalled with `go get` as separate dependencies:\n\n| Name           | Path                                               | Go Get Command                                                   |\n| -------------- | -------------------------------------------------- | ---------------------------------------------------------------- |\n| aws            | [modules/aws](./modules/aws)                       | `go get github.com/risor-io/risor/modules/aws@v1.7.0`            |\n| bcrypt         | [modules/bcrypt](./modules/bcrypt)                 | `go get github.com/risor-io/risor/modules/bcrypt@v1.7.0`         |\n| carbon         | [modules/carbon](./modules/carbon)                 | `go get github.com/risor-io/risor/modules/carbon@v1.7.0`         |\n| cli            | [modules/cli](./modules/cli)                       | `go get github.com/risor-io/risor/modules/cli@v1.7.0`            |\n| goquery        | [modules/goquery](./modules/goquery)               | `go get github.com/risor-io/risor/modules/goquery@v1.7.0`        |\n| htmltomarkdown | [modules/htmltomarkdown](./modules/htmltomarkdown) | `go get github.com/risor-io/risor/modules/htmltomarkdown@v1.7.0` |\n| image          | [modules/image](./modules/image)                   | `go get github.com/risor-io/risor/modules/image@v1.7.0`          |\n| jmespath       | [modules/jmespath](./modules/jmespath)             | `go get github.com/risor-io/risor/modules/jmespath@v1.7.0`       |\n| k8s            | [modules/kubernetes](./modules/kubernetes)         | `go get github.com/risor-io/risor/modules/kubernetes@v1.7.0`     |\n| pgx            | [modules/pgx](./modules/pgx)                       | `go get github.com/risor-io/risor/modules/pgx@v1.7.0`            |\n| s3fs           | [os/s3fs](./os/s3fs)                               | `go get github.com/risor-io/risor/os/s3fs@v1.7.0`                |\n| sched          | [modules/sched](./modules/sched)                   | `go get github.com/risor-io/risor/modules/sched@v1.7.0`          |\n| semver         | [modules/semver](./modules/semver)                 | `go get github.com/risor-io/risor/modules/semver@v1.7.0`         |\n| shlex          | [modules/shlex](./modules/shlex)                   | `go get github.com/risor-io/risor/modules/shlex@v1.7.0`          |\n| sql            | [modules/sql](./modules/sql)                       | `go get github.com/risor-io/risor/modules/sql@v1.7.0`            |\n| template       | [modules/template](./modules/template)             | `go get github.com/risor-io/risor/modules/template@v1.7.0`       |\n| uuid           | [modules/uuid](./modules/uuid)                     | `go get github.com/risor-io/risor/modules/uuid@v1.7.0`           |\n| vault          | [modules/vault](./modules/vault)                   | `go get github.com/risor-io/risor/modules/vault@v1.7.0`          |\n\nThese add-ons are included by default when using the Risor CLI. However, when\nbuilding Risor into your own program, you'll need to opt-in using `go get` as\ndescribed above and then add the modules as globals in Risor scripts as follows:\n\n```go\nimport (\n    \"github.com/risor-io/risor\"\n    \"github.com/risor-io/risor/modules/aws\"\n    \"github.com/risor-io/risor/modules/image\"\n    \"github.com/risor-io/risor/modules/pgx\"\n    \"github.com/risor-io/risor/modules/uuid\"\n)\n\nfunc main() {\n    source := `\"nice modules!\"`\n    result, err := risor.Eval(ctx, source,\n        risor.WithGlobals(map[string]any{\n            \"aws\":   aws.Module(),\n            \"image\": image.Module(),\n            \"pgx\":   pgx.Module(),\n            \"uuid\":  uuid.Module(),\n        }))\n    // ...\n}\n```\n\n## Syntax Highlighting\n\nA [Risor VSCode extension](https://marketplace.visualstudio.com/items?itemName=CurtisMyzie.risor-language)\nis already available which currently only offers syntax highlighting.\n\nYou can also make use of the [Risor TextMate grammar](./vscode/syntaxes/risor.grammar.json).\n\n## Benchmarking\n\nThere are two Makefile commands that assist with benchmarking and CPU profiling:\n\n```\nmake bench\nmake pprof\n```\n\n## Contributing\n\nRisor is intended to be a community project. You can lend a hand in various ways:\n\n- Please ask questions and share ideas in [GitHub discussions](https://github.com/risor-io/risor/discussions)\n- Share Risor on any social channels that may appreciate it\n- Open GitHub issue or a pull request for any bugs you find\n- Star the project on GitHub\n\n### Contributing New Modules\n\nAdding modules to Risor is a great way to get involved with the project.\nSee [this guide](https://risor.io/docs/contributing_modules) for details.\n\n## Community Projects\n\n- [RSX: Package Risor Scripts into Go Binaries](https://github.com/rubiojr/rsx)\n- [Awesome Risor](https://github.com/rubiojr/awesome-risor)\n- [tree-sitter-risor](https://github.com/applejag/tree-sitter-risor)\n- [bench_go_scripting](https://github.com/mna/bench_go_scripting)\n\n## Discuss the Project\n\nPlease visit the [GitHub discussions](https://github.com/risor-io/risor/discussions)\npage to share thoughts and questions.\n\nThere is also a `#risor` Slack channel on the [Gophers Slack](https://gophers.slack.com).\n\n## Credits\n\nCheck [CREDITS.md](./CREDITS.md).\n\n## License\n\nReleased under the [Apache License, Version 2.0](./LICENSE).\n\nCopyright Curtis Myzie / [github.com/myzie](https://github.com/myzie).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisor-io%2Frisor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frisor-io%2Frisor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frisor-io%2Frisor/lists"}