Skip to content

Commit

Permalink
Add docs about import order to HACKING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
barrettj12 committed Jul 5, 2023
1 parent f9c0755 commit d213066
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,39 @@ $ curl --unix-socket ~/pebble/.pebble.socket 'http://localhost/v1/services?names
```


## Code style

Pebble imports should be arranged in three groups:
- standard library imports
- third-party / non-Pebble imports
- Pebble imports (i.e. those prefixed with `github.com/canonical/pebble`)

Imports should be sorted alphabetically within each group.

We use the [`gopkg.in/check.v1`](https://pkg.go.dev/gopkg.in/check.v1) package for testing. Inside a test file, import this as follows:
```go
. "gopkg.in/check.v1"
```
so that identifiers from that package will be added to the local namespace.


Here is an example of correctly arranged imports:

```go
import (
"fmt"
"net"
"os"

"github.com/gorilla/mux"
. "gopkg.in/check.v1"

"github.com/canonical/pebble/internals/systemd"
"github.com/canonical/pebble/internals/testutil"
)
```


## Running the tests

Pebble has a suite of Go unit tests, which you can run using the regular `go test` command. To test all packages in the Pebble repository:
Expand Down

0 comments on commit d213066

Please sign in to comment.