{"id":21238760,"url":"https://github.com/splitgraph/seafowl-udf-go","last_synced_at":"2025-03-15T03:27:00.780Z","repository":{"id":181969034,"uuid":"659525866","full_name":"splitgraph/seafowl-udf-go","owner":"splitgraph","description":"Example User Defined Function (UDF) for Seafowl in Go","archived":false,"fork":false,"pushed_at":"2023-08-08T00:14:53.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-10T03:55:52.405Z","etag":null,"topics":["golang","msgpack","seafowl","udf"],"latest_commit_sha":null,"homepage":"https://www.splitgraph.com/blog/seafowl-udf-golang","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/splitgraph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-28T03:02:59.000Z","updated_at":"2023-09-05T19:54:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"aaa34339-7a2e-4676-bbae-4ca79f1f1b42","html_url":"https://github.com/splitgraph/seafowl-udf-go","commit_stats":null,"previous_names":["splitgraph/seafowl-udf-go"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splitgraph%2Fseafowl-udf-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splitgraph%2Fseafowl-udf-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splitgraph%2Fseafowl-udf-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splitgraph%2Fseafowl-udf-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/splitgraph","download_url":"https://codeload.github.com/splitgraph/seafowl-udf-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243679415,"owners_count":20329934,"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":["golang","msgpack","seafowl","udf"],"created_at":"2024-11-21T00:38:20.172Z","updated_at":"2025-03-15T03:27:00.740Z","avatar_url":"https://github.com/splitgraph.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Seafowl UDF Go\n\nA simple Seafowl UDF demo, intended to follow in the footsteps of the [Rust example](https://github.com/splitgraph/seafowl-udf-rust) but implemented in Go instead.\n\n# HOWTO\n\nDependencies: Go, tinygo\n| task | command |\n|---|---|\n| tinygo compile with wasi[^1] | `tinygo build -o seafowl-udf-go.wasm -target=wasi`\n| tinygo compile | `tinygo build -o seafowl-udf-go.wasm`\n| tests | `go test -v` |\n| compile (use tinygo for WASM) | `go build` should output `seafowl-udf-go`, run it via `./seafowl-udf-go 1 2` |\n\n---\n\n# How to run in Seafowl\n\nIt's basically identical to the Rust UDF [docs](https://github.com/splitgraph/seafowl-udf-rust#loading-the-wasm-module-into-seafowl-as-a-udf)\n\n1. Compile into a WASM using `tinygo build -o seafowl-udf-go.wasm -target=wasi`\n2. Install the module using [`./create_udf.sh`](./create_udf.sh)\n3. Run Seafowl (e.g. `seafowl` or the Docker image, whatever)\n4. Invoke the function using [`./query_udf.sh`](./query_udf.sh)\n\n   You can invoke it directly via SQL, the shell script is just a convenience e.g.\n\n   ```sql\n   SELECT addi64(1, 2) AS RESULT\n   ```\n\n   using e.g. [curl](https://seafowl.io/docs/guides/querying-http) or [psql](https://seafowl.io/docs/guides/querying-postgresql)\n\n   And you should get back\n\n   ```\n   $ ./query_udf.sh\n   SELECT addi64(1, 2) AS RESULT;\n   HTTP/1.1 200 OK\n   content-type: application/json; arrow-schema=%7B%22fields%22%3A%5B%7B%22children%22%3A%5B%5D%2C%22name%22%3A%22result%22%2C%22nullable%22%3Atrue%2C%22type%22%3A%7B%22bitWidth%22%3A64%2C%22isSigned%22%3Atrue%2C%22name%22%3A%22int%22%7D%7D%5D%2C%22metadata%22%3A%7B%7D%7D\n   x-seafowl-query-time: 426\n   vary: Authorization, Content-Type, Origin, X-Seafowl-Query\n   transfer-encoding: chunked\n   date: Tue, 18 Jul 2023 06:34:14 GMT\n\n   {\"result\":3}\n   ```\n\n[^1]: If you don't need concurrency/goroutines, the binary size can be squeezed even smaller via `tinygo build -scheduler=none -o seafowl-udf-go.wasm -target=wasi`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplitgraph%2Fseafowl-udf-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsplitgraph%2Fseafowl-udf-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplitgraph%2Fseafowl-udf-go/lists"}