... | ... | @@ -83,7 +83,7 @@ Stork build system provides the `rake fmt:backend` command to format the Golang |
|
|
|
|
|
## Imports Order
|
|
|
|
|
|
We first include the packages from the standard library, then 3rd party packages, and at the end, our project packages.
|
|
|
We first include the packages from the standard library, then 3rd party packages, and at the end, our project packages. The packages must be imported in an alphabetical order within each of these groups.
|
|
|
|
|
|
## File Names
|
|
|
|
... | ... | @@ -105,6 +105,10 @@ According to [Effective Go](https://go.dev/doc/effective_go), one-method interfa |
|
|
|
|
|
Another frequent case is an interface with multiple methods returning different properties. Such interfaces should be named after the object these properties belong to, plus the word `Accessor`. For example, an interface returning subnet properties can be called `SubnetAccessor`.
|
|
|
|
|
|
## Mock File Names
|
|
|
|
|
|
We often use interface mocking in our unit tests to simulate returning different sets of values from the interfaces. The mocks are generated and by the `MockGen` framework, which puts their implementations in the files named by the developers. The developers MUST use the `_test.go` as a suffix for these file names. Note that it implies that the mock implementation must be always stored in the same package as the tests using the mock.
|
|
|
|
|
|
## Getters and Setters
|
|
|
|
|
|
We require that getters and setters in Stork include the `Get` and `Set` prefixes. Even though the Effective Go document explicitly says that these prefixes are neither idiomatic nor required, we decided to use them because they make clear distinction between the getters and setters. Also, that's the naming convention used in other ISC projects.
|
... | ... | |