https://github.com/micro/micro
A Go microservices toolkit
https://github.com/micro/micro
go micro platform
Last synced: 11 days ago
JSON representation
A Go microservices toolkit
- Host: GitHub
- URL: https://github.com/micro/micro
- Owner: micro
- License: apache-2.0
- Created: 2015-01-16T22:35:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2025-05-02T13:56:47.000Z (22 days ago)
- Last Synced: 2025-05-05T22:14:21.097Z (19 days ago)
- Topics: go, micro, platform
- Language: Go
- Homepage: https://micro.mu
- Size: 20.7 MB
- Stars: 12,254
- Watchers: 312
- Forks: 1,058
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - micro - A distributed systems runtime for the cloud and beyond. (Distributed Systems / Search and Analytic Databases)
- awesome-go - micro/micro
- awesome - micro - A microservice runtime environment (Go)
- awesome-repositories - micro/micro - An API first development platform (Go)
- awesome-go - Micro - distributed cloud platform. Addresses the key requirements for building services in the cloud. It leverages the microservices architecture pattern and provides a set of services which act as the building blocks of a platform. Micro deals with the complexity of distributed systems and provides simpler programmable abstractions to build on. (Micro services frameworks)
- go-awesome - Micro - Microservice tools (Open source library / Microservices)
- awesome-go - micro - A cloud-native toolkit - ★ 5018 (Distributed Systems)
- awesome-go-extra - micro - 01-16T22:35:14Z|2022-08-22T15:31:34Z| (Distributed Systems / Advanced Console UIs)
- go-collection - micro
- go-collection - micro
- awesome-arsenal - Micro - API 开发平台。 (武器库 / 后端)
- awesome-go - micro - A distributed systems runtime for the cloud and beyond. Stars:`12.3K`. (Distributed Systems / Search and Analytic Databases)
- awesome-list-microservice - micro - native toolkit (rpc)
README
# Micro [](https://opensource.org/licenses/Apache-2.0) [](https://discord.gg/UmFkPbu32m)
A Go microservices toolkit
## Overview
Micro is an ecosystem for Go microservices development. It provides the tools required for building services in the cloud.
The core of Micro is the [Go Micro](https://go-micro.dev) framework, which developers import and use in their code to
write services. Surrounding this we introduce a number of tools to make it easy to serve and consume services.## Install the CLI
Install `micro` via `go get`
```
go get github.com/micro/micro/v5@latest
```For releases see the [latest](https://github.com/micro/micro/releases/latest) tag
## Create a service
Create your service using [Go Micro](https://go-micro.dev)
```go
package mainimport (
"go-micro.dev/v5"
)type Request struct {
Name string `json:"name"`
}type Response struct {
Message string `json:"message"`
}type Say struct{}
func (h *Say) Hello(ctx context.Context, req *Request, rsp *Response) error {
rsp.Message = "Hello " + req.Name
return nil
}func main() {
// create the service
service := micro.New("helloworld")// register handler
service.Handle(new(Say))// run the service
service.Run()
}
```Run a service
```
micro run
```List services
```
micro services
```Call a service
```
micro call helloworld Say.Hello '{"name": "Asim"}'
```Describe a service
```
micro describe helloworld
```Output
```
{
"name": "helloworld",
"version": "latest",
"metadata": null,
"endpoints": [
{
"request": {
"name": "Request",
"type": "Request",
"values": [
{
"name": "string",
"type": "string",
"values": null
}
]
},
"response": {
"name": "Response",
"type": "Response",
"values": [
{
"name": "string",
"type": "string",
"values": null
}
]
},
"metadata": {},
"name": "Say.Hello"
}
],
"nodes": [
{
"metadata": {
"broker": "http",
"protocol": "mucp",
"registry": "mdns",
"server": "mucp",
"transport": "http"
},
"id": "helloworld-9988def2-2ee4-45f1-9cf7-faa62535538f",
"address": "172.17.0.1:40397"
}
]
}
```## Create a client
Create a client to call the service
```go
package mainimport (
"context"
"fmt""go-micro.dev/v5"
)type Request struct {
Name string
}type Response struct {
Message string
}func main() {
client := micro.New("helloworld").Client()req := client.NewRequest("helloworld", "Say.Hello", &Request{Name: "John"})
var rsp Response
err := client.Call(context.TODO(), req, &rsp)
if err != nil {
fmt.Println(err)
return
}fmt.Println(rsp.Message)
}
```## Micro API
Call services via http using the [micro-api](https://github.com/micro/micro/tree/master/cmd/micro-api)
Install the API
```
go get github.com/micro/micro/cmd/micro-api@latest
```Run the API
```
micro-api
```If you have the service running
```
curl http://localhost:8080/helloworld/Say/Hello -d '{"name": "John"}'
```Or with headers
```
curl -H 'Micro-Service: helloworld' -H 'Micro-Endpoint: Say.Hello' http://localhost:8080/ -d '{"name": "John"}'
```