{"id":13412746,"url":"https://github.com/1set/starlet","last_synced_at":"2025-08-22T07:41:08.364Z","repository":{"id":174331353,"uuid":"643249613","full_name":"1set/starlet","owner":"1set","description":"✨ Yet another Go wrapper for Starlark that simplifies usage, offers data conversion and useful Starlark libraries","archived":false,"fork":false,"pushed_at":"2024-07-23T00:59:56.000Z","size":454,"stargazers_count":16,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T20:51:25.383Z","etag":null,"topics":["go","golang","script","scripting","scripting-language","starlark","starlark-go","starlark-lang","starlark-language","starlarky","starlet"],"latest_commit_sha":null,"homepage":"","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/1set.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}},"created_at":"2023-05-20T15:09:07.000Z","updated_at":"2024-07-26T22:50:21.000Z","dependencies_parsed_at":"2024-05-14T03:05:12.236Z","dependency_job_id":"150b0a1c-cb17-45fd-9c81-a5717ebb7d9a","html_url":"https://github.com/1set/starlet","commit_stats":null,"previous_names":["1set/starlet"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1set%2Fstarlet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1set%2Fstarlet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1set%2Fstarlet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/1set%2Fstarlet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/1set","download_url":"https://codeload.github.com/1set/starlet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243625163,"owners_count":20321248,"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","script","scripting","scripting-language","starlark","starlark-go","starlark-lang","starlark-language","starlarky","starlet"],"created_at":"2024-07-30T20:01:28.666Z","updated_at":"2025-03-14T18:32:04.304Z","avatar_url":"https://github.com/1set.png","language":"Go","readme":"# :sparkles: Starlet - Supercharging Starlark, Simply\n\n[![godoc](https://pkg.go.dev/badge/github.com/1set/starlet.svg)](https://pkg.go.dev/github.com/1set/starlet)\n[![codecov](https://codecov.io/github/1set/starlet/branch/master/graph/badge.svg?token=M1tauam4Hw)](https://codecov.io/github/1set/starlet)\n[![codacy](https://app.codacy.com/project/badge/Grade/4e9c3f67a9574e6caa1b0d4706535815)](https://app.codacy.com/gh/1set/starlet/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n[![codeclimate](https://api.codeclimate.com/v1/badges/290ec0cc3261d16c423f/maintainability)](https://codeclimate.com/github/1set/starlet/maintainability)\n[![goreportcard](https://goreportcard.com/badge/github.com/1set/starlet)](https://goreportcard.com/report/github.com/1set/starlet)\n\n\u003e Enhancing your Starlark scripting experience with powerful extensions and enriched wrappers. Start your Starlark journey with Starlet, where simplicity meets functionality.\n\n*Starlet* is yet another Go wrapper for the official [*Starlark in Go*](https://github.com/google/starlark-go) project, designed to enhance the Starlark scripting experience with powerful extensions and enriched wrappers, and provide a more user-friendly and powerful interface for embedding Starlark scripting in your Go applications.\n\nInspired by the [*Starlight*](https://github.com/starlight-go/starlight) and [*Starlib*](https://github.com/qri-io/starlib) projects, *Starlet* focuses on three main objectives: providing an easier-to-use **Go wrapper** for Starlark, offering flexible **data conversion** between Go and Starlark, and supplying a set of **useful libraries** for Starlark.\n\n## Key Features\n\n*Starlet* provides the following key features:\n\n### Flexible Machine Abstraction\n\n*Starlet* introduces a streamlined interface for executing Starlark scripts, encapsulating the complexities of setting up and running the scripts: The [`Machine`](https://pkg.go.dev/github.com/1set/starlet#Machine) type serves as a comprehensive wrapper for Starlark runtime environments, offering an intuitive API for executing Starlark scripts, managing global variables, loading modules, controlling the script execution flow., and handling script outputs.\n\n### Enhanced Data Conversion\n\n*Starlet* offers the [`dataconv`](https://pkg.go.dev/github.com/1set/starlet/dataconv) package that simplifies the data exchange between Go and Starlark types. Unlike *Starlight*, which wraps Go values in Starlark-friendly structures, it focuses on transforming Go values into their Starlark equivalents and vice versa. This allows for a more seamless integration of Go's rich data types into Starlark scripts.\n\n### Extended Libraries \u0026 Functionalities\n\n*Starlet* includes a set of custom modules and libraries that extend the functionality of the Starlark language. These modules cover a wide range of use cases, such as file manipulation, HTTP client, JSON/CSV handling, and more, making Starlark scripts even more powerful and versatile.\n\n## Libraries\n\n*Starlet* comes with a set of libraries to extend the standard Starlark library. Here's a brief overview:\n\n| Package                           | Go Doc                                                                                                                                       | Description                                                   |\n|:----------------------------------|:---------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------|\n| [`atom`](/lib/atom)               | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/atom.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/atom)               | Atomic operations for integers, floats, and strings           |\n| [`base64`](/lib/base64)           | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/base64.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/base64)           | Base64 encoding \u0026 decoding functions                          |\n| [`csv`](/lib/csv)                 | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/csv.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/csv)                 | Parses and writes comma-separated values (csv) contents       |\n| [`file`](/lib/file)               | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/file.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/file)               | Functions to interact with the file system                    |\n| [`goidiomatic`](/lib/goidiomatic) | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/goidiomatic.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/goidiomatic) | Go idiomatic functions and values for Starlark                |\n| [`hashlib`](/lib/hashlib)         | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/hashlib.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/hashlib)         | Hash primitives for Starlark                                  |\n| [`http`](/lib/http)               | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/http.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/http)               | HTTP client and server handler implementation for Starlark    |\n| [`json`](/lib/json)               | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/json.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/json)               | Utilities for converting Starlark values to/from JSON strings |\n| [`log`](/lib/log)                 | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/log.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/log)                 | Functionality for logging messages at various severity levels |\n| [`path`](/lib/path)               | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/path.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/path)               | Functions to manipulate directories and file paths            |\n| [`random`](/lib/random)           | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/random.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/random)           | Functions to generate random values for various distributions |\n| [`re`](/lib/re)                   | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/re.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/re)                   | Regular expression functions for Starlark                     |\n| [`runtime`](/lib/runtime)         | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/runtime.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/runtime)         | Provides Go and app runtime information                       |\n| [`string`](/lib/string)           | [![godoc](https://pkg.go.dev/badge/github.com/1set/starlet/lib/string.svg)](https://pkg.go.dev/github.com/1set/starlet/lib/string)           | Constants and functions to manipulate strings                 |\n\nFor extensive documentation on each library, please refer to the respective README files in the [`lib`](/lib) directory. Additionally, *Starlet* includes an array of official modules. You can explore all provided modules by using [`GetAllBuiltinModuleNames()`](https://pkg.go.dev/github.com/1set/starlet#GetAllBuiltinModuleNames) method.\n\n## Installation\n\nTo install *Starlet*, use the following Go command under your project directory:\n\n```bash\ngo get github.com/1set/starlet\n```\n\nTo explore the capabilities of the Starlet CLI tool, use the command below to install:\n\n```bash\ngo install github.com/1set/starlet/cmd/starlet@latest\n```\n\n## Usage\n\nYou can use *Starlet* to enhance your Starlark scripting experience. Here's a quick example:\n\n```go\nimport \"github.com/1set/starlet\"\n\n// Define your machine with global variables and modules\nglobals := starlet.StringAnyMap{\n    \"greet\": func(name string) string {\n        return fmt.Sprintf(\"Hello, %s!\", name)\n    },\n}\nmac := starlet.NewWithNames(globals, []string{\"random\"}, nil)\n\n// Run a Starlark script in the machine\nscript := `\ntarget = random.choice([\"World\", \"Starlark\", \"Starlet\"])\ntext = greet(target)\nprint(\"Starlark:\", text)\n`\nres, err := mac.RunScript([]byte(script), nil)\n\n// Check for errors and results\nif err != nil {\n    fmt.Println(\"Error executing script:\", err)\n    return\n}\nfmt.Println(\"Go:\", res[\"text\"].(string))\nfmt.Println(\"Modules:\", starlet.GetAllBuiltinModuleNames())\n```\n\nThis may output:\n\n```\nStarlark: Hello, Starlet!\nGo: Hello, Starlet!\nModules: [atom base64 csv file go_idiomatic hashlib http json log math path random re runtime string struct time]\n```\n\nUse CLI to interact with the read-eval-print loop (REPL):\n\n```python\n\u003e\u003e\u003e resp = http.get(\"https://api.github.com/repos/1set/starlet\")\n\u003e\u003e\u003e resp.status_code\n200\n\u003e\u003e\u003e data = resp.json()\n\u003e\u003e\u003e data[\"description\"]\n\"✨ Enhancing your Starlark scripting experience with powerful extensions and enriched wrappers. Start your Starlark journey with Starlet, where simplicity meets functionality.\"\n\u003e\u003e\u003e \",\".join(data[\"topics\"])\n\"go,golang,script,scripting,scripting-language,starlark,starlark-go,starlark-lang,starlark-language,starlarky\"\n\u003e\u003e\u003e pprint(data[\"license\"])\n{\n    \"key\": \"mit\",\n    \"name\": \"MIT License\",\n    \"node_id\": \"MDc6TGljZW5zZTEz\",\n    \"spdx_id\": \"MIT\",\n    \"url\": \"https://api.github.com/licenses/mit\"\n}\n\u003e\u003e\u003e\n```\n\n## Contributing\n\nContributions to *Starlet* are all welcomed. If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request. Before undertaking any significant changes, please let us know by filing an issue or claiming an existing one to ensure there is no duplication of effort.\n\n## License\n\n*Starlet* is licensed under the [MIT License](LICENSE).\n\n## Credits\n\n*Starlet* is inspired by two projects:\n\n1. [Starlight](https://github.com/starlight-go/starlight): A Go wrapper and data conversion tool between Go and Starlark.\n2. [Starlib](https://github.com/qri-io/starlib): A collection of third-party libraries for Starlark.\n\nWe appreciate the work done by the creators and contributors of these projects. Their efforts have paved the way for the development of *Starlet*. Special thanks to the authors and contributors of these projects! 🎉\n","funding_links":[],"categories":["Embeddable Scripting Languages","Go","Libraries and extensions","可嵌入的脚本语言","Tooling"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","Starlark"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1set%2Fstarlet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F1set%2Fstarlet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F1set%2Fstarlet/lists"}