Some utilities to parse Eclipse Kura payloads in Go

go get




Some utilities to parse Eclipse Kura payloads in Go.

Kura Datatype

The kuradatatypes package contains the protobuf generated Go code for the Kura payload as defined in the Kura repository:

In order to use the kuradatatypes package you can import it in your Go program using:

package main

import (
    pb ""

func main(){

    metric_name := "mymetric"

    metric_type := pb.KuraPayload_KuraMetric_STRING

    metric := &pb.KuraPayload_KuraMetric{
                            Name: &metric_name,
                            Type: &metric_type,

    metrics := []*pb.KuraPayload_KuraMetric{metric}
    message := &pb.KuraPayload{
                        Metric: metrics,

    fmt.Printf("Here my Kura payload as string: %s\n", message)

    marshaler := &jsonpb.Marshaler{}
    json_string, _ := marshaler.MarshalToString(message)
    fmt.Printf("Here my Kura payload as json string: %s\n", json_string)


You can find some example programs in the ./examples folder.

The mqtt_subscriber example, subscribe to an mqtt topic and convert the KuraPayload to a json string. Here the usage:

Usage of examples/mqtt_subscriber:
  -clientid string
    	A clientid for the connection (default "localhost")
  -log.level value
    	Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal, panic]. (default info)
  -password string
    	Password to match username
  -qos int
    	The QoS to subscribe to messages at
  -server string
    	The full url of the MQTT server to connect to ex: tcp:// (default "tcp://")
  -topic string
    	Topic to subscribe to (default "#")
  -username string
    	A username to authenticate to the MQTT server

You can build the examples using go build filename.go

Detailed instructions on how to setup your development environment are here: