{"id":15393886,"url":"https://github.com/mitchellh/go-mruby","last_synced_at":"2026-01-11T03:52:51.134Z","repository":{"id":15042563,"uuid":"17768531","full_name":"mitchellh/go-mruby","owner":"mitchellh","description":"Go (golang) bindings to mruby.","archived":true,"fork":false,"pushed_at":"2020-08-01T15:36:50.000Z","size":134,"stargazers_count":471,"open_issues_count":18,"forks_count":35,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-01-19T19:50:44.238Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://gist.github.com/mitchellh/90029601268e59a29e64e55bab1c5bdc","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"facebook/yoga","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitchellh.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}},"created_at":"2014-03-15T05:01:38.000Z","updated_at":"2024-07-22T20:44:57.000Z","dependencies_parsed_at":"2022-09-07T14:01:07.524Z","dependency_job_id":null,"html_url":"https://github.com/mitchellh/go-mruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fgo-mruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fgo-mruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fgo-mruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitchellh%2Fgo-mruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitchellh","download_url":"https://codeload.github.com/mitchellh/go-mruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236051309,"owners_count":19087106,"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":[],"created_at":"2024-10-01T15:20:40.282Z","updated_at":"2025-10-11T05:31:40.845Z","avatar_url":"https://github.com/mitchellh.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# mruby Library for Go [![Build Status](https://travis-ci.org/mitchellh/go-mruby.svg?branch=master)](https://travis-ci.org/mitchellh/go-mruby)\n\ngo-mruby provides [mruby](https://github.com/mruby/mruby) bindings for\n[Go](http://golang.org). This allows Go applications to run a lightweight\nembedded Ruby VM. Using the mruby library, Go applications can call Ruby\ncode, and Ruby code can call Go code (that is properly exposed)!\n\nAt the time of writing, this is the most comprehensive mruby library for\nGo _by far_. It is also the only mruby library for Go that enables exposing\nGo functions to Ruby as well as being able to generically convert complex\nRuby types into Go types. Our goal is to implement all of the mruby API.\n\n**Project Status:** The major portions of the mruby API are implemented,\nbut the mruby API is huge. If there is something that is missing, please\nissue a pull request and I'd be happy to add it! We're also not yet ready\nto promise API backwards compatibility on a Go-level, but we're getting there.\n\n## Installation\n\nInstallation is a little trickier than a standard Go library, but not\nby much. You can't simply `go get` this library, unfortunately. This is\nbecause [mruby](https://github.com/mruby/mruby) must first be built. We\ndon't ship a pre-built version of mruby because the build step of mruby\nis important in customizing what aspects of the standard library you want\navailable, as well as any other extensions.\n\nTo build mruby, we've made it very easy. You will need the following packages\navailable on your host operating system:\n\n* bison\n* flex\n* ruby 2.x\n\nThen just type:\n\n```\n$ make\n```\n\nThis will download mruby, compile it, and run the tests for go-mruby,\nverifying that your build is functional. By default, go-mruby will download\nand build a default version of mruby, but this is customizable.\n\nCompiling/installing the go-mruby library should work on Linux, Mac OS X,\nand Windows. On Windows, msys is the only supported build toolchain (same\nas Go itself).\n\n**Due to this linking, it is strongly recommended that you vendor this\nrepository and bake our build system into your process.**\n\n### Customizing the mruby Compilation\n\nYou can customize the mruby compilation by setting a couple environmental\nvariables prior to calling `make`:\n\n  * `MRUBY_COMMIT` is the git ref that will be checked out for mruby. This\n    defaults to to a recently tagged version. Many versions before 1.2.0 do not\n    work with go-mruby. It is recommend you explicitly set this to a ref that\n    works for you to avoid any changes in this library later.\n\n  * `MRUBY_CONFIG` is the path to a `build_config.rb` file used to configure\n    how mruby is built. If this is not set, go-mruby will use the default\n    build config that comes with mruby. You can learn more about configuring\n    the mruby build [here](https://github.com/mruby/mruby/tree/master/doc/guides/compile.md).\n\n## Usage\n\ngo-mruby exposes the mruby API in a way that is idiomatic Go, so that it\nis comfortable to use by a standard Go programmer without having intimate\nknowledge of how mruby works.\n\nFor usage examples and documentation, please see the\n[go-mruby GoDoc](http://godoc.org/github.com/mitchellh/go-mruby), which\nwe keep up to date and full of examples.\n\nFor a quick taste of what using go-mruby looks like, though, we provide\nan example below:\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/mitchellh/go-mruby\"\n)\n\nfunc main() {\n\tmrb := mruby.NewMrb()\n\tdefer mrb.Close()\n\n\t// Our custom function we'll expose to Ruby. The first return\n\t// value is what to return from the func and the second is an\n\t// exception to raise (if any).\n\taddFunc := func(m *mruby.Mrb, self *mruby.MrbValue) (mruby.Value, mruby.Value) {\n\t\targs := m.GetArgs()\n\t\treturn mruby.Int(args[0].Fixnum() + args[1].Fixnum()), nil\n\t}\n\n\t// Lets define a custom class and a class method we can call.\n\tclass := mrb.DefineClass(\"Example\", nil)\n\tclass.DefineClassMethod(\"add\", addFunc, mruby.ArgsReq(2))\n\n\t// Let's call it and inspect the result\n\tresult, err := mrb.LoadString(`Example.add(12, 30)`)\n\tif err != nil {\n\t\tpanic(err.Error())\n\t}\n\n\t// This will output \"Result: 42\"\n\tfmt.Printf(\"Result: %s\\n\", result.String())\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fgo-mruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitchellh%2Fgo-mruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitchellh%2Fgo-mruby/lists"}