core

package module
v0.0.37 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 13 Imported by: 56

README

Core

Core contains common libraries used across our Go repositories.

Documentation

Overview

Package core contains the core dependencies

Index

Examples

Constants

View Source
const EnumDataType = "integer"

EnumDataType is exported here to be passed as GormDataType.

Variables

LogLevels stores available log levels in serverity order.

Functions

func BytesToSlice

func BytesToSlice(bytes [32]byte) []byte

BytesToSlice converts a 32 bit array to a slice slice.

func CopyBigInt

func CopyBigInt(val *big.Int) *big.Int

CopyBigInt creates a copy of a big int without mutating the original.

func EnumScan added in v0.0.7

func EnumScan(src interface{}) (uint8, error)

EnumScan converts the enum to a value. the returned uint 8 should be used. Note this should only be used for a non-nullable enum.

func EnumValue added in v0.0.7

func EnumValue(enum EnumInter) (driver.Value, error)

EnumValue converts the enum to a value.

func ExpandOrReturnPath added in v0.0.6

func ExpandOrReturnPath(path string) string

ExpandOrReturnPath expands a homedir path, if it can't be expanded, the original dir is returned since on these systems homedir cannot be used anyway.

func GetEnv

func GetEnv(name, defaultVal string) string

GetEnv gets an environment variable. If it is not present, the default variable is used.

func GetEnvInt

func GetEnvInt(name string, defaultVal int) int

GetEnvInt gets an environment variable as an int. if not found or cast the defaultVal is returned.

func IsTest added in v0.0.11

func IsTest() bool

IsTest returns true if the current process is a test.

func PtrTo added in v0.0.32

func PtrTo[T any](v T) *T

PtrTo returns a pointer to the given value.

Example
package main

import (
	"fmt"
	"github.com/ethereum/go-ethereum/common"
	"github.com/synapsecns/sanguine/core"
	"reflect"
)

func main() {
	res := core.PtrTo(common.Hash{})
	fmt.Println(reflect.TypeOf(res))
}
Output:

*common.Hash

func RandomItem added in v0.0.36

func RandomItem[T any](items []T) (res T, _ error)

RandomItem is a generic function to get a random item from a slice.

Types

type Enum added in v0.0.7

type Enum interface {
	EnumInter
	fmt.Stringer
	GormDataType() string
	sql.Scanner
	driver.Valuer
}

Enum is a type used to define interfaces db enums must conform to. it is kept here so it can be used throughout the app.

type EnumInter added in v0.0.7

type EnumInter interface {
	Int() uint8
}

EnumInter ensures an enum has a type to access an integer.

Directories

Path Synopsis
Package assets provides static assets we want to embed in the application in the main folder and documentation related assets in subfolders.
Package assets provides static assets we want to embed in the application in the main folder and documentation related assets in subfolders.
Package bytemap is an implementation of https://github.com/google/triemap/blob/main/bytemap.go with generic support for values
Package bytemap is an implementation of https://github.com/google/triemap/blob/main/bytemap.go with generic support for values
Package commandline contains common utilities for use across clis
Package commandline contains common utilities for use across clis
Package config contains the configuration required to run a node.
Package config contains the configuration required to run a node.
Package dbcommon provides common database functionality
Package dbcommon provides common database functionality
Package ginhelper provides some common functionality across gin servers.
Package ginhelper provides some common functionality across gin servers.
Package mapmutex provides an extensible, type-safe mutex implementation TODO: use generics
Package mapmutex provides an extensible, type-safe mutex implementation TODO: use generics
Package merkle provides the tools to create a merkle tree and keep track of its historical states.
Package merkle provides the tools to create a merkle tree and keep track of its historical states.
Package metrics implements a metrics dashboard with either datadog or prometheus (coming soon)
Package metrics implements a metrics dashboard with either datadog or prometheus (coming soon)
newrelic
Package newrelic provides custom wrpapers for newrelic.
Package newrelic provides custom wrpapers for newrelic.
Package mocktesting is used for mocking out the testing.T interface.
Package mocktesting is used for mocking out the testing.T interface.
Package observer provides an observer implementation
Package observer provides an observer implementation
Package processlog contains an opinionated method for piping logs from external processes into stdout and readbale files for testing..
Package processlog contains an opinionated method for piping logs from external processes into stdout and readbale files for testing..
Package prom exposes metrics on synapse-node
Package prom exposes metrics on synapse-node
Package server provides a way to access a server TODO: consider moving this into gin helper
Package server provides a way to access a server TODO: consider moving this into gin helper
Package testsuite contains the standard test suite
Package testsuite contains the standard test suite
Package threaditer extends iter with a mutex for thread safe use
Package threaditer extends iter with a mutex for thread safe use
Package toml contains common utilities for implementing toml types.
Package toml contains common utilities for implementing toml types.

Jump to

Keyboard shortcuts

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