Skip to content
Raspberry Pi Go Language Interface
Go Other
  1. Go 98.9%
  2. Other 1.1%
Branch: master
Clone or download
Latest commit a7ae98d Sep 19, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Updated circleci and requirements May 14, 2019
cmd Removed params from main module Apr 23, 2019
docs Added metrics May 12, 2018
etc Updates Sep 8, 2018
sys Fix function comments based on best practices from Effective Go Mar 20, 2019
util Added persistence module Jul 7, 2019
.gitignore Deleted input classes which have moved to gopi-inout repo Aug 25, 2018 Updated some documentation Jan 3, 2018
Makefile Removed params from main module Apr 23, 2019 Updated circleci and requirements May 14, 2019
app.go Updated client pool module Jun 5, 2019
app_main.go Updated service type May 4, 2019
app_test.go Added AppParams Apr 23, 2019
events.go Updated RPCEvent Apr 26, 2019
flags.go Updated flags to use the .gopi.json file for parameters May 23, 2019
flags_test.go Added circleci pipeline Apr 24, 2019
geometry.go Updated graphics and made a few name changes Jan 8, 2018
go.mod Added AppParams Apr 23, 2019
gopi.go Added basic logging class Dec 20, 2018
gopi_test.go Updates Sep 8, 2018
graphics.go Updated Do method to include userInfo argument Jan 19, 2019
graphics_test.go Added AppParams Apr 23, 2019
hw.go Added Uptime and load average to hw Apr 28, 2019
input.go Uncommented input manager functions Aug 26, 2018
layout.go Huge reorganization Sep 8, 2018
metrics.go Added Unit function to metrics interface Sep 2, 2018
modules.go Updated client pool module Jun 5, 2019
modules_test.go Updates to tests Dec 3, 2017
rpc.go Added first and any flags Jun 2, 2019
timer.go Updated timer module Sep 9, 2018
vector.go Updated graphics interfaces Jan 7, 2019

GOPI Go Language Application Framework


This repository contains an application framework for the Go language, which will allow you to develop applications which utilize a number of features of your computer. It's targetted at the Raspberry Pi presently. The following features are intended to be supported:

  • The GPIO, I2C and SPI interfaces
  • Display and display surfaces, bitmaps and vector graphics
  • GPU acceleration for 2D graphics
  • Font loading and rendering in bitmap and vector forms
  • Input devices like the mouse, keyboard and touchscreen
  • Infrared transmission and receiving, for example for remote controls
  • Network microservices, announcement and discovery

It would also be great to support the following features in the future:

  • Image and video encoding/decoding, including utilizing hardware acceleration
  • Connected cameras
  • 3D graphics
  • Audio devices
  • User interface widgets and layout
  • Building for Darwin (Macintosh) targets


The tested requirements are currently:

  • Any Raspberry Pi (v2, v3, Zero and Zero W have been tested)
  • Raspbian GNU/Linux 9 (other distributions may work, but not tested)
  • Go 1.12

In order to use the library, you'll need to have a working version of Go on your Raspberry Pi, which you can download. Then retrieve the library on your device, using:

go get

The gopi repository is mostly just a set of interfaces and some utility packages. Other repositories provide implementation:

Repository Link Module
gopi-hw Hardware implementations
gopi-graphics Graphics & Fonts
gopi-rpc Microservices & Discovery
gopi-input Input services (Keyboard, Mouse, Touchscreen)

Please see each repository for more example code and information on the modules provided.

Getting Started

In order to get started, build some of the examples in the "cmd" folder. They can be built with the makefile.

  • make will run the tests and install the examples
  • make install will build and install the examples without testing
  • make clean will remove intermediate files

There are two examples in this repository you can examine in order so you can develop your own applications:

  • helloworld demonstrates the most canonical code, taking in command-line arguments, outputting a message and waiting for user input to end the program;
  • timers demonstrates the use of the timer module, either outputting a single message, or one on a repeating basis.

Fuller documentation of the examples and developing your own code against this framework is available in the documentation.


This repository contains two modules:

Module Import Type Name
Logger gopi.MODULE_TYPE_LOGGER sys/logger
Timer gopi.MODULE_TYPE_TIMER sys/timer


The logger module provides very basic logging functionality. Here is the interface for any logging module:

type Logger interface {

  // Output logging messages
  Fatal(format string, v ...interface{}) error
  Error(format string, v ...interface{}) error
  Warn(format string, v ...interface{})
  Info(format string, v ...interface{})
  Debug(format string, v ...interface{})
  Debug2(format string, v ...interface{})

  // Return IsDebug flag
  IsDebug() bool

A logger module is required for every application which uses this framework, so include the module in your main package:

package main

import (
  // Frameworks

  // Modules
  _ ""

The logger is then available as app.Logger within your application, and is also passed to every gopi module with the Open method. The standard logger includes some command-line flags in case you want to log to a file, rather than to stderr:

$ helloworld -help
Usage of helloworld:
    	Set debugging mode
    	When writing log to file, append output to end of file
  -log.file string
    	File for logging (default: log to stderr)
    	Verbose logging

Logging occurs depending on the combination of the debug and verbose flags, according to the following rules:

Debug Verbose Levels logged
false false Fatal, Error and Warn
false true Fatal, Error, Warn and Info
true false Fatal, Error, Warn, Info and Debug
true true Fatal, Error, Warn, Info, Debug and Debug2


The timer module emits gopi.Event objects once, at regular intervals, or at intervals according to a backoff rule. The timer interface is as follows:

type Timer interface {

  // Schedule a timeout (one shot)
  NewTimeout(duration time.Duration, userInfo interface{})

  // Schedule an interval, which can fire immediately
  NewInterval(duration time.Duration, userInfo interface{}, immediately bool)

  // Schedule a backoff timer with maximum backoff
  NewBackoff(duration time.Duration, max_duration time.Duration, userInfo interface{})

You can subscribe to emitted events which are as follows:

type TimerEvent interface {

  // Provide the timestamp for the event
  Timestamp() time.Time

  // The user info for the event
  UserInfo() interface{}

  // Cancel the timer which fired this event


Copyright 2016-2018 David Thorpe All Rights Reserved

Redistribution and use in source and binary forms, with or without 
modification, are permitted with some conditions. 

This repository is released under the BSD License. Please see the file LICENSE for a copy of this license and for a list of the conditions for redistribution and use.

You can’t perform that action at this time.