Categorygithub.com/DIMO-Network/shared
modulepackage
0.12.4
Repository: https://github.com/dimo-network/shared.git
Documentation: pkg.go.dev

# README

shared

Library code shared among our repositories

For an overview of the project, see the DIMO technical documentation site.

vin utils

Use the VIN type for strings that are VIN's and it gets some basic decoding functionality (eg. year, or tesla model).

config loader

Convention over configuration library for typed configurations that can read from yaml file or env vars. Provides an opinionated way of dealing with configurations: for local development we want to use yaml config files, and on higher level environments we want settings to come from environment variables (we use kubernetes). Supported types are: string, int, int64, bool.

adding custom types

  1. modify the config_loader_test.go by updating the tests (Test_loadFromEnvVars and Test_loadFromYaml) for your scenario with the desired type in the example settings struct
  2. modify config_loader func matchEnvVarToField by adding a case for your type.
  3. modify loadFromEnvVars by adding to the specialTypes list.
  4. modify the yaml library per readme there, git push, make a release
  5. then go get with the new version eg. go get github.com/DIMO-Network/[email protected] from this repo

gRPC library

We should probably put these in the repositories of the services that own them, but we are putting this off for now. To make changes to the current suite for, e.g., the devices API, run

protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative api/devices/*.proto

Linting

brew install golangci-lint

golangci-lint run

This should use the settings from .golangci.yml, which you can override.

If brew version does not work, download from https://github.com/golangci/golangci-lint/releases (darwin arm64 if M1), then copy to /usr/local/bin and sudo xattr -c golangci-lint

License

BSL

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package privileges contains the different privileges that can be given to a user.
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author
GrpcErrorToFiber useful anywhere calling a grpc underlying service and wanting to augment the error for fiber from grpc status codes meant to play nicely with the ErrorHandler in api.go that this would hand off errors to.
IsOdometerValid encapsulates logic to decide whether to return odometer.
LoadConfig fills in all the values in the Settings from local yml file (for dev) and env vars (for deployments).
No description provided by the author
No description provided by the author
SlugString converts names into url or ID friendly human readable names, aiming for alphanumeric and dashes.
No description provided by the author

# Structs

CloudEvent represents an event according to the CloudEvents spec.
CloudEventHeaders contains the fields common to all CloudEvent messages.
No description provided by the author
No description provided by the author
TODO(elffjs): Move this to DIMO-Network/shared.
KMSCipher is a Cipher that performs symmetric encryption with an AWS KMS key.
ROT13Cipher is a Cipher that implements ROT13 encryption.
StringSet offers a nice api to deal with string lists.

# Interfaces

Cipher is an interface for something that can encrypt and decrypt strings.
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author