Getting started

Build and run a Go service, then call it over RPC. No model or agent is needed.

Install

With Go 1.26 or newer:

go install go-micro.dev/v6/cmd/micro@v6.15.1
export PATH="$(go env GOPATH)/bin:$PATH"
mkdir my-app
cd my-app
go mod init example.com/my-app
go get go-micro.dev/v6@v6.15.1

This guide uses v6.15.1 of both the framework and CLI.

Write a service

Save this as main.go. Replace the handler body with your application’s logic:

package main

import (
    "context"
    "log"

    micro "go-micro.dev/v6"
)

type ListRequest struct{}
type ListResponse struct {
    Notes []string `json:"notes"`
}

type Notes struct{}

func (n *Notes) List(ctx context.Context, req *ListRequest, rsp *ListResponse) error {
    rsp.Notes = []string{"Review the release", "Update the documentation"}
    return nil
}

func main() {
    service := micro.NewService("notes")
    service.Init()
    if err := service.Handle(new(Notes)); err != nil {
        log.Fatal(err)
    }
    if err := service.Run(); err != nil {
        log.Fatal(err)
    }
}

Start it and leave it running:

go run .

In a second terminal:

micro call notes Notes.List '{}'

The response contains Review the release and Update the documentation. The service is named notes; the operation is Notes.List.

Discovery uses multicast DNS by default. If your network blocks multicast, use a shared registry such as NATS; see Services.

Your service is running and can be called by other applications. You can stop here.

Choose what to do next

Build further