This guide will describe how to setup your environment to enable contribution to development.
a. Follow official golang installation guide. b. Use update-golang script.
Both options install golang to
/usr/local/go. For everything to work correctly you must add path to go to your environment PATH variable. Add the following line to your
(Restart may be needed for the changes in the
.profile file to be applied). To test that go is setup correctly run in terminal:
The command should succeed and print out the currently installed version of go.
Some parts of the
hub repository are sensitive to location of the code. The source code of the repository must reside in your go workspace, at
Manually create the folder structure and use
git clone --recursive to download source code and all dependencies:
cd $HOME/go mkdir -p src/github.com/plgd-dev cd src/github.com/plgd-dev git clone --recursive email@example.com:plgd-dev/hub.git
After a successful checkout use
go mod download and
go mod tidy commands to download dependencies.
cd $HOME/go/src/plgd-dev/hub go mod download go mod tidy
Execute the following command in terminal:
sudo apt install build-essential
Follow official docker installation guide.
Additionally, after succesfull docker installation you must allow non-root users to use docker. To do so follow Manage Docker as a non-root user guide.
Services use protobuf messages to communicate. To generate
.pb files from
protoc binary is used in Makefiles. To install latest protoc do the following steps:
.zipfile contains two folders:
include. a) move the contents of the extracted
/usr/local/binb) move the contents of the extracted
0755(read+write+execute for owner, read+execute for group and world)
These steps are automated in convenience script
To automatically generate API clients and server stubs in golang protoc plugins from gRPC-Gateway are used. To install them run:
go install github.com/grpc-ecosystem/grpc-gateway/main/protoc-gen-grpc-gateway \ github.com/grpc-ecosystem/grpc-gateway/main/protoc-gen-openapiv2 \ google.golang.org/protobuf/cmd/protoc-gen-go \ google.golang.org/grpc/cmd/protoc-gen-go-grpc
Your system should now be fully setup and capable of compiling all of the code in the repository.
Test go compilation by running unit tests:
The command should succeed and execute all available unit test in the repository.
Test protobuf generation:
plgd makes it simpler to build a successful IoT initiative – to create a proof of concept, evaluate, optimize, and scale.