github.com/snowflakedb/gosnowflake@v1.9.0/README.md (about)

     1  ## Support
     2  
     3  For official support and urgent, production-impacting issues, please [contact Snowflake Support](https://community.snowflake.com/s/article/How-To-Submit-a-Support-Case-in-Snowflake-Lodge).
     4  
     5  # Go Snowflake Driver
     6  
     7  <a href="https://codecov.io/github/snowflakedb/gosnowflake?branch=master">
     8      <img alt="Coverage" src="https://codecov.io/github/snowflakedb/gosnowflake/coverage.svg?branch=master">
     9  </a>
    10  <a href="https://github.com/snowflakedb/gosnowflake/actions?query=workflow%3A%22Build+and+Test%22">
    11      <img src="https://github.com/snowflakedb/gosnowflake/workflows/Build%20and%20Test/badge.svg?branch=master">
    12  </a>
    13  <a href="http://www.apache.org/licenses/LICENSE-2.0.txt">
    14      <img src="http://img.shields.io/:license-Apache%202-brightgreen.svg">
    15  </a>
    16  <a href="https://goreportcard.com/report/github.com/snowflakedb/gosnowflake">
    17      <img src="https://goreportcard.com/badge/github.com/snowflakedb/gosnowflake">
    18  </a>
    19  
    20  This topic provides instructions for installing, running, and modifying the Go Snowflake Driver. The driver supports Go's [database/sql](https://golang.org/pkg/database/sql/) package.
    21  
    22  # Prerequisites
    23  
    24  The following software packages are required to use the Go Snowflake Driver.
    25  
    26  ## Go
    27  
    28  The latest driver requires the [Go language](https://golang.org/) 1.19 or higher. The supported operating systems are Linux, Mac OS, and Windows, but you may run the driver on other platforms if the Go language works correctly on those platforms.
    29  
    30  
    31  # Installation
    32  
    33  If you don't have a project initialized, set it up.
    34  
    35  ```sh
    36  go mod init example.com/snowflake
    37  ```
    38  
    39  Get Gosnowflake source code, if not installed.
    40  
    41  ```sh
    42  go get -u github.com/snowflakedb/gosnowflake
    43  ```
    44  
    45  # Docs
    46  
    47  For detailed documentation and basic usage examples, please see the documentation at
    48  [godoc.org](https://godoc.org/github.com/snowflakedb/gosnowflake/).
    49  
    50  # Sample Programs
    51  
    52  Snowflake provides a set of sample programs to test with. Set the environment variable ``$GOPATH`` to the top directory of your workspace, e.g., ``~/go`` and make certain to
    53  include ``$GOPATH/bin`` in the environment variable ``$PATH``. Run the ``make`` command to build all sample programs.
    54  
    55  ```
    56  make install
    57  ```
    58  
    59  In the following example, the program ``select1.go`` is built and installed in ``$GOPATH/bin`` and can be run from the command line:
    60  
    61  ```
    62  SNOWFLAKE_TEST_ACCOUNT=<your_account> \
    63  SNOWFLAKE_TEST_USER=<your_user> \
    64  SNOWFLAKE_TEST_PASSWORD=<your_password> \
    65  select1
    66  Congrats! You have successfully run SELECT 1 with Snowflake DB!
    67  ```
    68  
    69  # Development
    70  
    71  The developer notes are hosted with the source code on [GitHub](https://github.com/snowflakedb/gosnowflake).
    72  
    73  ## Testing Code
    74  
    75  
    76  Set the Snowflake connection info in ``parameters.json``:
    77  
    78  ```
    79  {
    80      "testconnection": {
    81          "SNOWFLAKE_TEST_USER":      "<your_user>",
    82          "SNOWFLAKE_TEST_PASSWORD":  "<your_password>",
    83          "SNOWFLAKE_TEST_ACCOUNT":   "<your_account>",
    84          "SNOWFLAKE_TEST_WAREHOUSE": "<your_warehouse>",
    85          "SNOWFLAKE_TEST_DATABASE":  "<your_database>",
    86          "SNOWFLAKE_TEST_SCHEMA":    "<your_schema>",
    87          "SNOWFLAKE_TEST_ROLE":      "<your_role>"
    88      }
    89  }
    90  ```
    91  
    92  Install [jq](https://stedolan.github.io/jq) so that the parameters can get parsed correctly, and run ``make test`` in your Go development environment:
    93  
    94  ```
    95  make test
    96  ```
    97  
    98  ## Capturing Code Coverage
    99  
   100  Configure your testing environment as described above and run ``make cov``. The coverage percentage will be printed on the console when the testing completes.
   101  
   102  ```
   103  make cov
   104  ```
   105  
   106  For more detailed analysis, results are printed to ``coverage.txt`` in the project directory.
   107  
   108  To read the coverage report, run:
   109  
   110  ```
   111  go tool cover -html=coverage.txt
   112  ```
   113  
   114  ## Submitting Pull Requests
   115  
   116  You may use your preferred editor to edit the driver code. Make certain to run ``make fmt lint`` before submitting any pull request to Snowflake. This command formats your source code according to the standard Go style and detects any coding style issues.
   117  
   118  ## Runaway `dbus-daemon` processes on certain OS
   119  This only affects certain Linux distributions, one of them is confirmed to be RHEL. Due to a bug in one of the dependencies (`keyring`),
   120  on the affected OS, each invocation of a program depending on gosnowflake (or any other program depending on the same `keyring`),
   121  will generate a new instance of `dbus-daemon` fork which can, due to not being cleaned up, eventually fill the fd limits.
   122  
   123  Until we replace the offending dependency with one which doesn't have the bug, a workaround needs to be applied, which can be:
   124  * cleaning up the runaway processes periodically
   125  * setting envvar `DBUS_SESSION_BUS_ADDRESS=$XDG_RUNTIME_DIR/bus` (if that socket exists, or create it) or even `DBUS_SESSION_BUS_ADDRESS=/dev/null`
   126  
   127  The driver will try to detect automatically, whether your runtime is susceptible for this bug or not, and if so, log a message on `Warning` loglevel.
   128  
   129  Details in [issue 773](https://github.com/snowflakedb/gosnowflake/issues/773)