wharf-core

module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT

README

Wharf core library

Codacy Badge Go Reference

Utility Go code used by numerous other Wharf components.

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.16 or later: https://golang.ir/

  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.ir/

go test -v ./...

Linting Golang

go get -u github.com/mgechev/revive
npm run lint-go

Linting markdown

npm install

npm run lint-md

# Some errors can be fixed automatically. Keep in mind that this updates the
# files in place.
npm run lint-md-fix

Linting

You can lint all of the above at the same time by running:

npm run lint

# Some errors can be fixed automatically. Keep in mind that this updates the
# files in place.
npm run lint-fix

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