Skip to content

borud/go-span-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-span-client

This repository contains a simple client library for communicating with Span as an IoT device. If you want to access the Span API for managing Span resources, the library you want is the Go Span API Client.

This library uses the Pion DTLS library.

Godoc

Minimal example

package main

import (
    "log"
    "time"
    client "github.com/borud/go-span-client"
)

func main() {
    client, err := client.Connect(client.NewDefaultConfig())
    if err != nil {
        log.Fatal(err)
    }
    defer client.Close()
   
    n, err := client.Write([]byte("this is a test"), time.Second)
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("wrote %d bytes", n)
   
    buffer := make([]byte, 1024)
   
    n, err = client.Read(buffer, time.Second*5)
    if err != nil {
        log.Fatal(err)
    }
    log.Printf("read %d bytes: [%s]", n, string(buffer))
}

About

Simple Span Client library for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published