scalarutils

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 7 Imported by: 28

README

Linting and Tests Coverage Status

Scalar Utils Library

scalarutils are utilities used by several backend services.

Installing it

scalarutils is compatible with modern Go releases in module mode, with Go installed:

go get -u github.com/savannahghi/scalarutils

will resolve and add the package to the current development module, along with its dependencies.

Alternatively the same can be achieved if you use import in a package:

import "github.com/savannahghi/scalarutils"

and run go get without parameters.

The package name is scalarutils

Developing

The default branch library is main

We try to follow semantic versioning ( https://semver.org/ ). For that reason, every major, minor and point release should be tagged.

git tag -m "v0.0.1" "v0.0.1"
git push --tags

Continuous integration tests must pass on Travis CI. Our coverage threshold is 90% i.e you must keep coverage above 90%.

Environment variables

In order to run tests, you need to have an env.sh file similar to this one:

# Application settings
export DEBUG=true
export IS_RUNNING_TESTS=true
export SENTRY_DSN=<a Sentry Data Source Name>
export GOOGLE_CLOUD_PROJECT="Google Cloud project id"

This file must not be committed to version control.

It is important to export the environment variables. If they are not exported, they will not be visible to child processes e.g go test ./....

These environment variables should also be set up on Travis CI environment variable section.

Contributing

I would like to cover the entire GitHub API and contributions are of course always welcome. The calling pattern is pretty well established, so adding new methods is relatively straightforward. See CONTRIBUTING.md for details.

Versioning

In general, scalarutils follows semver as closely as we can for tagging releases of the package. For self-contained libraries, the application of semantic versioning is relatively straightforward and generally understood. We've adopted the following versioning policy:

  • We increment the major version with any incompatible change to non-preview functionality, including changes to the exported Go API surface or behavior of the API.
  • We increment the minor version with any backwards-compatible changes to functionality, as well as any changes to preview functionality in the GitHub API. GitHub makes no guarantee about the stability of preview functionality, so neither do we consider it a stable part of the go-github API.
  • We increment the patch version with any backwards-compatible bug fixes.

License

This library is distributed under the MIT license found in the LICENSE file.

Documentation

Index

Constants

View Source
const (
	// DateTimeFormatLayout is the default format with East African Timezone
	DateTimeFormatLayout = "2006-01-02T15:04:05+03:00"
	// DateLayout is a short version of the date format
	DateLayout = "2006-01-02"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Base64Binary

type Base64Binary string

Base64Binary is a stream of bytes

func (Base64Binary) MarshalGQL

func (sc Base64Binary) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Base64Binary) UnmarshalGQL

func (sc *Base64Binary) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type Canonical

type Canonical string

Canonical is a URI that is a reference to a canonical URL on a FHIR resource

func (Canonical) MarshalGQL

func (sc Canonical) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Canonical) UnmarshalGQL

func (sc *Canonical) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type Code

type Code string

Code is a string which has at least one character and no leading or trailing whitespace and where there is no whitespace other than single spaces in the contents

func (Code) MarshalGQL

func (sc Code) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Code) UnmarshalGQL

func (sc *Code) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type Date

type Date struct {
	Year  int
	Month int
	Day   int
}

Date is a custom date type that maintains only date level precision

func NewDate

func NewDate(day, month, year int) (*Date, error)

NewDate initializes and validates a date

func (Date) AsTime

func (d Date) AsTime() time.Time

AsTime returns a Go stdlib time that corresponds to this date

func (Date) MarshalGQL

func (d Date) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (Date) MarshalText

func (d Date) MarshalText() (text []byte, err error)

MarshalText translates the date into text

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalGQL

func (d *Date) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(text []byte) error

UnmarshalText parses the value from text

func (*Date) Validate

func (d *Date) Validate() error

Validate checks that the date makes sense

type DateTime

type DateTime string

DateTime is a date, date-time or partial date (e.g. just year or year + month). If hours and minutes are specified, a time zone SHALL be populated. The format is a union of the schema types gYear, gYearMonth, date and dateTime. Seconds must be provided due to schema type constraints but may be zero-filled and may be ignored. Dates SHALL be valid dates.

func (DateTime) MarshalGQL

func (sc DateTime) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (DateTime) Time

func (sc DateTime) Time() time.Time

Time converts the DateTime to a time

func (*DateTime) UnmarshalGQL

func (sc *DateTime) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type Decimal

type Decimal decimal.Decimal

Decimal is a rational number with implicit precision

func (*Decimal) Decimal

func (sc *Decimal) Decimal() decimal.Decimal

Decimal returns the underlying decimal

func (Decimal) MarshalGQL

func (sc Decimal) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Decimal) String

func (sc *Decimal) String() string

String renders the underlying decimal value as a string

func (*Decimal) UnmarshalGQL

func (sc *Decimal) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type Instant

type Instant string

Instant is an instant in time - known at least to the second

func (Instant) MarshalGQL

func (sc Instant) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Instant) UnmarshalGQL

func (sc *Instant) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type Markdown

type Markdown string

Markdown is a string that may contain Github Flavored Markdown syntax for optional processing by a mark down presentation engine

func (Markdown) MarshalGQL

func (sc Markdown) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*Markdown) UnmarshalGQL

func (sc *Markdown) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type OID

type OID string

OID is an OID represented as a URI

func (OID) MarshalGQL

func (sc OID) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*OID) UnmarshalGQL

func (sc *OID) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type URI

type URI string

URI is string of characters used to identify a name or a resource

func (URI) MarshalGQL

func (sc URI) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*URI) UnmarshalGQL

func (sc *URI) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type URL

type URL string

URL is a URI that is a literal reference

func (URL) MarshalGQL

func (sc URL) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*URL) UnmarshalGQL

func (sc *URL) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type UUID

type UUID string

UUID is a UUID, represented as a URI

func (UUID) MarshalGQL

func (sc UUID) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*UUID) UnmarshalGQL

func (sc *UUID) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

type XHTML

type XHTML string

XHTML is xhtml - escaped html (see specfication)

func (XHTML) MarshalGQL

func (sc XHTML) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*XHTML) UnmarshalGQL

func (sc *XHTML) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

Jump to

Keyboard shortcuts

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