Setting up a Go Development Environment
Setting up a Go Development Environment
The sample procedure that follows assumes a Linux-based development system.
Example Procedure for Go
Perform the following procedure to set up a Go environment for developing your GPSS client. This procedure assumes a Linux-based development system.
- Install Go on your development system. For example, to install Go
version 1.14 into your home directory on a CentOS development system:
user@devsys$ wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz user@devsys$ tar xzf go1.14.linux-amd64.tar.gz -C $HOME/ user@devsys$ export GOPATH=$HOME/go user@devsys$ export PATH=$PATH:$GOPATH/bin
These commands download Go, unpack the package into the $HOME/go directory, set up $GOPATH, and add the Go bin directory to your $PATH.
- Install the gRPC protocol buffer compiler version 3 on your development system. Protocol Buffer Compiler Installation in the gRPC documentation provides instructions.
- Install the gRPC protocol compiler plugin for Go, and update your
$PATH so that the protocol compiler can locate the
plugin:
user@devsys$ export GO111MODULE=on user@devsys$ go get github.com/golang/protobuf/protoc-gen-go@v1.3 user@devsys$ export PATH="$PATH:$(go env GOPATH)/bin"
- Create a work directory. For example:
user@devsys$ mkdir $HOME/gpss_job_dev user@devsys$ cd gpss_job_dev user@devsys$ export GPSSJOBDEV_DIR=`pwd`
Examples in this guide reference your work directory. You may consider adding $GPSSJOBDEV_DIR to your .bash_profile or equivalent shell initialization script.
- If you are interested in examining gRPC Go example code, download
the code by cloning the grpc-go github repository.
For example:
user@devsys$ git clone https://github.com/grpc/grpc-go.git
The command clones the repository to a directory named grpc-go in the current directory.
- Prepare the work directory for your GPSS Go client development.
Create a directory for the source code and the job.proto
service definition file. For example:
user@devsys$ mkdir jobclient
- Navigate to your client work directory and copy the job.proto
service definition file to this directory.
Refer to GPSS Streaming Job API Service Definition
if you have not already created the file.
For example:
user@devsys$ cd jobclient user@devsys$ cp <dir>/job.proto .
- Navigate back to your base work directory:
user@devsys$ cd $GPSSJOBDEV_DIR