keep-network / keep-common

Common libraries and tools used across Keep repositories
MIT License
5 stars 14 forks source link

= keep-common

https://github.com/keep-network/keep-common/actions/workflows/client.yml[image:https://img.shields.io/github/actions/workflow/status/keep-network/keep-common/client.yml?branch=main&event=push&label=Go build[Go build status]] https://docs.threshold.network[image:https://img.shields.io/badge/docs-website-green.svg[Docs]] https://discord.gg/threshold[image:https://img.shields.io/badge/chat-Discord-5865f2.svg[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 ./...`