{"id":13416835,"url":"https://github.com/traefik/yaegi","last_synced_at":"2025-05-13T18:04:33.563Z","repository":{"id":37583093,"uuid":"116938442","full_name":"traefik/yaegi","owner":"traefik","description":"Yaegi is Another Elegant Go Interpreter","archived":false,"fork":false,"pushed_at":"2025-01-08T13:50:32.000Z","size":31628,"stargazers_count":7532,"open_issues_count":163,"forks_count":379,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-05-06T17:13:28.341Z","etag":null,"topics":["go","golang","interpreter"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/traefik/yaegi","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/traefik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"2018-01-10T09:39:30.000Z","updated_at":"2025-05-06T09:58:12.000Z","dependencies_parsed_at":"2024-06-18T10:56:56.742Z","dependency_job_id":"a37715d4-8966-4bbb-9f8a-d7c9f5868c9a","html_url":"https://github.com/traefik/yaegi","commit_stats":{"total_commits":1089,"total_committers":44,"mean_commits":24.75,"dds":0.2350780532598714,"last_synced_commit":"e686f55767b948e7c151d09f2f7ec3bdaf1ac96e"},"previous_names":["containous/yaegi"],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traefik%2Fyaegi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traefik%2Fyaegi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traefik%2Fyaegi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/traefik%2Fyaegi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/traefik","download_url":"https://codeload.github.com/traefik/yaegi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000826,"owners_count":21997441,"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":["go","golang","interpreter"],"created_at":"2024-07-30T22:00:23.059Z","updated_at":"2025-05-13T18:04:33.491Z","avatar_url":"https://github.com/traefik.png","language":"Go","readme":"\u003cp align=\"center\"\u003e\n\u003cimg width=\"400\" src=\"doc/images/yaegi.png\" alt=\"Yaegi\" title=\"Yaegi\" /\u003e\n\u003c/p\u003e\n\n[![release](https://img.shields.io/github/tag-date/traefik/yaegi.svg?label=alpha)](https://github.com/traefik/yaegi/releases)\n[![Build Status](https://github.com/traefik/yaegi/actions/workflows/main.yml/badge.svg)](https://github.com/traefik/yaegi/actions/workflows/main.yml)\n[![GoDoc](https://godoc.org/github.com/traefik/yaegi?status.svg)](https://pkg.go.dev/mod/github.com/traefik/yaegi)\n\nYaegi is Another Elegant Go Interpreter.\nIt powers executable Go scripts and plugins, in embedded interpreters or interactive shells, on top of the Go runtime.\n\n## Features\n\n* Complete support of [Go specification][specs]\n* Written in pure Go, using only the standard library\n* Simple interpreter API: `New()`, `Eval()`, `Use()`\n* Works everywhere Go works\n* All Go \u0026 runtime resources accessible from script (with control)\n* Security: `unsafe` and `syscall` packages neither used nor exported by default\n* Support the latest 2 major releases of Go (Go 1.21 and Go 1.22)\n\n## Install\n\n### Go package\n\n```go\nimport \"github.com/traefik/yaegi/interp\"\n```\n\n### Command-line executable\n\n```bash\ngo install github.com/traefik/yaegi/cmd/yaegi@latest\n```\n\nNote that you can use [rlwrap](https://github.com/hanslub42/rlwrap) (install with your favorite package manager),\nand alias the `yaegi` command in `alias yaegi='rlwrap yaegi'` in your `~/.bashrc`, to have history and command line edition.\n\n### CI Integration\n\n```bash\ncurl -sfL https://raw.githubusercontent.com/traefik/yaegi/master/install.sh | bash -s -- -b $GOPATH/bin v0.9.0\n```\n\n## Usage\n\n### As an embedded interpreter\n\nCreate an interpreter with `New()`, run Go code with `Eval()`:\n\n```go\npackage main\n\nimport (\n\t\"github.com/traefik/yaegi/interp\"\n\t\"github.com/traefik/yaegi/stdlib\"\n)\n\nfunc main() {\n\ti := interp.New(interp.Options{})\n\n\ti.Use(stdlib.Symbols)\n\n\t_, err := i.Eval(`import \"fmt\"`)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t_, err = i.Eval(`fmt.Println(\"Hello Yaegi\")`)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n[Go Playground](https://play.golang.org/p/2n-EpZbMYI9)\n\n### As a dynamic extension framework\n\nThe following program is compiled ahead of time, except `bar()` which is interpreted, with the following steps:\n\n1. use of `i.Eval(src)` to evaluate the script in the context of interpreter\n2. use of `v, err := i.Eval(\"foo.Bar\")` to get the symbol from the interpreter context,  as a `reflect.Value`\n3. application of `Interface()` method and type assertion to convert `v` into `bar`, as if it was compiled\n\n```go\npackage main\n\nimport \"github.com/traefik/yaegi/interp\"\n\nconst src = `package foo\nfunc Bar(s string) string { return s + \"-Foo\" }`\n\nfunc main() {\n\ti := interp.New(interp.Options{})\n\n\t_, err := i.Eval(src)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tv, err := i.Eval(\"foo.Bar\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tbar := v.Interface().(func(string) string)\n\n\tr := bar(\"Kung\")\n\tprintln(r)\n}\n```\n\n[Go Playground](https://play.golang.org/p/WvwH4JqrU-p)\n\n### As a command-line interpreter\n\nThe Yaegi command can run an interactive Read-Eval-Print-Loop:\n\n```console\n$ yaegi\n\u003e 1 + 2\n3\n\u003e import \"fmt\"\n\u003e fmt.Println(\"Hello World\")\nHello World\n\u003e\n```\n\nNote that in interactive mode, all stdlib package are pre-imported,\nyou can use them directly:\n\n```console\n$ yaegi\n\u003e reflect.TypeOf(time.Date)\n: func(int, time.Month, int, int, int, int, int, *time.Location) time.Time\n\u003e\n```\n\nOr interpret Go packages, directories or files, including itself:\n\n```console\n$ yaegi -syscall -unsafe -unrestricted github.com/traefik/yaegi/cmd/yaegi\n\u003e\n```\n\nOr for Go scripting in the shebang line:\n\n```console\n$ cat /tmp/test\n#!/usr/bin/env yaegi\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"test\")\n}\n$ ls -la /tmp/test\n-rwxr-xr-x 1 dow184 dow184 93 Jan  6 13:38 /tmp/test\n$ /tmp/test\ntest\n```\n\n## Documentation\n\nDocumentation about Yaegi commands and libraries can be found at usual [godoc.org][docs].\n\nKey documentation of the internal design: https://marc.vertes.org/yaegi-internals/  Also see [interp/trace.go](interp/trace.go) for helpful printing commands to see what is happening under the hood during compilation.\n\n## Limitations\n\nBeside the known [bugs] which are supposed to be fixed in the short term, there are some limitations not planned to be addressed soon:\n\n- Assembly files (`.s`) are not supported.\n- Calling C code is not supported (no virtual \"C\" package).\n- Directives about the compiler, the linker, or embedding files are not supported.\n- Interfaces to be used from the pre-compiled code can not be added dynamically, as it is required to pre-compile interface wrappers.\n- Representation of types by `reflect` and printing values using %T may give different results between compiled mode and interpreted mode.\n- Interpreting computation intensive code is likely to remain significantly slower than in compiled mode.\n\nGo modules are not supported yet. Until that, it is necessary to install the source into `$GOPATH/src/github.com/traefik/yaegi` to pass all the tests.\n\n## Contributing\n\n[Contributing guide](CONTRIBUTING.md).\n\n## License\n\n[Apache 2.0][License].\n\n[specs]: https://golang.org/ref/spec\n[docs]: https://pkg.go.dev/github.com/traefik/yaegi\n[license]: https://github.com/traefik/yaegi/blob/master/LICENSE\n[github]: https://github.com/traefik/yaegi\n[bugs]: https://github.com/traefik/yaegi/issues?q=is%3Aissue+is%3Aopen+label%3Abug\n","funding_links":[],"categories":["Popular","Go","Programming","Golang","Go 程序设计","golang","Repositories","Members"],"sub_categories":["Golang","网络服务_其他"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftraefik%2Fyaegi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftraefik%2Fyaegi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftraefik%2Fyaegi/lists"}