Project Setup
This guide walks you through creating a new Go project that uses Gate from scratch. If you prefer a pre-configured setup, see the Plugin Template instead.Prerequisites
Before you begin, ensure you have:- Go 1.21 or higher installed (download here)
- Basic Go knowledge (modules, packages, functions)
- A text editor (VS Code, GoLand, Vim, etc.)
- Terminal access for running commands
Creating a New Project
Initialize Go Module
Initialize a new Go module:Replace
github.com/yourusername/my-gate-proxy with your actual module path.Create Configuration File
Create a This configures Gate to:
config.yml file for Gate’s configuration:- Listen on port 25565
- Connect players to the “lobby” server first
- Fall back to other servers if lobby is unavailable
Project Structure
A typical Gate project structure:Understanding go.mod
After runninggo get, your go.mod should look like:
go.minekube.com/gate- Core proxy functionalitygo.minekube.com/brigodier- Command frameworkgo.minekube.com/common- Minecraft components (chat, colors)github.com/robinbraemer/event- Event system
Adding Common Features
Register a Command
Createcommands.go:
main.go to call it:
Handle Events
Createevents.go:
main.go:
Working with Components
Gate uses a component system for rich text:Complete Example
Here’s a completemain.go with commands and events:
Building Your Project
Development Build
For quick testing:Production Build
Create an optimized binary:Cross-Compilation
Build for different platforms:Configuration Best Practices
Separate Environments
Create different config files for different environments:Environment Variables
Use environment variables for sensitive data:Validation
Gate validates your configuration on startup. Common issues:Troubleshooting
Module download fails
Module download fails
Error:
go: module go.minekube.com/gate: Get "https://proxy.golang.org/..." failedSolutions:- Check your internet connection
- Verify firewall isn’t blocking Go module proxy
- Try setting
GOPROXYenvironment variable:
Import cycle errors
Import cycle errors
Error:
import cycle not allowedSolution: Reorganize your code to avoid circular imports. For example:Port already in use
Port already in use
Error:
bind: address already in useSolutions:-
Find and stop the process using the port:
-
Or change the port in
config.yml:
Config file not found
Config file not found
Error: Or specify the path explicitly:
config file not foundSolution: Ensure config.yml is in the same directory as your binary:Backend servers not connecting
Backend servers not connecting
Error: Players can’t connect to backend serversSolutions:
-
Verify backend servers are running:
- Check firewall rules allow connections
-
Verify addresses in
config.ymlare correct - Check backend server logs for connection attempts
Testing Your Proxy
Manual Testing
-
Start your proxy:
- Start a backend server (e.g., Paper, Spigot) on port 25566
-
Connect with Minecraft client to
localhost:25565
Unit Testing
Createmain_test.go:
Performance Tips
Use Goroutines for Async Operations
Batch Player Operations
Resource Cleanup
Use context cancellation:Next Steps
Commands Guide
Learn how to create powerful commands
Events Guide
Master the event system
Simple Proxy Example
Study a complete working example
API Reference
Explore the full API documentation
Additional Resources
- Go Documentation: golang.org/doc
- Gate Package Docs: pkg.go.dev/go.minekube.com/gate
- Brigodier (Commands): pkg.go.dev/go.minekube.com/brigodier
- Event System: github.com/robinbraemer/event
- Discord Community: discord.gg/6vMDqWE

