Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tdakkota/sun
Python-compatible built-ins for Starlark written in Go.
https://github.com/tdakkota/sun
builtin builtin-functions golang module python starlark starlark-go
Last synced: 14 days ago
JSON representation
Python-compatible built-ins for Starlark written in Go.
- Host: GitHub
- URL: https://github.com/tdakkota/sun
- Owner: tdakkota
- License: mit
- Created: 2021-04-04T10:02:29.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-10-27T11:59:07.000Z (about 1 year ago)
- Last Synced: 2024-10-18T21:17:15.190Z (20 days ago)
- Topics: builtin, builtin-functions, golang, module, python, starlark, starlark-go
- Language: Go
- Homepage:
- Size: 89.8 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# sun
Sun is a Starlark module which adds Python-compatible built-ins like [`map`](https://docs.python.org/3/library/functions.html#map) and [`filter`](https://docs.python.org/3/library/functions.html#filter).## Installation
```bash
go get github.com/tdakkota/sun
```## Usage
```go
package mainimport (
"fmt""go.starlark.net/starlark"
"github.com/tdakkota/sun"
)func main() {
code := "list(filter(lambda x: x % 2 == 0, range(10)))"// Eval Starlark expresion.
thread := &starlark.Thread{Name: "main"}
result, err := starlark.Eval(thread, "example.star", code, sun.Module.Members)
if err != nil {
panic(err)
}fmt.Println(result)
// Output:
// [0, 2, 4, 6, 8]
}
```