Skip to content

Common libraries and tools used across Keep repositories

License

Notifications You must be signed in to change notification settings

keep-network/keep-common

Repository files navigation

keep-common

Go build status Docs Chat with us on Discord

Common libraries and tools used across Keep repositories.

Directory structure

The directory structure used in the keep-common repository is the same as used on other Keep repositories, and very similar to that used in other Go projects:

keep-common/
  tools/ (1)
    generators/ (2)
  pkg/ (3)
    chain/
      chain.go, *.go (4)
      ethereum/
        gen/
          gen.go (5)
    relay/
      relay.go, *.go
  1. Keep tools have categorized directories here, which are typically Go commands that can be used from other repositories.

  2. Code generators in particular live in this subtree.

  3. All additional Go packages live in pkg/.

  4. The high-level interfaces for a package mypackage live in mypackage.go. Packages like chain are interface packages that expose a common interface to network and blockchain layers, for example. Their subpackages provide particular implementations of these common interfaces, if these are considered shared implementations..

  5. When a package requires generated code, it should have a subpackage named gen/. This subpackage should contain a single file, gen.go, with a // go:generate annotation to trigger appropriate code generation. All code generation is done with a single invocation of go generate at build time.

Installation

  • Clone this repo

  • Install go v1.18: $ brew install go@1.18

  • Generate go files: $ go generate ./…​/gen

  • Build the project: $ go build ./…​

  • Run tests: $ go test ./…​