This repo is the home for all of the public go code produced by the Kin Foundation. In addition to various tools and services, this repository is the SDK from which you may develop your own applications that integrate with the Kin network.
This repository depends upon a number of external dependencies, and uses dep to manage them (see installation instructions here).
To satisfy dependencies and populate the vendor
directory run:
$ dep ensure -v
Note that if this hangs indefinitely on your machine, you might need to check if mercurial is installed.
You can use dep yourself in your project and add Kin go as a vendor'd dependency, or you can just drop this repos as $GOPATH/src/github.com/kinecosystem/go
to import it the canonical way (you still need to run dep ensure -v
).
When creating this project, we had to decide whether or not we committed our external dependencies to the repo. We decided that we would not, by default, do so. This lets us avoid the diff churn associated with updating dependencies while allowing an acceptable path to get reproducible builds. To do so, simply install dep and run dep ensure -v
in your checkout of the code. We realize this is a judgement call; Please feel free to open an issue if you would like to make a case that we change this policy.
In addition to the other top-level packages, there are a few special directories that contain specific types of packages:
http.Handler
that make it easier to incorporate portions of the Kin protocol into your own http server. db
or log
. Each of these directories have their own README file that explain further the nature of their contents.
In addition to the packages described above, this repository contains various packages related to working with the Kin network from a go program. It's recommended that you use godoc to browse the documentation for each.
While much of the code in individual packages is organized based upon different developers' personal preferences, many of the packages follow a simple convention for organizing the declarations inside of a package that aim to aid in your ability to find code.
In each package, there may be one or more of a set of common files:
main.go
file. This file contains the package documentation (unless a separate doc.go
file is used), all of the exported vars, consts, types and funcs for the package. main.go
file of a packageIn addition to the above files, a package often has files that contains code that is specific to one declared type. This file uses the snake case form of the type name (for example loggly_hook.go
would correspond to the type LogglyHook
). This file should contain method declarations, interface implementation assertions and any other declarations that are tied solely to that type.
Each non-test file can have a test counterpart like normal, whose name ends with _test.go
. The common files described above also have their own test counterparts... for example internal_test.go
should contains tests that test unexported behavior and more commonly test helpers that are unexported.
Generally, file contents are sorted by exported/unexported, then declaration type (ordered as consts, vars, types, then funcs), then finally alphabetically.
Often, we provide test packages that aid in the creation of tests that interact with our other packages. For example, the support/db
package has the support/db/dbtest
package underneath it that contains elements that make it easier to test code that accesses a SQL database. We've found that this pattern of having a separate test package maximizes flexibility and simplifies package dependencies.