cryptogarageinc / cfd-go

Crypto Finance Development Kit for Go
MIT License
3 stars 2 forks source link

Crypto Finance Development Kit for Go (CFD-GO)

CFD library for Go.

Overview

This library is development kit for crypto finance application. Useful when developing applications for cryptocurrencies.

Target Network

Support function by cfd

Libraries for each language

Dependencies

Windows (MinGW)

attention: Cgo can only be used on the make platform.

(Recommended to use wsl(Windows Subsystem for Linux), because it can be cumbersome.)

download and install files.

MacOS

# xcode cli tools
xcode-select --install

# install dependencies using Homebrew
brew install cmake go

Linux(Ubuntu)

# install dependencies using APT package Manager
apt-get install -y build-essential golang cmake

cmake version 3.14.2 or lower, download from website and install cmake.

go version 1.11 or lower, get golang.org/dl/go1.12 or higher.


Build

Using CMake

# recommend out of source build
mkdir build && cd $_
# configure & build
cmake .. -DENABLE_SHARED=on -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=off -DENABLE_JS_WRAPPER=off -DENABLE_CAPI=on -DTARGET_RPATH=/usr/local/lib/
make
cd ..
go mod download
go build

CMake options

cmake .. (CMake options) -DENABLE_JS_WRAPPER=off


install / uninstall

On Linux or MacOS, can use install / uninstall.

On Windows, can use releases asset.

Using releases asset

The fastest and easiest way. Target is amd64(x86_64) only.

(cleanup)
./tools/cmake_cleanup.sh
sudo ./tools/cleanup_install_files.sh

(download)
wget https://github.com/cryptogarageinc/cfd-go/releases/download/v0.3.2/cfdgo-v0.3.2-ubuntu2004-gcc-x86_64.zip

(unzip)
sudo unzip -q cfdgo-v0.3.2-ubuntu2004-gcc-x86_64.zip -d /

install (after build)

install for /usr/local/lib.

Using CMake install

Attention: Currently, there is a problem with ExternalProject, so a problem occurs when performing update processing. Please perform cleanup when building before installation.

(cleanup)
./tools/cmake_cleanup.sh
sudo ./tools/cleanup_install_files.sh

(build)
mkdir build && cd build && cmake .. -DENABLE_SHARED=on -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTS=off -DENABLE_JS_WRAPPER=off -DENABLE_CAPI=on -DTARGET_RPATH=/usr/local/lib && make

(install by using makefile)
cd build && sudo make install

(install by using ninja)
cd build && sudo ninja install

cmake version is 3.15 or higher: cmake --install build

Using releases asset (for install)

Target is amd64(x86_64) only.

(cleanup)
./tools/cmake_cleanup.sh
sudo ./tools/cleanup_install_files.sh

(download)
wget https://github.com/cryptogarageinc/cfd-go/releases/download/v0.3.2/cfdgo-v0.3.2-ubuntu2004-gcc-x86_64.zip

(unzip)
sudo unzip -q cfdgo-v0.3.2-ubuntu2004-gcc-x86_64.zip -d /

uninstall

(uninstall by using makefile)
cd build && sudo make uninstall

(uninstall by using ninja)
cd build && sudo ninja uninstall

(uninstall by using script)
sudo ./tools/cleanup_install_files.sh

How to use cfd-go as go module

  1. Once, clone this repository.

  2. Build & install cfd-go(and dependencies).

  3. Modify go.mod file adding cfd-go as go moudle

    go.mod

    require (
      github.com/cryptogarageinc/cfd-go v0.3.2
      ...
    )

    Reference github commit:

    require (
      github.com/cryptogarageinc/cfd-go v1.0.0-0.20191205091101-a48a6a8b1a24
      ...
    )

    (version format: UnknownVersionTag-UtcDate-CommitHash)

  4. Download cfd-go module

    go mod download

Test and Example

Test

test file is cfdgo_test.go . Execute by the following method.

Example


Information for developers

managed files

using library

develop tools

generate from swig.i

attention: At first, install swig and set PATH.

(linux/macos)
./tools/gen_swig.sh

(Windows)
.\tools\gen_swig.bat

formatter

use by makefile:

make

(windows)
mingw32-make

mockgen

make generate

(windows)
mingw32-make generate

develop tools by docker compose

generate from swig.i by docker compose

docker-compose run swig

formatter and mockgen by docker compose

docker-compose run formatter

support compilers

code coverage

(Windows)
.\go_coverage.bat

(Ubuntu / MacOS)
./go_coverage.sh

Note

Git connection

Git repository connections default to HTTPS. However, depending on the connection settings of GitHub, you may only be able to connect via SSH. As a countermeasure, forcibly establish SSH connection by setting CFD_CMAKE_GIT_SSH=1 in the environment variable.

Ignore git update for CMake External Project

Depending on your git environment, you may get the following error when checking out external:

  Performing update step for 'libwally-core-download'
  Current branch cmake_build is up to date.
  No stash entries found.
  No stash entries found.
  No stash entries found.
  CMake Error at /workspace/cfd-core/build/external/libwally-core/download/libwally-core-download-prefix/tmp/libwally-core-download-gitupdate.cmake:133 (message):

    Failed to unstash changes in:
    '/workspace/cfd-core/external/libwally-core/'.

    You will have to resolve the conflicts manually

This phenomenon is due to the git update related command. Please set an environment variable that skips update processing.