github.com/opensearch-project/opensearch-go/v2@v2.3.0/DEVELOPER_GUIDE.md (about)

     1  - [Developer Guide](#developer-guide)
     2    - [Getting Started](#getting-started)
     3      - [Git Clone OpenSearch Go Client Repository](#git-clone-opensearch-go-client-repository)
     4      - [Install Prerequisites](#install-prerequisites)
     5        - [Go 1.11](#go-111)
     6        - [Docker](#docker)
     7        - [Windows](#windows)
     8      - [Unit Testing](#unit-testing)
     9      - [Integration Testing](#integration-testing)
    10        - [Execute integration tests from your terminal](#execute-integration-tests-from-your-terminal)
    11      - [Lint](#lint)
    12        - [Markdown lint](#markdown-lint)
    13    - [Use an Editor](#use-an-editor)
    14      - [GoLand](#goland)
    15  
    16  # Developer Guide
    17  
    18  So you want to contribute code to the OpenSearch Go Client? Excellent! We're glad you're here. Here's what you need to do:
    19  
    20  ## Getting Started
    21  
    22  ### Git Clone OpenSearch Go Client Repository
    23  
    24  Fork [opensearch-project/opensearch-go](https://github.com/opensearch-project/opensearch-go) and clone locally, e.g. `git clone https://github.com/[your username]/opensearch-go.git`.
    25  
    26  ### Install Prerequisites
    27  
    28  #### Go 1.11
    29  
    30  OpenSearch Go Client builds using [Go](https://golang.org/doc/install) 1.11 at a minimum.
    31  
    32  #### Docker
    33  
    34  [Docker](https://docs.docker.com/install/) is required for building some OpenSearch artifacts and executing integration tests.
    35  
    36  #### Windows
    37  
    38  To build the project on Windows, use [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install), the compatibility layer for running Linux applications.
    39  
    40  Install ```make```
    41  ```
    42  sudo apt install make
    43  ```
    44  
    45  ### Unit Testing
    46  
    47  Go has a simple tool for running tests, and we simplified it further by creating this make command:
    48  
    49  ```
    50  make test-unit
    51  ```
    52  
    53  Individual unit tests can be run with the following command:
    54  
    55  ```
    56  cd folder-path/to/test;
    57  go test -v -run TestName;
    58  ```
    59  
    60  ### Integration Testing
    61  
    62  In order to test opensearch-go client, you need a running OpenSearch cluster. You can use Docker to accomplish this. The [Docker Compose file](.ci/opensearch/docker-compose.yml) supports the ability to run integration tests for the project in local environments. If you have not installed docker-compose, you can install it from this [link](https://docs.docker.com/compose/install/).
    63  
    64  In order to differentiate unit tests from integration tests, Go has a built-in mechanism for allowing you to logically separate your tests with [build tags](https://pkg.go.dev/cmd/go#hdr-Build_constraints). The build tag needs to be placed as close to the top of the file as possible, and must have a blank line beneath it. Hence, create all integration tests with build tag 'integration'.
    65  
    66  #### Execute integration tests from your terminal
    67  
    68  1. Run below command to start containers. By default, it will launch latest OpenSearch cluster.
    69     ```
    70     make cluster.build cluster.start
    71     ```
    72  2. Run all integration tests.
    73     ```
    74     make test-integ race=true
    75     ```
    76  3. Stop and clean containers.
    77     ```
    78     make cluster.stop cluster.clean
    79     ```
    80  
    81  ## Lint
    82  
    83  To keep all the code in a certain uniform format, it was decided to use some writing rules. If you wrote something wrong, it's okay, you can simply run the script to check the necessary files, and optionally format the content. But keep in mind that all these checks are repeated on the pipeline, so it's better to check locally.
    84  
    85  ### Markdown lint
    86  
    87  To check the markdown files, run the following command:
    88  
    89  ```
    90  make lint.markdown
    91  ```
    92  
    93  ## Use an Editor
    94  
    95  ### GoLand
    96  
    97  You can import the OpenSearch project into GoLand as follows:
    98  
    99  1. Select **File | Open**
   100  2. In the subsequent dialog navigate to the ~/go/src/opensearch-go and click **Open**
   101  
   102  After you have opened your project, you need to specify the location of the Go SDK. You can either specify a local path to the SDK or download it. To set the Go SDK, navigate to **Go | GOROOT** and set accordingly.