github.com/osrg/gobgp/v3@v3.30.0/BUILD.md (about)

     1  # Development Guide
     2  
     3  ## Building the development environment
     4  
     5  You need a working [Go environment](https://golang.org/doc/install) (1.16 or newer).
     6  
     7  ```bash
     8  $ git clone git://github.com/osrg/gobgp
     9  $ cd gobgp && go mod download
    10  ```
    11  
    12  Now ready to modify the code and build two binaries, `cmd/gobgp` and `cmd/gobgpd`.
    13  
    14  ## Testing
    15  
    16  Before sending pull request, please make sure that your changes have passed both unit and integration tests. Check out [the tests](https://github.com/osrg/gobgp/blob/master/.github/workflows/ci.yml) triggered by a pull request. If you need to debug the integration tests, it's a good idea to run them [locally](https://github.com/osrg/gobgp/blob/master/test/scenario_test/README.md).
    17  
    18  ## Changing the gRPC API
    19  
    20  If you change the gRPC API, generate `api/*.pb.go` in the following way:
    21  
    22  ```bash
    23  $ ./tools/grpc/genproto.sh
    24  ```
    25  
    26  In order for the script to run, you'll need protoc (version 3.19.1) in your PATH.
    27  
    28  ## Releases
    29  
    30  GoBGP releases are time-based. Minor releases will occur every month ([Semantic Versioning](https://semver.org/)). Major releases occur only when absolutely necessary.
    31  
    32  ## Versioning
    33  
    34  GoBGP has a internal module for version information.
    35  ```internal/pkg/version/version.go``` defines the following variables
    36  
    37  ```MAJOR``` ```MINOR``` ```PATCH``` these constants are for the Semantic Versioning scheme.
    38  These will be updated upon release by maintainer.
    39  
    40  There is also two more variables that are ment to be changed by ldflags;
    41  
    42  ```TAG``` is supposed to be used to denote which branch the build is based upon.
    43  ```SHA``` is supposed to be used to inform about which git sha sum the build is based on.
    44  
    45  ### Examples
    46  
    47  A normal release version of GoBGP Version 2.5.0 should should have;
    48  
    49  ```golang
    50  const MAJOR uint = 2
    51  const MINOR uint = 5
    52  const PATCH uint = 0
    53  ```
    54  
    55  If you have a non-standard release and want to have more build information there is some flags to be used.
    56  `COMMIT`, `IDENTIFIER` and `METADATA`.
    57  
    58  ```bash
    59  go build -ldflags \
    60  	"-X github.com/osrg/gobgp/v3/internal/pkg/version.COMMIT=`git rev-parse --short HEAD` \
    61  	 -X github.com/osrg/gobgp/v3/internal/pkg/version.METADATA="date.`date "+%Y%m%d"`" \
    62  	 -X github.com/osrg/gobgp/v3/internal/pkg/version.IDENTIFIER=alpha"
    63  ```
    64  
    65  This will produce a version number of
    66  
    67  ```3.0.0-alpaha+commit.XXXYYYZZ.date.20211209```
    68  
    69  ## Layout
    70  
    71  The GoBGP project adopts [Standard Go Project Layout](https://github.com/golang-standards/project-layout).
    72  
    73  ## Fuzzing
    74  
    75  Run [Go Fuzzing](https://go.dev/security/fuzz)
    76  
    77  ```bash
    78  go test -fuzz=FuzzParseRTR                      $PWD/pkg/packet/rtr
    79  go test -fuzz=FuzzParseBMPMessage               $PWD/pkg/packet/bmp
    80  go test -fuzz=FuzzParseBGPMessage               $PWD/pkg/packet/bgp
    81  go test -fuzz=FuzzParseLargeCommunity           $PWD/pkg/packet/bgp
    82  go test -fuzz=FuzzParseFlowSpecComponents       $PWD/pkg/packet/bgp
    83  go test -fuzz=FuzzMRT                           $PWD/pkg/packet/mrt
    84  go test -fuzz=FuzzZapi                          $PWD/internal/pkg/zebra
    85  ```