tools

package
v0.0.0-...-da20d80 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2016 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SUPERUSER_ID int64 = 1
)

Variables

View Source
var Config *viper.Viper

Functions

func AbsolutizeURL

func AbsolutizeURL(req *http.Request, uri string) string

AbsolutizeURL returns an absolute URL from the given URI and http.Request

func ConcatXML

func ConcatXML(fileNames []string) ([]byte, [sha1.Size]byte)

ConcatXML concatenates the XML content of the files given by fileNames into a valid XML by importing all children of the root node into the root node of the first file.

func ConvertMethodName

func ConvertMethodName(val string) string

ConvertMethodName converts an Odoo snake style method name (e.g. search_read) into a YEP Pascal cased style (e.g. SearchRead).

func ConvertModelName

func ConvertModelName(val string) string

ConvertModelName converts an Odoo dotted style model name (e.g. res.partner) into a YEP Pascal cased style (e.g. ResPartner).

func GetLogger

func GetLogger(moduleName string) log15.Logger

GetLogger returns a context logger for the given module

func GetStructFieldByJSONTag

func GetStructFieldByJSONTag(structValue reflect.Value, tag string) (sf reflect.Value)

GetStructFieldByJSONTag returns a pointer value of the struct field of the given structValue with the given JSON tag. If several are found, it returns the first one. If none are found it returns the zero value. If structType is not a Type of Kind struct, then it panics.

func ListStaticFiles

func ListStaticFiles(subDir string, modules []string) []string

ListStaticFiles get all file names of the static files that are in the "server/static/*/<subDir>" directories.

func Log15ForGin

func Log15ForGin(logger log15.Logger) gin.HandlerFunc

Log15ForGin returns a gin.HandlerFunc (middleware) that logs requests using log15.

Requests with errors are logged using log15.Error(). Requests without errors are logged using log15.Info().

func LogAndPanic

func LogAndPanic(log log15.Logger, msg string, ctx ...interface{})

LogAndPanic is a helper function for logging an error message on the given logger and then panic with the same error message.

func SnakeCaseString

func SnakeCaseString(in string) string

SnakeCaseString convert the given string to snake case following the Golang format: acronyms are converted to lower-case and preceded by an underscore.

func UnmarshalJSONValue

func UnmarshalJSONValue(data, dst reflect.Value) error

UnmarshalJSONValue unmarshals the given data as a Value of type []byte into the dst Value. dst must be a pointer Value

Types

type Context

type Context map[string]interface{}

Context is a map of objects that is passed along from function to function during a transaction.

type Digits

type Digits [2]int

Digits is a tuple of 2 ints specifying respectively: - The precision: the total number of digits - The scale: the number of digits to the right of the decimal point (PostgresSQL definitions)

type FieldType

type FieldType string
const (
	NO_TYPE   FieldType = ""
	BINARY    FieldType = "binary"
	BOOLEAN   FieldType = "boolean"
	CHAR      FieldType = "char"
	DATE      FieldType = "date"
	DATETIME  FieldType = "datetime"
	FLOAT     FieldType = "float"
	HTML      FieldType = "html"
	INTEGER   FieldType = "integer"
	MANY2MANY FieldType = "many2many"
	MANY2ONE  FieldType = "many2one"
	ONE2MANY  FieldType = "one2many"
	ONE2ONE   FieldType = "one2one"
	REV2ONE   FieldType = "rev2one"
	REFERENCE FieldType = "reference"
	SELECTION FieldType = "selection"
	TEXT      FieldType = "text"
)

type LangDirection

type LangDirection string
const (
	LANG_DIRECTION_LTR LangDirection = "ltr"
	LANG_DIRECTION_RTL LangDirection = "rtl"
)

type LangParameters

type LangParameters struct {
	DateFormat   string        `json:"date_format"`
	Direction    LangDirection `json:"lang_direction"`
	ThousandsSep string        `json:"thousands_sep"`
	TimeFormat   string        `json:"time_format"`
	DecimalPoint string        `json:"decimal_point"`
	ID           int64         `json:"id"`
	Grouping     string        `json:"grouping"`
}

Jump to

Keyboard shortcuts

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