Skip to content

Get Started

A Go extension is simply an ordinary Go source file (.go) that the host compiles and runs with the Scriggo engine. It is a good fit when you need stronger typing, complex parsing, or access to the Go ecosystem.

This page covers creating the extension file and declaring entry points. For the full sdk usage, return types, and Scriggo limitations, see Detail Usage. The two ways to drive the extension — local native Go and runtime Scriggo — are covered in Running with Native Go and Running with Scriggo. Shared metadata is in Getting Started and return shapes in Data Formats.

Clone the miru_extension_template repository to get started:

Terminal window
git clone https://github.com/appdevelpo/miru_extension_template.git my-extension

Create a .go file named after your package, e.g. my.extension.go. It’s a normal Go package; pull in the official SDK with go get:

Terminal window
go get github.com/miru-project/miru-core/pkg/extension/golang/sdk

Go extensions expose entry points through exported functions that the host calls by name:

import sdk "github.com/miru-project/miru-core/pkg/extension/golang/sdk"
// Argument order: pkg string first, then the business arguments
func Latest(pkg string, page int) ([]sdk.ExtensionListItem, error) { /* ... */ }
func Search(pkg string, kw string, page int, filter string) ([]sdk.ExtensionListItem, error) { /* ... */ }
func Detail(pkg, url string) (*sdk.ExtensionDetail, error) { /* ... */ }
func Watch(pkg, url string) (*sdk.ExtensionWatch, error) { /* mirror list (or ExtensionAllMirror for @type all) */ }
func Mirror(pkg, url string) (*sdk.ExtensionBangumiWatchMirror, error) { /* resolve final playback shape */ }
func Load() { /* runs once when the extension loads (optional) */ }

Submit your extension to the Miru Extension Repository via a PR. The PR must contain the extension source file and does not need the index.json file.