Skip to content

Developers Guide

If you want to learn how to extend Gate with your own code, you are in the right place.

GitHub release (latest SemVer)DocGitHub go.mod Go versionGo Report CardtestDiscord

Starter Template

The starter template is designed to help you get started with your own Gate powered project. Fork it! 🚀 - minekube/gate-plugin-template

Any Language

Go to the API 🌐 section to learn how to use Gate's API from any programming language.

Integration Options

Getting Started

Gate is designed with developers in mind.

All you need to get started is a working Go environment. You can find the Go installation instructions here.

Once you have Go installed, you create a new Go module and add Gate as a dependency:

sh
mkdir mcproxy; cd mcproxy
go mod init mcproxy
go get -u go.minekube.com/gate@latest

Add and initialize your plugin and execute Gate, that's it!

go
func main() {
    // Add our "plug-in" to be initialized on Gate start.
    proxy.Plugins = append(proxy.Plugins, proxy.Plugin{
        Name: "SimpleProxy",
        Init: func (ctx context.Context, proxy *proxy.Proxy) error {
            return newSimpleProxy(proxy).init() // see code examples
        },
    })

    // Execute Gate entrypoint and block until shutdown.
    // We could also run gate.Start if we don't need Gate's command-line.
    gate.Execute()
}

Learning by Example

The best way to learn how to extend Gate is by looking at some examples. If you want to see a complete Go project that uses Gate, check out the Simple Proxy example.

Gate's Plugin Architecture

Gate does not follow a traditional plugin system like Java Bukkit or BungeeCord. Instead, you create your own Go module, import Gate APIs, and compile it like a normal Go program.

Throughout the docs we refer to your custom code as a module, plugin or extension.

Note on Go's plugin system

We don't support Go's plugin system as it is not a mature solution. They force your plugin implementation to be highly-coupled with Gate's build toolchain, the end-result would be very brittle, hard to maintain, and the overhead would be much higher since the plugin author does not have any control over new versions of Gate.

One better solution would be to publish Go modules as Gate extensions where users can install open source plugins from GitHub like: gate mod install As implemented in Hugo Modules

Released under the Apache 2.0 License. (web version: 684aec7e)