The following instructions are useful during development.
Note: This has been tested on Linux and Darwin/macOS. It has not been tested on Windows.
🤔 The following tasks need to be complete before proceeding. These are "one-time tasks" which may already have been completed.
Since the Senzing library is a prerequisite, it must be installed first.
-
Verify Senzing C shared objects, configuration, and SDK header files are installed.
/opt/senzing/er/lib/opt/senzing/er/sdk/c/etc/opt/senzing
-
If not installed, see How to Install Senzing for Go Development.
-
Identify git repository.
export GIT_ACCOUNT=senzing-garage export GIT_REPOSITORY=init-database export GIT_ACCOUNT_DIR=~/${GIT_ACCOUNT}.git export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/${GIT_REPOSITORY}"
-
Using the environment variables values just set, follow steps in clone-repository to install the Git repository.
-
A one-time command to install dependencies needed for
maketargets. Example:cd ${GIT_REPOSITORY_DIR} make dependencies-for-development
-
Install dependencies needed for Go code. Example:
cd ${GIT_REPOSITORY_DIR} make dependencies
-
Run linting. Example:
cd ${GIT_REPOSITORY_DIR} make lint
-
Build the binaries. Example:
cd ${GIT_REPOSITORY_DIR} make clean build
-
The binaries will be found in the
${GIT_REPOSITORY_DIR}/targetdirectory. Example:tree ${GIT_REPOSITORY_DIR}/target
-
Run program. Examples:
-
Linux
${GIT_REPOSITORY_DIR}/target/linux-amd64/init-database -
macOS
${GIT_REPOSITORY_DIR}/target/darwin-amd64/init-database -
Windows
${GIT_REPOSITORY_DIR}/target/windows-amd64/init-database
-
-
Clean up. Example:
cd ${GIT_REPOSITORY_DIR} make clean
-
Run tests. Example:
cd ${GIT_REPOSITORY_DIR} make clean setup test
-
Optional: View the SQLite database. Example:
docker run \ --env SQLITE_DATABASE=G2C.db \ --interactive \ --publish 9174:8080 \ --rm \ --tty \ --volume /tmp/sqlite:/data \ coleifer/sqlite-web
Visit localhost:9174.
Create a code coverage map.
-
Run Go tests. Example:
cd ${GIT_REPOSITORY_DIR} make clean setup coverage
A web-browser will show the results of the coverage. The goal is to have over 80% coverage. Anything less needs to be reflected in testcoverage.yaml.
-
View documentation. Example:
cd ${GIT_REPOSITORY_DIR} make clean documentation
-
If a web page doesn't appear, visit localhost:6060.
-
Senzing documentation will be in the "Third party" section.
github.com>senzing-garage>template-go -
When a versioned release is published with a
v0.0.0format tag, the reference can be found by clicking on the following badge at the top of the README.md page. Example:[![Go Reference Badge]][Go Reference]
-
To stop the
godocserver, runcd ${GIT_REPOSITORY_DIR} make clean
-
Use make target to run a Docker images that builds RPM and DEB files. Example:
cd ${GIT_REPOSITORY_DIR} make package
-
The results will be in the
${GIT_REPOSITORY_DIR}/targetdirectory. Example:tree ${GIT_REPOSITORY_DIR}/target
-
Determine if
init-databaseis installed. Example:apt list --installed | grep init-database -
✏️ Install
init-database. Theinit-database-...filename will need modification. Example:cd ${GIT_REPOSITORY_DIR}/target sudo apt install ./init-database-0.0.0.deb
-
✏️ Identify database. One option is to bring up PostgreSQL as see in Test using Docker-compose stack with PostgreSQL database. Example:
export SENZING_TOOLS_DATABASE_URL=sqlite3://na:na@/tmp/sqlite/G2C.db -
✏️ Run command. Example:
export LD_LIBRARY_PATH=/opt/senzing/er/lib/ init-database
-
Remove
init-databasefrom system. Example:sudo apt-get remove init-database
Make documents visible at hub.senzing.com/init-database.
-
Identify repository. Example:
export GIT_ACCOUNT=senzing export GIT_REPOSITORY=init-database export GIT_ACCOUNT_DIR=~/${GIT_ACCOUNT}.git export GIT_REPOSITORY_DIR="${GIT_ACCOUNT_DIR}/${GIT_REPOSITORY}"
-
Make documents. Example:
export LD_LIBRARY_PATH=/opt/senzing/er/lib/ init-database docs --dir ${GIT_REPOSITORY_DIR}/docs
-
Bring up Docker composition.
docker-compose -f docker-compose/docker-compose.sqlite.yaml up -
Visit database at localhost:9174.
-
Bring down Docker composition.
--volumesis an optional parameter to delete the contents of the volumes.docker-compose -f docker-compose/docker-compose.sqlite.yaml down --volumes
-
Bring up Docker composition.
docker-compose -f docker-compose/docker-compose.postgresql.yaml up -
Visit database at localhost:9171.
- Login
- Username and Password are shown in "Senzing demonstration" box.
- On right-hand side, click on "Servers" > "senzing"
- Password: postgres
- Login
-
Bring down Docker composition.
--volumesis an optional parameter to delete the contents of the volumes.docker-compose -f docker-compose/docker-compose.postgresql.yaml down --volumes
-
Bring up Docker composition.
docker-compose -f docker-compose/docker-compose.mysql.yaml up -
Visit database at localhost:9173.
- Login
- Username:
mysql - Password:
mysql
- Username:
- Login
-
Bring down Docker composition.
--volumesis an optional parameter to delete the contents of the volumes.docker-compose -f docker-compose/docker-compose.mysql.yaml down --volumes
-
Bring up Docker composition.
docker-compose -f docker-compose/docker-compose.mssql.yaml up -
Visit database at localhost:9177.
- Login
- System: MS SQL (beta)
- Server: senzing-mssql
- Username: sa
- Password: Passw0rd
- Database: G2
- Login
-
Bring down Docker composition.
--volumesis an optional parameter to delete the contents of the volumes.docker-compose -f docker-compose/docker-compose.mssql.yaml down --volumes
-
Bring up Docker composition.
docker-compose -f docker-compose/docker-compose.oracle.yaml up -
xxx
-
Bring down Docker composition.
--volumesis an optional parameter to delete the contents of the volumes.docker-compose -f docker-compose/docker-compose.oracle.yaml down --volumes
The following instructions show how to bring up a test stack to be used
in testing the sz-sdk-go-core packages.
-
Identify a directory to place docker-compose artifacts. The directory specified will be deleted and re-created. Example:
export SENZING_DEMO_DIR=~/my-senzing-demo -
Bring up the docker-compose stack. Example:
export PGADMIN_DIR=${SENZING_DEMO_DIR}/pgadmin export POSTGRES_DIR=${SENZING_DEMO_DIR}/postgres export RABBITMQ_DIR=${SENZING_DEMO_DIR}/rabbitmq export SENZING_VAR_DIR=${SENZING_DEMO_DIR}/var export SENZING_UID=$(id -u) export SENZING_GID=$(id -g) rm -rf ${SENZING_DEMO_DIR:-/tmp/nowhere/for/safety} mkdir ${SENZING_DEMO_DIR} mkdir -p ${PGADMIN_DIR} ${POSTGRES_DIR} ${RABBITMQ_DIR} ${SENZING_VAR_DIR} chmod -R 777 ${SENZING_DEMO_DIR} curl -X GET \ --output ${SENZING_DEMO_DIR}/docker-versions-stable.sh \ https://raw.githubusercontent.com/senzing-garage/knowledge-base/main/lists/docker-versions-stable.sh source ${SENZING_DEMO_DIR}/docker-versions-stable.sh curl -X GET \ --output ${SENZING_DEMO_DIR}/docker-compose.yaml \ "https://raw.githubusercontent.com/senzing-garage/docker-compose-demo/main/resources/postgresql/docker-compose-postgresql-uninitialized.yaml" cd ${SENZING_DEMO_DIR} sudo --preserve-env docker-compose up
-
In a separate terminal window, set environment variables. Identify Database URL of database in docker-compose stack. Example:
export LOCAL_IP_ADDRESS=$(curl --silent https://raw.githubusercontent.com/senzing-garage/knowledge-base/main/gists/find-local-ip-address/find-local-ip-address.py | python3 -) export SENZING_TOOLS_DATABASE_URL=postgresql://postgres:postgres@${LOCAL_IP_ADDRESS}:5432/er/?sslmode=disable
-
Run tests.
cd ${GIT_REPOSITORY_DIR} make clean test
-
Optional: View the PostgreSQL database.
Visit localhost:9171. For the initial login, review the instructions at the top of the web page. For server password information, see the
POSTGRESQL_POSTGRES_PASSWORDvalue in${SENZING_DEMO_DIR}/docker-compose.yaml. Usually, it's "postgres". -
Cleanup.
cd ${SENZING_DEMO_DIR} sudo --preserve-env docker-compose down cd ${GIT_REPOSITORY_DIR} make clean