Skip to main content

Contributing

If you want to contribute to this repository, consider posting a bug report, feature request, or a pull request.

You can talk to us directly on our Discord server, in the #smartcontracts-dev channel.

Creating a Pull Request

Please base your work on the develop branch.

Before creating a pull request ensure that all tests pass locally, and that the linter reports no violations.

Running Tests

To run tests locally, execute one of the following commands:

go test -tags rocksdb,builtin_static ./...

or, as an alternative:

make test

The commands above only trigger lightweight tests. If you have introduced major changes, consider running the whole test suite instead. That it will much longer (and will time out after an hour).

::: warn

Check that the database.inMemory parameter is set to false (default) before running the complete test suite. See the source code for details.

:::

make test-full

Running the Linter

Setup

Step 1: Install golintci

See the provider instructions on how to install golintci.

Step 2: Set Up Your Environment

See the provider instructions on how to integrate golintci into your source code editor. You can also find our recommended settings for VS Code and GoLand at the bottom of this article.

Usage

To run the linter locally, execute:

golangci-lint run

or

make lint

The linter will also automatically run every time you run:

make

False Positives

You can disable false positives by placing a special comment directly above the "violating" element:

//nolint
func foobar() *string {
// ...
}

To be sure that linter will not ignore actual issues in the future, try to suppress only relevant warnings over an element:

//nolint:golint,unused
func neverUsedFoobar() *string {
// ...
}

Visual Studio Code

Adjust your VS Code settings as follows:

// required:
"go.lintTool": "golangci-lint",
// recommended:
"go.lintOnSave": "package"
"go.lintFlags": ["--fix"],
"editor.formatOnSave": true,

GoLand

  1. Install the golintci plugin.

A screenshot that shows how to install golintci in GoLand.

  1. Configure path for golangci.

A screenshot that shows how to configure path for golangci in GoLand.

  1. Add a golangci file watcher with a custom command. We recommend you to use it with the --fix parameter.

A screenshot that shows how to add a golangci file watcher in GoLand.