wharf-core

module
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: MIT

README

Wharf core library

Codacy Badge Go Reference

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

Dependencies

Development

  1. Install Go 1.18 or later: https://golang.org/

  2. 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
    
  3. 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
    
  4. Start hacking with your favorite tool. For example VS Code, GoLand, Vim, Emacs, or whatnot.

Tests

Requires Go 1.16 or later to be installed: https://golang.org/

go test -v ./...

Linting

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.

Directories

Path Synopsis
internal
pkg
app
Package app contains utility types and functions regarding metadata about the application itself, such as versioning.
Package app contains utility types and functions regarding metadata about the application itself, such as versioning.
config
Package config helps you with reading configuration from files and environment variables in a unified way.
Package config helps you with reading configuration from files and environment variables in a unified way.
env
logger
Package logger contains logging types and functions in a memory-efficient and fast manner.
Package logger contains logging types and functions in a memory-efficient and fast manner.
logger/consolejson
Package consolejson is a concrete implementation of the logger.Sink and logger.Context used for outputting JSON-formatted log lines.
Package consolejson is a concrete implementation of the logger.Sink and logger.Context used for outputting JSON-formatted log lines.
logger/consolepretty
Package consolepretty is a concrete implementation of the logger.Sink and logger.Context used for outputting good looking human-readable logs to the console.
Package consolepretty is a concrete implementation of the logger.Sink and logger.Context used for outputting good looking human-readable logs to the console.

Jump to

Keyboard shortcuts

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