From b9b5524e7332639a0c8f266964d58e0733d928f7 Mon Sep 17 00:00:00 2001 From: Michael Dockter Date: Fri, 2 Aug 2024 14:22:20 -0400 Subject: [PATCH] 158 dockter 1 (#159) * #158 Savepoint * #158 Fine tuning * #158 Add footnotes * #158 Add footnotes * #158 Savepoint * #158 Improve documentation * #158 Improve documentation * #158 Reorganize * #158 Reorganize * #158 Reorganize * #158 Reorganize * #158 Reorganize * #158 Reorganize * #158 Reorganize * #158 Update license * #158 Add godoc * #158 uncomment database url --- .github/dependabot.yml | 10 ++- .github/workflows/go-test-darwin.yaml | 2 +- .gitignore | 1 + CHANGELOG.md | 6 +- CONTRIBUTING.md | 50 +++++++++------ Dockerfile | 21 ++++--- Makefile | 87 +++++++++++++++++--------- README.md | 35 ++++++++--- docker-compose.test.yaml | 6 ++ docs/README.md | 7 ++- docs/development.md | 72 ++++++++++++++------- docs/examples.md | 10 --- makefiles/darwin.mk | 8 +-- makefiles/darwin_arm64.mk | 3 +- makefiles/darwin_x86_64.mk | 2 +- makefiles/linux.mk | 5 +- makefiles/linux_arm64.mk | 2 +- makefiles/linux_x86_64.mk | 2 +- makefiles/windows.mk | 6 +- makefiles/windows_arm64.mk | 2 +- makefiles/windows_x86_64.mk | 2 +- testdata/senzing-license/g2.lic | Bin 1092 -> 1092 bytes testdata/sqlite/G2C.db | Bin 245760 -> 48128 bytes 23 files changed, 214 insertions(+), 125 deletions(-) create mode 100644 docker-compose.test.yaml diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e2a98a1..ea91495 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,10 +3,14 @@ version: 2 updates: - - package-ecosystem: "github-actions" - directory: "/" + - package-ecosystem: github-actions + directory: / schedule: - interval: "daily" + interval: daily + - package-ecosystem: docker + directory: / + schedule: + interval: daily - package-ecosystem: gomod directory: / schedule: diff --git a/.github/workflows/go-test-darwin.yaml b/.github/workflows/go-test-darwin.yaml index b3940e1..1424c7b 100644 --- a/.github/workflows/go-test-darwin.yaml +++ b/.github/workflows/go-test-darwin.yaml @@ -5,7 +5,7 @@ on: [pull_request, workflow_dispatch] env: DYLD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos LD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos - SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@nowhere/tmp/sqlite/G2C.db" + SENZING_TOOLS_DATABASE_URL: sqlite3://na:na@nowhere/tmp/sqlite/G2C.db permissions: contents: read diff --git a/.gitignore b/.gitignore index 938d36d..950a688 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,7 @@ go.work # Makefile target/ +.coverage cover.out coverage.html coverage.out diff --git a/CHANGELOG.md b/CHANGELOG.md index 93b6169..2bfbfc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,18 +8,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Thing 6 - Thing 5 -- Thing 4 ## [1.0.1] - yyyy-mm-dd ### Added to 1.0.1 -- Thing 3 +- Thing 4 ### Fixed in 1.0.1 -- Thing 2 +- Thing 3 ## [1.0.0] - yyyy-mm-dd diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 89228e3..e9d74bd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,15 +2,15 @@ Welcome to the project! -We encourage contribution in a manner consistent with the [Code of Conduct](CODE_OF_CONDUCT.md). +We encourage contribution in a manner consistent with the [Code of Conduct]. The following will guide you through the process. There are a number of ways you can contribute: -1. [Asking questions](#questions) -1. [Requesting features](#feature-requests) -1. [Reporting bugs](#bug-reporting) -1. [Contributing code or documentation](#contributing-code-or-documentation) +1. [Asking questions] +1. [Requesting features] +1. [Reporting bugs] +1. [Contributing code or documentation] ## License Agreements @@ -23,19 +23,19 @@ A license agreement is not needed for submitting feature request, bug reporting, ### Individual Contributor License Agreement In order to contribute to this repository, an -[Individual Contributor License Agreement (ICLA)](.github/senzing-individual-contributor-license-agreement.pdf) +[Individual Contributor License Agreement (ICLA)] must be completed, submitted and accepted. ### Corporate Contributor License Agreement If the contribution to this repository is on behalf of a company, a -[Corporate Contributor License Agreement (CCLA)](.github/senzing-corporate-contributor-license-agreement.pdf) +[Corporate Contributor License Agreement (CCLA)] must also be completed, submitted and accepted. ### Project License Agreement The license agreement for this repository is stated in the -[LICENSE](LICENSE) file. +[LICENSE] file. ## Questions @@ -50,7 +50,7 @@ TODO: Instead, use ??? All feature requests are "GitHub issues". To request a feature, create a -[GitHub issue](https://help.github.com/articles/creating-an-issue/) +[GitHub issue] in this repository. When creating an issue, there will be a choice to create a "Bug report" or a "Feature request". @@ -59,11 +59,8 @@ Choose "Feature request". ## Bug Reporting All bug reports are "GitHub issues". -Before reporting on a bug, check to see if it has -[already been reported](https://github.com/search?q=+is%3Aissue+user%3Asenzing). -To report a bug, create a -[GitHub issue](https://help.github.com/articles/creating-an-issue/) -in this repository. +Before reporting on a bug, check to see if it has [already been reported]. +To report a bug, create a [GitHub issue] in this repository. When creating an issue, there will be a choice to create a "Bug report" or a "Feature request". Choose "Bug report". @@ -71,8 +68,8 @@ Choose "Bug report". ## Contributing code or documentation To contribute code or documentation to the repository, you must have -[License Agreements](#license-agreements) in place. -This needs to be complete before a [Pull Request](#pull-requests) can be accepted. +[License Agreements] in place. +This needs to be complete before a [Pull Request] can be accepted. ### Setting up a development environment @@ -116,9 +113,22 @@ TODO: ### Pull Requests Code in the main branch is modified via GitHub pull request. -Follow GitHub's -[Creating a pull request from a branch](https://help.github.com/articles/creating-a-pull-request/) -or -[Creating a pull request from a fork](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) instructions. +Follow GitHub's [Creating a pull request from a branch] or +[Creating a pull request from a fork] instructions. Accepting pull requests will be at the discretion of Senzing, Inc. and the repository owner(s). + +[already been reported]: https://github.com/search?q=+is%3Aissue+user%3Asenzing +[Asking questions]: #questions +[Code of Conduct]: CODE_OF_CONDUCT.md +[Contributing code or documentation]: #contributing-code-or-documentation +[Corporate Contributor License Agreement (CCLA)]: .github/senzing-corporate-contributor-license-agreement.pdf +[Creating a pull request from a branch]: https://help.github.com/articles/creating-a-pull-request/ +[Creating a pull request from a fork]: https://help.github.com/articles/creating-a-pull-request-from-a-fork/ +[GitHub issue]: https://help.github.com/articles/creating-an-issue/ +[Individual Contributor License Agreement (ICLA)]: .github/senzing-individual-contributor-license-agreement.pdf +[LICENSE]: LICENSE +[License Agreements]: #license-agreements +[Pull Request]: #pull-requests +[Reporting bugs]: #bug-reporting +[Requesting features]: #feature-requests diff --git a/Dockerfile b/Dockerfile index 2a98fd9..a1fd79c 100755 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # Stages # ----------------------------------------------------------------------------- -ARG IMAGE_GO_BUILDER=golang:1.22.3-bullseye +ARG IMAGE_BUILDER=golang:1.22.3-bullseye ARG IMAGE_FINAL=senzing/senzingapi-runtime-staging:latest # ----------------------------------------------------------------------------- @@ -12,15 +12,19 @@ ARG IMAGE_FINAL=senzing/senzingapi-runtime-staging:latest FROM ${IMAGE_FINAL} as senzingapi_runtime # ----------------------------------------------------------------------------- -# Stage: go_builder +# Stage: builder # ----------------------------------------------------------------------------- -FROM ${IMAGE_GO_BUILDER} as go_builder +FROM ${IMAGE_BUILDER} as builder ENV REFRESHED_AT=2024-07-01 LABEL Name="senzing/go-builder" \ Maintainer="support@senzing.com" \ Version="0.1.0" +# Run as "root" for system installation. + +USER root + # Copy local files from the Git repository. COPY ./rootfs / @@ -57,15 +61,19 @@ LABEL Name="senzing/template-go" \ HEALTHCHECK CMD ["/app/healthcheck.sh"] USER root -# Copy local files from the Git repository. +# Install packages via apt-get. + +# Copy files from repository. COPY ./rootfs / # Copy files from prior stage. -COPY --from=go_builder "/output/linux/template-go" "/app/template-go" +COPY --from=builder "/output/linux/template-go" "/app/template-go" -# Install packages via apt-get. +# Run as non-root container + +USER 1001 # Runtime environment variables. @@ -73,6 +81,5 @@ ENV LD_LIBRARY_PATH=/opt/senzing/g2/lib/ # Runtime execution. -USER 1001 WORKDIR /app ENTRYPOINT ["/app/template-go"] diff --git a/Makefile b/Makefile index ffafccc..3bdc956 100644 --- a/Makefile +++ b/Makefile @@ -15,13 +15,16 @@ PROGRAM_NAME := $(shell basename `git rev-parse --show-toplevel`) MAKEFILE_PATH := $(abspath $(firstword $(MAKEFILE_LIST))) MAKEFILE_DIRECTORY := $(shell dirname $(MAKEFILE_PATH)) TARGET_DIRECTORY := $(MAKEFILE_DIRECTORY)/target +DIST_DIRECTORY := $(MAKEFILE_DIRECTORY)/dist +BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//') +BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//') +BUILD_VERSION := $(shell git describe --always --tags --abbrev=0 --dirty | sed 's/v//') DOCKER_CONTAINER_NAME := $(PROGRAM_NAME) DOCKER_IMAGE_NAME := senzing/$(PROGRAM_NAME) DOCKER_BUILD_IMAGE_NAME := $(DOCKER_IMAGE_NAME)-build -BUILD_VERSION := $(shell git describe --always --tags --abbrev=0 --dirty | sed 's/v//') -BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//') -BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's/^ *//') GIT_REMOTE_URL := $(shell git config --get remote.origin.url) +GIT_REPOSITORY_NAME := $(shell basename `git rev-parse --show-toplevel`) +GIT_VERSION := $(shell git describe --always --tags --long --dirty | sed -e 's/\-0//' -e 's/\-g.......//') GO_PACKAGE_NAME := $(shell echo $(GIT_REMOTE_URL) | sed -e 's|^git@github.com:|github.com/|' -e 's|\.git$$||' -e 's|Senzing|senzing|') PATH := $(MAKEFILE_DIRECTORY)/bin:$(PATH) @@ -33,7 +36,9 @@ GO_ARCH = $(word 2, $(GO_OSARCH)) # Conditional assignment. ('?=') # Can be overridden with "export" +# Example: "export LD_LIBRARY_PATH=/path/to/my/senzing/g2/lib" +DOCKER_IMAGE_TAG ?= $(GIT_REPOSITORY_NAME):$(GIT_VERSION) GOBIN ?= $(shell go env GOPATH)/bin LD_LIBRARY_PATH ?= /opt/senzing/g2/lib @@ -63,10 +68,11 @@ hello-world: hello-world-osarch-specific # Dependency management # ----------------------------------------------------------------------------- -.PHONY: dependencies-for-make -dependencies-for-make: +.PHONY: dependencies-for-development +dependencies-for-development: @go install github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest @go install github.com/vladopajic/go-test-coverage/v2@latest + @go install golang.org/x/tools/cmd/godoc@latest @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.58.1 @@ -88,8 +94,7 @@ setup: setup-osarch-specific # ----------------------------------------------------------------------------- .PHONY: lint -lint: - @${GOBIN}/golangci-lint run --config=.github/linters/.golangci.yaml +lint: golangci-lint # ----------------------------------------------------------------------------- # Build @@ -97,7 +102,7 @@ lint: PLATFORMS := darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 windows/amd64 windows/arm64 $(PLATFORMS): - @echo Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME) + $(info Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME)) @GOOS=$(GO_OS) GOARCH=$(GO_ARCH) go build -o $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME) @@ -128,6 +133,23 @@ build-scratch: .PHONY: docker-build docker-build: docker-build-osarch-specific +# ----------------------------------------------------------------------------- +# Run +# ----------------------------------------------------------------------------- + +.PHONY: docker-run +docker-run: + @docker run \ + --interactive \ + --rm \ + --tty \ + --name $(DOCKER_CONTAINER_NAME) \ + $(DOCKER_IMAGE_NAME) + + +.PHONY: run +run: run-osarch-specific + # ----------------------------------------------------------------------------- # Test # ----------------------------------------------------------------------------- @@ -135,6 +157,11 @@ docker-build: docker-build-osarch-specific .PHONY: test test: test-osarch-specific + +.PHONY: docker-test +docker-test: + @docker-compose -f docker-compose.test.yaml up + # ----------------------------------------------------------------------------- # Coverage # ----------------------------------------------------------------------------- @@ -149,23 +176,6 @@ check-coverage: @go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./... @${GOBIN}/go-test-coverage --config=.github/coverage/.testcoverage.yaml -# ----------------------------------------------------------------------------- -# Run -# ----------------------------------------------------------------------------- - -.PHONY: docker-run -docker-run: - @docker run \ - --interactive \ - --rm \ - --tty \ - --name $(DOCKER_CONTAINER_NAME) \ - $(DOCKER_IMAGE_NAME) - - -.PHONY: run -run: run-osarch-specific - # ----------------------------------------------------------------------------- # Documentation # ----------------------------------------------------------------------------- @@ -177,6 +187,10 @@ documentation: documentation-osarch-specific # Package # ----------------------------------------------------------------------------- +.PHONY: package +package: clean package-osarch-specific + + .PHONY: docker-build-package docker-build-package: @docker build \ @@ -189,10 +203,6 @@ docker-build-package: --tag $(DOCKER_BUILD_IMAGE_NAME) \ . - -.PHONY: package -package: package-osarch-specific - # ----------------------------------------------------------------------------- # Clean # ----------------------------------------------------------------------------- @@ -206,10 +216,17 @@ clean: clean-osarch-specific # Utility targets # ----------------------------------------------------------------------------- +.PHONY: docker-rmi-for-build +docker-rmi-for-build: + -docker rmi --force \ + $(DOCKER_IMAGE_NAME):$(GIT_VERSION) \ + $(DOCKER_IMAGE_NAME) + + .PHONY: help help: - @echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)". - @echo "Makefile targets:" + $(info Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)) + $(info Makefile targets:) @$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs @@ -224,3 +241,11 @@ print-make-variables: update-pkg-cache: @GOPROXY=https://proxy.golang.org GO111MODULE=on \ go get $(GO_PACKAGE_NAME)@$(BUILD_TAG) + +# ----------------------------------------------------------------------------- +# Specific programs +# ----------------------------------------------------------------------------- + +.PHONY: golangci-lint +golangci-lint: + @${GOBIN}/golangci-lint run --config=.github/linters/.golangci.yaml diff --git a/README.md b/README.md index ec34eca..27f6dee 100644 --- a/README.md +++ b/README.md @@ -19,13 +19,14 @@ the recommendation is not to use it yet. The template-go repository serves as a starting point for new repositories hosting Go code. It also shows best practices that can be retro-fitted into existing repositories hosting Go code. -[![Go Reference](https://pkg.go.dev/badge/github.com/senzing-garage/template-go.svg)](https://pkg.go.dev/github.com/senzing-garage/template-go) -[![Go Report Card](https://goreportcard.com/badge/github.com/senzing-garage/template-go)](https://goreportcard.com/report/github.com/senzing-garage/template-go) -[![License](https://img.shields.io/badge/License-Apache2-brightgreen.svg)](https://github.com/senzing-garage/template-go/blob/main/LICENSE) +[![Go Reference Badge]][Package reference] +[![Go Report Card Badge]][Go Report Card] +[![License Badge]][License] +[![go-test-linux.yaml Badge]][go-test-linux.yaml] +[![go-test-darwin.yaml Badge]][go-test-darwin.yaml] +[![go-test-windows.yaml Badge]][go-test-windows.yaml] -[![go-test-linux.yaml](https://github.com/senzing-garage/template-go/actions/workflows/go-test-linux.yaml/badge.svg)](https://github.com/senzing-garage/template-go/actions/workflows/go-test-linux.yaml) -[![go-test-darwin.yaml](https://github.com/senzing-garage/template-go/actions/workflows/go-test-darwin.yaml/badge.svg)](https://github.com/senzing-garage/template-go/actions/workflows/go-test-darwin.yaml) -[![go-test-windows.yaml](https://github.com/senzing-garage/template-go/actions/workflows/go-test-windows.yaml/badge.svg)](https://github.com/senzing-garage/template-go/actions/workflows/go-test-windows.yaml) +[![golangci-lint.yaml Badge]][golangci-lint.yaml] ## Overview @@ -35,7 +36,7 @@ Aspects of the template-go repository: 1. **Makefile:** Simplifies development lifecycle commands. 1. **Sample code:** `main.go` and `examplepackage` code examples. 1. **Sample test cases:** `*_test.go` files showing how to write and document test cases. -1. **Sample documentation:** Documentation style conducive to the [Go Package library](https://pkg.go.dev). +1. **Sample documentation:** Documentation style conducive to the [Go Package library]. 1. **Dockerfile:** Containerizing the Go program. 1. **RPM/DEB builds:** Using `package.Dockerfile` to build `RPM` and `DEB` files for installation. 1. **.github/workflows:** GitActions tailored to Go programming. @@ -51,17 +52,31 @@ See [main.go] for an example of use. 1. [Development] 1. [Errors] 1. [Examples] +1. [Package reference] 1. Related artifacts: 1. [DockerHub] - 1. [Helm Chart] [API documentation]: https://pkg.go.dev/github.com/senzing-garage/template-go [Development]: docs/development.md [DockerHub]: https://hub.docker.com/r/senzing/template-go [Errors]: docs/errors.md [Examples]: docs/examples.md -[Helm Chart]: https://github.com/senzing-garage/charts/tree/main/charts/template-go +[Go Package library]: https://pkg.go.dev +[Go Reference Badge]: https://pkg.go.dev/badge/github.com/senzing-garage/template-go.svg +[Go Report Card Badge]: https://goreportcard.com/badge/github.com/senzing-garage/template-go +[Go Report Card]: https://goreportcard.com/report/github.com/senzing-garage/template-go +[go-test-darwin.yaml Badge]: https://github.com/senzing-garage/template-go/actions/workflows/go-test-darwin.yaml/badge.svg +[go-test-darwin.yaml]: https://github.com/senzing-garage/template-go/actions/workflows/go-test-darwin.yaml +[go-test-linux.yaml Badge]: https://github.com/senzing-garage/template-go/actions/workflows/go-test-linux.yaml/badge.svg +[go-test-linux.yaml]: https://github.com/senzing-garage/template-go/actions/workflows/go-test-linux.yaml +[go-test-windows.yaml Badge]: https://github.com/senzing-garage/template-go/actions/workflows/go-test-windows.yaml/badge.svg +[go-test-windows.yaml]: https://github.com/senzing-garage/template-go/actions/workflows/go-test-windows.yaml +[golangci-lint.yaml Badge]: https://github.com/senzing-garage/template-go/actions/workflows/golangci-lint.yaml/badge.svg +[golangci-lint.yaml]: https://github.com/senzing-garage/template-go/actions/workflows/golangci-lint.yaml +[License Badge]: https://img.shields.io/badge/License-Apache2-brightgreen.svg +[License]: https://github.com/senzing-garage/template-go/blob/main/LICENSE [main.go]: main.go -[Senzing Garage]: https://github.com/senzing-garage-garage +[Package reference]: https://pkg.go.dev/github.com/senzing-garage/template-go +[Senzing Garage]: https://github.com/senzing-garage [Senzing Quick Start guides]: https://docs.senzing.com/quickstart/ [Senzing]: https://senzing.com/ diff --git a/docker-compose.test.yaml b/docker-compose.test.yaml new file mode 100644 index 0000000..1200075 --- /dev/null +++ b/docker-compose.test.yaml @@ -0,0 +1,6 @@ +version: '3' +services: + sut: + build: . + entrypoint: [""] + command: ["/app/container-test.sh"] diff --git a/docs/README.md b/docs/README.md index be6db54..a5a756d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,8 @@ # template-go -Placeholder for [GitHub pages](https://pages.github.com/). +Placeholder for [GitHub pages]. -See [https://garage.senzing.com/template-go](https://garage.senzing.com/template-go). +See [GitHub page]. + +[GitHub page]: https://garage.senzing.com/template-go +[GitHub pages]: https://pages.github.com/ diff --git a/docs/development.md b/docs/development.md index ef72431..9044aee 100644 --- a/docs/development.md +++ b/docs/development.md @@ -1,8 +1,20 @@ # template-go development -## Install Go +The following instructions are useful during development. -1. See Go's [Download and install]. +**Note:** This has been tested on Linux and Darwin/macOS. +It has not been tested on Windows. + +## Prerequisites for development + +:thinking: The following tasks need to be complete before proceeding. +These are "one-time tasks" which may already have been completed. + +1. The following software programs need to be installed: + 1. [git] + 1. [make] + 1. [docker] + 1. [go] ## Install Senzing C library @@ -37,7 +49,7 @@ Since the Senzing library is a prerequisite, it must be installed first. ```console cd ${GIT_REPOSITORY_DIR} - make dependencies-for-make + make dependencies-for-development ``` @@ -50,6 +62,17 @@ Since the Senzing library is a prerequisite, it must be installed first. ``` +## Lint + +1. Run linting. + Example: + + ```console + cd ${GIT_REPOSITORY_DIR} + make lint + + ``` + ## Build 1. Build the binaries. @@ -71,10 +94,10 @@ Since the Senzing library is a prerequisite, it must be installed first. ## Run -1. Run the binary. +1. Run program. Examples: - 1. linux + 1. Linux ```console ${GIT_REPOSITORY_DIR}/target/linux-amd64/template-go @@ -88,7 +111,7 @@ Since the Senzing library is a prerequisite, it must be installed first. ``` - 1. windows + 1. Windows ```console ${GIT_REPOSITORY_DIR}/target/windows-amd64/template-go @@ -104,20 +127,9 @@ Since the Senzing library is a prerequisite, it must be installed first. ``` -## Lint - -1. Run Go tests. - Example: - - ```console - cd ${GIT_REPOSITORY_DIR} - make lint - - ``` - ## Test -1. Run Go tests. +1. Run tests. Example: ```console @@ -145,7 +157,7 @@ Create a code coverage map. ## Documentation -1. Start [godoc] documentation server. +1. View documentation. Example: ```console @@ -162,7 +174,7 @@ Create a code coverage map. the reference can be found by clicking on the following badge at the top of the README.md page. Example: - [![Go Reference](https://pkg.go.dev/badge/github.com/senzing-garage/template-go.svg)](https://pkg.go.dev/github.com/senzing-garage/template-go) + [![Go Reference Badge]][Go Reference] 1. To stop the `godoc` server, run @@ -191,6 +203,15 @@ Example: ``` +1. **Optional:** Test using `docker-compose`. + Example: + + ```console + cd ${GIT_REPOSITORY_DIR} + make docker-test + + ``` + ## Package ### Package RPM and DEB files @@ -247,10 +268,15 @@ Example: ``` +## References + [clone-repository]: https://github.com/senzing-garage/knowledge-base/blob/main/HOWTO/clone-repository.md -[Download and install]: https://go.dev/doc/install -[Go]: https://go.dev/ -[godoc]: https://pkg.go.dev/golang.org/x/tools/cmd/godoc +[docker]: https://github.com/senzing-garage/knowledge-base/blob/main/WHATIS/docker.md +[git]: https://github.com/senzing-garage/knowledge-base/blob/main/WHATIS/git.md +[Go Reference Badge]: https://pkg.go.dev/badge/github.com/senzing-garage/template-go.svg +[Go Reference]: https://pkg.go.dev/github.com/senzing-garage/template-go +[go]: https://github.com/senzing-garage/knowledge-base/blob/main/WHATIS/go.md [How to Install Senzing for Go Development]: https://github.com/senzing-garage/knowledge-base/blob/main/HOWTO/install-senzing-for-go-development.md [localhost:6060]: http://localhost:6060/pkg/github.com/senzing-garage/template-go/ +[make]: https://github.com/senzing-garage/knowledge-base/blob/main/WHATIS/make.md [testcoverage.yaml]: ../.github/coverage/testcoverage.yaml diff --git a/docs/examples.md b/docs/examples.md index 68a16bb..8dbf2be 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -1,11 +1 @@ # template-go examples - -## Examples of CLI - -The following examples require initialization described in -[Demonstrate using Command Line Interface](../README.md#demonstrate-using-command-line-interface). - -## Examples of Docker - -The following examples require initialization described in -[Demonstrate using Docker](../README.md#demonstrate-using-docker). diff --git a/makefiles/darwin.mk b/makefiles/darwin.mk index f4032f3..051dd06 100644 --- a/makefiles/darwin.mk +++ b/makefiles/darwin.mk @@ -7,7 +7,7 @@ SENZING_DIR ?= /opt/senzing/g2 SENZING_TOOLS_SENZING_DIRECTORY ?= $(SENZING_DIR) -LD_LIBRARY_PATH := $(SENZING_TOOLS_SENZING_DIRECTORY)/lib:$(SENZING_TOOLS_SENZING_DIRECTORY)/lib/macos +LD_LIBRARY_PATH ?= $(SENZING_TOOLS_SENZING_DIRECTORY)/lib:$(SENZING_TOOLS_SENZING_DIRECTORY)/lib/macos DYLD_LIBRARY_PATH := $(LD_LIBRARY_PATH) SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@nowhere/tmp/sqlite/G2C.db PATH := $(MAKEFILE_DIRECTORY)/bin:/$(HOME)/go/bin:$(PATH) @@ -57,12 +57,12 @@ documentation-osarch-specific: .PHONY: hello-world-osarch-specific hello-world-osarch-specific: - @echo "Hello World, from darwin." + $(info Hello World, from darwin.) .PHONY: package-osarch-specific package-osarch-specific: - @echo No packaging for darwin. + $(info No packaging for darwin.) .PHONY: run-osarch-specific @@ -87,4 +87,4 @@ test-osarch-specific: .PHONY: only-darwin only-darwin: - @echo "Only darwin has this Makefile target." + $(info Only darwin has this Makefile target.) diff --git a/makefiles/darwin_arm64.mk b/makefiles/darwin_arm64.mk index 929ee15..6897c45 100644 --- a/makefiles/darwin_arm64.mk +++ b/makefiles/darwin_arm64.mk @@ -7,6 +7,7 @@ .PHONY: build-osarch-specific build-osarch-specific: darwin/arm64 + .PHONY: docker-build-osarch-specific docker-build-osarch-specific: @docker build \ @@ -21,4 +22,4 @@ docker-build-osarch-specific: .PHONY: only-darwin-arm64 only-darwin-arm64: - @echo "Only darwin-arm64 has this Makefile target." + $(info Only darwin-arm64 has this Makefile target.) diff --git a/makefiles/darwin_x86_64.mk b/makefiles/darwin_x86_64.mk index 6ce96f2..33af8ba 100644 --- a/makefiles/darwin_x86_64.mk +++ b/makefiles/darwin_x86_64.mk @@ -13,4 +13,4 @@ build-osarch-specific: darwin/amd64 .PHONY: only-darwin-x86_64 only-darwin-x86_64: - @echo "Only darwin-x86_64 has this Makefile target." + $(info Only darwin-x86_64 has this Makefile target.) diff --git a/makefiles/linux.mk b/makefiles/linux.mk index cb1a6d3..47dd5cb 100644 --- a/makefiles/linux.mk +++ b/makefiles/linux.mk @@ -21,6 +21,7 @@ clean-osarch-specific: @docker rm --force $(DOCKER_CONTAINER_NAME) 2> /dev/null || true @docker rmi --force $(DOCKER_IMAGE_NAME) $(DOCKER_BUILD_IMAGE_NAME) 2> /dev/null || true @rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true + @rm -f $(MAKEFILE_DIRECTORY)/.coverage || true @rm -f $(MAKEFILE_DIRECTORY)/coverage.html || true @rm -f $(MAKEFILE_DIRECTORY)/coverage.out || true @rm -f $(MAKEFILE_DIRECTORY)/cover.out || true @@ -53,7 +54,7 @@ docker-build-osarch-specific: .PHONY: hello-world-osarch-specific hello-world-osarch-specific: - @echo "Hello World, from linux." + $(info Hello World, from linux.) .PHONY: package-osarch-specific @@ -86,4 +87,4 @@ test-osarch-specific: .PHONY: only-linux only-linux: - @echo "Only linux has this Makefile target." + $(info Only linux has this Makefile target.) diff --git a/makefiles/linux_arm64.mk b/makefiles/linux_arm64.mk index afe03af..5c23d78 100644 --- a/makefiles/linux_arm64.mk +++ b/makefiles/linux_arm64.mk @@ -24,4 +24,4 @@ docker-build-osarch-specific: .PHONY: only-linux-arm64 only-linux-arm64: - @echo "Only linux-arm64 has this Makefile target." + $(info Only linux-arm64 has this Makefile target.) diff --git a/makefiles/linux_x86_64.mk b/makefiles/linux_x86_64.mk index 890ae03..0469668 100644 --- a/makefiles/linux_x86_64.mk +++ b/makefiles/linux_x86_64.mk @@ -15,4 +15,4 @@ build-osarch-specific: linux/amd64 .PHONY: only-linux-x86_64 only-linux-x86_64: - @echo "Only linux-x86_64 has this Makefile target." + $(info Only linux-x86_64 has this Makefile target.) diff --git a/makefiles/windows.mk b/makefiles/windows.mk index da510e4..ed1d210 100644 --- a/makefiles/windows.mk +++ b/makefiles/windows.mk @@ -49,12 +49,12 @@ docker-build-osarch-specific: .PHONY: hello-world-osarch-specific hello-world-osarch-specific: - @echo "Hello World, from windows." + $(info Hello World, from windows.) .PHONY: package-osarch-specific package-osarch-specific: - @echo No packaging for windows. + $(info No packaging for windows) .PHONY: run-osarch-specific @@ -80,4 +80,4 @@ test-osarch-specific: .PHONY: only-windows only-windows: - @echo "Only windows has this Makefile target." + $(info Only windows has this Makefile target.) diff --git a/makefiles/windows_arm64.mk b/makefiles/windows_arm64.mk index bde8009..585cdc7 100644 --- a/makefiles/windows_arm64.mk +++ b/makefiles/windows_arm64.mk @@ -14,4 +14,4 @@ build-osarch-specific: windows/arm64 .PHONY: only-windows-arm64 only-windows-arm64: - @echo "Only windows-arm64 has this Makefile target." + $(info Only windows-arm64 has this Makefile target.) diff --git a/makefiles/windows_x86_64.mk b/makefiles/windows_x86_64.mk index 39f9ac7..de1f472 100644 --- a/makefiles/windows_x86_64.mk +++ b/makefiles/windows_x86_64.mk @@ -14,4 +14,4 @@ build-osarch-specific: windows/amd64 .PHONY: only-windows-x86_64 only-windows-x86_64: - @echo "Only windows-x86_64 has this Makefile target." + $(info Only windows-x86_64 has this Makefile target.) diff --git a/testdata/senzing-license/g2.lic b/testdata/senzing-license/g2.lic index 768bb3961682801157ecd7df7e1d53a74894528b..67bc86ccaa28b77f2ce7e1168a257503e2f3e582 100644 GIT binary patch delta 564 zcmV-40?Ylx2*e1m9|4gdEC(_$GBhnPHIq^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