You need install mig cli tools to create project.
For library usage see gomig libraries docs.
For accessing app dependencies (config driver, cache driver, etc.) you must use app
namespace functions.
// github.com/myapp is your app namespace
import "github.com/myapp/src/app"
app.Config()
Check if app run on production mode.
Check if app run on development mode.
Compile template if defined.
Parameters:
name (string)
: template name.data (any)
: data for template to render.
Check if template is defined.
Parameters:
-name (string)
: template name.
Generate new uuid.
Ternary operator.
Parameters:
cond (bool)
: boolean condition value.yes (any)
: value to return on true state.no (any)
: value to return on false state.
Format number use message.NewPrinter(language.English)
formatter.
Parameters:
format (any)
: format pattern or number.v (...any)
: pass to formatter.
Format string using regular expression.
Parameters:
data (any)
: value to format.pattern (string)
: regex pattern.replacement (string)
: replacement pattern.
Format file size to friendly string.
Parameters:
size (numeric)
: size.
Format date to jalaali string (use gomig/jalaali
package).
Parameters:
format (string)
: date format.time (time.Time)
: date value.
Encode value to json or return fallback on failed.
Parameters:
data (any)
: value to marshal.fallback (string)
: fallback value if marshalling failed.
Generate go map from key value pairs.
Parameters:
values (...any)
: key value pairs.
Parse parameter value from string or return fallback value (|
key:value separated string).
Parameters:
parameters (string)
: parameters string.param (string)
: parameter name.fallback (string)
: fallback value.
Check if option exists in options str (|
separated string).
Parameters:
options (string)
: options string.option (string)
: option to check.
Check if map field exists.
Parameters:
data (map[string]any)
: map data.field (string)
: field name.
Check if value contains key. This pipe use json encoder for converting data to map before check.
Parameters:
data (any)
: data object.field (string)
: field name.
Get map field if exists or return fallback.
Parameters:
data (map[string]any)
: data map.field (string)
: field name.fallback (any)
: fallback value.
Get app config value.
Parameters:
path (string)
: config path.
Convert new line to <br/>
tag.
Parameters:
data (string)
: data.
Return renderable raw css (no escape).
Parameters:
data (string)
: css raw data.
Return renderable raw html (no escape).
Parameters:
data (string)
: html raw data.
Return renderable raw attr (no escape).
Parameters:
data (string)
: attr raw data.
Generate raw html attribute from key:value
pair.
Parameters:
attr (...string)
:key:value
paired attributes.
Return renderable raw js (no escape).
Parameters:
data (string)
: js raw data.
Return renderable raw js string (no escape).
Parameters:
data (string)
: js raw data.
Return renderable raw url string (no escape).
Parameters:
data (string)
: js raw data.
Find asset url from file system (public directory).
Parameters:
path (string)
: base path to search in public directory.pattern (string)
: file pattern to search.ignore (string)
: file pattern to ignore.extension (string)
: file extension.
Find all asset url from file system (public directory).
Parameters:
path (string)
: base path to search in public directory.pattern (string)
: file pattern to search.ignore (string)
: file pattern to ignore.extension (string)
: file extension.
For creating base web layout template use following syntax: (/views/Layout.tpl
)
Use layout in template: (/views/pages/home.tpl
)
Render template:
router.Get("/", func(c *fiber.Ctx) error {
return app.Render(c, "pages/home", "layout", data, 201)
})