utils

package
v0.0.0-...-ae9d8b3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultCurrency = "USD"

Variables

View Source
var CurrentRates = map[string]*Currency{
	"USD": &Currency{Symbol: "$"},
	"GBP": &Currency{Symbol: "£"},
	"EUR": &Currency{Symbol: "€"},
}
View Source
var (
	ErrNotSuccessful = errors.New("HTTP Get request was not successful")
)

Functions

func ColorToHex

func ColorToHex(c color.Color) string

func ConvertPrices

func ConvertPrices(rawPrices map[string]string) map[string]ApproximatePrice

func FindBackgroundColor

func FindBackgroundColor(img image.Image) color.Color

func HTTPGetBytes

func HTTPGetBytes(url string) ([]byte, error)

func HTTPGetString

func HTTPGetString(url string) (string, error)

func HTTPGetToTempfile

func HTTPGetToTempfile(url string) (*os.File, error)

func HTTPPostForm

func HTTPPostForm(url string, data url.Values) (*http.Response, error)

func HTTPReadResponse

func HTTPReadResponse(resp *http.Response) ([]byte, error)

func HTTPReadResponseString

func HTTPReadResponseString(resp *http.Response) (string, error)

func ProjectRootPath

func ProjectRootPath(elem ...string) string

func RunMinioTest

func RunMinioTest(fn func(*MinioConnection))

RunMinioTest creates a minio test bucket and ensures the bucket is removed, even if the test panics.

func SetHTTPTestMode

func SetHTTPTestMode()

func StringSliceCleanup

func StringSliceCleanup(s []string) []string

StringSliceCleanup returns a string slice with empty strings removed.

func StringSliceUnique

func StringSliceUnique(col []string) []string

func StringSlicesDiff

func StringSlicesDiff(slice1, slice2 []string) []string

StringSlicesDiff compares two string slices and returns the difference.

func TransformImage

func TransformImage(img image.Image, transform Transform, bgColor color.Color) image.Image

func UpdateRates

func UpdateRates() error

Types

type ApproximatePrice

type ApproximatePrice struct {
	Amount      int    `json:"amount"`
	Currency    string `json:"currency"`
	Approximate bool   `json:"approximate"`
	Formatted   string `json:"formatted"`
}

type Currency

type Currency struct {
	Symbol string
	Rates  map[string]float64 `json:"rates"`
}

type MinioConnection

type MinioConnection struct {
	Client   *minio.Client
	Bucket   string
	TestMode bool
}

func NewMinioConnection

func NewMinioConnection() *MinioConnection

func NewMinioTestConnection

func NewMinioTestConnection() *MinioConnection

func (*MinioConnection) Clean

func (conn *MinioConnection) Clean()

Clean removes all files from a bucket and deletes the bucket.

func (*MinioConnection) PutObject

func (conn *MinioConnection) PutObject(objectName string, reader io.Reader, contentType string) error

PutObject creates an object in a bucket.

func (*MinioConnection) RemoveObject

func (conn *MinioConnection) RemoveObject(objectName string) error

RemoveObject removes an object from a bucket.

func (*MinioConnection) TestConfig

func (conn *MinioConnection) TestConfig()

TestConfig checks if the minio settings are valid

type Transform

type Transform struct {
	Size     int
	Path     string
	Format   imaging.Format
	MimeType string
}

Jump to

Keyboard shortcuts

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