Utility Go code used by numerous other Wharf components.
go get -u github.com/iver-wharf/wharf-core/v2
Mantra of this repository is to include code that will be used in more than 1 other repository, and does not solve any particular use case. It's more for common code. It holds code that does not solve any particular problems that’s specific for the different component’s domains.
Instead, it is a place of common utility code. What you will find in this utility repository is Go code that features:
-
✔️ Reading configuration from files and/or environment variables
-
✔️ Logging in a unified manner
-
✔️ Serving common endpoints such as GET /version
-
✔️ Common HTTP JSON models, such as the IETF RFC-7807 problem response.
What you will not find in this repository:
-
❌ Parsing .wharf-ci.yml files
-
❌ Abstractions over Kubernetes
-
❌ Abstractions over AMQP (already found in iver-wharf/messagebus-go)
-
❌ Wharf API database or HTTP JSON models
- YAML library gopkg.in/yaml.v2 (github.com/go-yaml/yaml)
- Configuration library spf13/viper
- Web framework github.com/gin-gonic/gin
- Database ORM library gorm.io/gorm
- Terminal coloring library github.com/fatih/color
-
Install Go 1.18 or later: https://golang.org/
-
Install the swaggo/swag CLI globally:
# Run this outside of any Go module, including this repository, to not # have `go get` update the go.mod file. $ cd .. $ go get -u github.com/swaggo/swag
-
Generate the swaggo files (this has to be redone each time the swaggo documentation comments has been altered):
# Navigate back to this repository $ cd wharf-api # Generate the files into docs/ $ swag
-
Start hacking with your favorite tool. For example VS Code, GoLand, Vim, Emacs, or whatnot.
Requires Go 1.16 or later to be installed: https://golang.org/
go test -v ./...
make deps # download linting dependencies
make lint
make lint-go # only lint Go code
make lint-md # only lint Markdown files
Some errors can be fixed automatically. Keep in mind that this updates the files in place.
make lint-fix
make lint-fix-go # only lint and fix Go files
make lint-fix-md # only lint and fix Markdown files
Maintained by Iver. Licensed under the MIT license.