code.vegaprotocol.io/vega@v0.79.0/GETTING_STARTED.md (about)

     1  # Getting Started
     2  
     3  This document is a guide for new Go developers.
     4  
     5  It starts with a vanilla Linux or MacOSX installation, and runs through all the
     6  steps needed to build and test vega.
     7  
     8  ## Installing Golang
     9  
    10  Almost all of vega (including tools not in this repo) are written in Go, so you will need it installed locally. The version targeted can be found in the `go.mod` at the root of this repo, but realistically there is not much harm in having a slightly newer version.
    11  
    12  The Go tool-chain can be installed via an OS package manager, or directly from https://golang.org/dl/. Use whichever you are most comfortable with. See also the [Golang installation guide](https://golang.org/doc/install) for more information.
    13  
    14  After installation set the following environment variables:
    15  
    16  ```bash
    17  # Add to $HOME/.bashrc:
    18  export GOROOT="/path/to/your/go/install"
    19  export GOPATH="$HOME/go"
    20  export PATH="$PATH:$GOROOT/bin"
    21  ```
    22  
    23  Now run the following to ensure everything exists and is in working order:
    24  
    25  ```bash
    26  $ which go gofmt
    27  /path/to/your/go/install/bin/go
    28  /path/to/your/go/install/bin/gofmt
    29  
    30  $ go version
    31  go version go[INSTALLED VERSION] linux/amd64
    32  ```
    33  ## GitHub Authentication and Git configurations
    34  
    35  To be able to clone/push/pull from github in a seamless way, it is worth setting up SSH keys in github so that authentication can happen magically. If not already set up, following this guide (https://github.com/settings/keys)
    36  
    37  You also now need to tell git to prefer SSH over HTTPS when accessing all `vegaprotocol` repositories by doing the following:
    38  
    39  ```bash
    40  git config --global url."git@github.com:vegaprotocol".insteadOf "https://github.com/vegaprotocol"
    41  ```
    42  
    43  This is necessary since some of the repos that `vega` depends on in `vegaprotocol` are private repositories. The git setting ensure that `go get` now knows to use `ssh` too.
    44  
    45  
    46  ## MacOS Requirements
    47  
    48  In order to get the required tools for MacOS make sure to install the following packages:
    49  ### `bash`
    50  ```bash
    51  $ brew install bash
    52  # now make sure you are using bash, not zsh (this can be tricky to modify)
    53  ```
    54  
    55  ### `jq`
    56  ```bash
    57  $ brew install jq
    58  ```
    59  
    60  ### `gnu-sed`
    61  ```bash
    62  $ brew install gnu-sed
    63  # read the stdout, cos it asks you to modify `.profile` or `.bash_profile`
    64  # e.g. add export PATH="/usr/local/Cellar/gnu-sed/4.8/libexec/gnubin:$PATH"
    65  ```
    66  
    67  ### `coreutils`
    68  ```bash
    69  $ brew install coreutils
    70  # again read the stdout - similar changes required to modify `.profile` or `.bash_profile`
    71  # e.g export PATH="/usr/local/Cellar/coreutils/9.0/libexec/gnubin:$PATH" 
    72  ```
    73  
    74  ### `findutils`
    75  ```bash
    76  $ brew install findutils
    77  # again read the stdout to modify `.profile` or `.bash_profile`
    78  # e.g. export PATH="/usr/local/Cellar/findutils/4.8.0_1/libexec/gnubin:$PATH"
    79  ```
    80  
    81  ## Building and Testing Vega
    82  
    83  Go makes building easy:
    84  
    85  ```bash
    86  git clone git@github.com:vegaprotocol/vega.git
    87  cd vega
    88  
    89  go install ./...
    90  
    91  # check binary works
    92  vega --help
    93  ```
    94  
    95  And equally also makes testing easy:
    96  
    97  ```bash
    98  go test ./...
    99  go test -race ./...
   100  go test -v ./integration/... --godog.format=pretty
   101  ```
   102  
   103  There is also a `Makefile` which contain the above commands and also some other useful things.
   104  
   105  ## Running A Vega Node Locally
   106  
   107  With vega built it is technically possible to run the node locally, but it is a bit cumbersome. The steps are here if you are feeling brave: https://github.com/vegaprotocol/networks
   108  
   109  An alternative is to use `VegaCapsule` (VC) which will allow you to configure and run a Vega network locally. For more information and  detailed information to get started see the [VC repo](https://github.com/vegaprotocol/vegacapsule)