go-common

module
v0.0.0-...-8d1786a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2020 License: Apache-2.0

README

Civil Logo


Civil is a decentralized and censorship resistant ecosystem for online Journalism. Read more in our whitepaper.

This repository contains open-source code for common components used in various Civil projects written in Go.

CircleCI Go Report Card Gitter chat Telegram chat

For Civil's main open-source tools and packages, check out http://github.com/joincivil/Civil.

Contributing

Civil's ecosystem is free and open-source, we're all part of it and you're encouraged to be a part of it with us. We are looking to evolve this into something the community will find helpful and effortless to use.

If you're itching to dwelve deeper inside, help wanted and good first issue labels are good places to get started and learn the architecture.

Install Requirements

This project is using make to run setup, builds, tests, etc and has been tested and running on go 1.11.1.

Ensure that your $GOPATH and $GOROOT are setup properly in your shell configuration and that this repo is cloned into the appropriate place in the $GOPATH. i.e. $GOPATH/src/github.com/joincivil/go-common/

To setup the necessary requirements:

make setup

Code Generation

There are a few places where code/artifacts need to be moved or generated before the project can be built, tested, and/or linted. This is likely a place that can be streamlined and improved as time goes on.

The latest generated code is checked into the repository, except for the contract .abi/.bin. The .abi/.bin is only needed to generate the Solidity wrappers.

Contract .abi & .bin

This project relies on artifacts from the main Civil repository http://github.com/joincivil/Civil. NOTE: The .abi/.bin is pre-generated and included in this repository in /abi, so this step can normally be skipped.

If re-generation of the .abi/.bin files is needed, please clone (or have cloned) the Civil repository into a directory accessible by this repository.

To build and copy the Civil contract .abi/.bin files, run the scripts/abi_retrieval.sh script:

scripts/abi_retrieval.sh /full/path/to/main/civil/repo /full/path/to/go-common/abi

The destination directory is generally the go-common/abi directory in this repository. This will produce the .abi & .bin files from the artifacts in the Civil repository.

If there are issues with dependencies while running abi_retrieval.sh, try running the yarn install in the joincivil/Civil repo directly before running abi_retrieval.sh. More information can be found at joincivil/Civil#dev-setup

Solidity Wrappers

There are Solidity wrappers that are created by abigen from the go-ethereum package. To generate, the .abi/.bin files are required in /abi. The wrappers will go into pkg/generated/contract directory and are generated by running:

make generate-civil-contracts

Lint

Check all the packages for linting errors using a variety of linters via golangci-lint. Check the Makefile for the up to date list of linters.

make lint

Build

make build

Testing

Runs the tests and checks code coverage across the project. Produces a coverage.txt file for use later.

make test

Code Coverage Tool

Run make test and launches the HTML code coverage tool.

make cover

Directories

Path Synopsis
cmd
pkg
eth
gen
Package gen contains all the components for code generation.
Package gen contains all the components for code generation.
generated/contract
Code generated by 'gen/libgen' DO NOT EDIT.
Code generated by 'gen/libgen' DO NOT EDIT.
strings
Package strings contains various common utils for strings
Package strings contains various common utils for strings
time
Package time contains various common time separate by utility types
Package time contains various common time separate by utility types

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL