commongo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 2

README

Go module to operate git

Usage:

Installation

# specific version
go get go get github.com/QFO6/common-go@vx.x.x
# or get latest
go get github.com/QFO6/common-go@master

Usage

import commongo "github.com/QFO6/common-go"

commongo.FormFields(xxx)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormFields

func FormFields(m interface{}) []string

FormFields get fields names defined in Struct with "form" tag

func ModelFields

func ModelFields(m interface{}) []string

ModelFields return model fields name

func ParseModel

func ParseModel(m interface{}, excludeFields []string)

ParseModelForm generate *ModelForm

func ParseModelForm

func ParseModelForm(m interface{})

ParseModelForm generate *HtmlForm

func SliceToMap

func SliceToMap(list []string) (out []map[string]interface{})

SliceToMap convert []string to [{"text":abc, "value": abc},{}...]

Types

type HtmlForm

type HtmlForm struct {
	Name     []string // [Name, Desc ...]
	Type     []string // [input, select, ....]
	Required []string // ["required", "", "", "required"]
	Help     []string
	Label    []string
	Value    []interface{}
	Options  map[string][][]interface{}          // options for field
	Extra    map[string]string                   // eg: disable
	Attrs    map[string]map[string]string        // attr for field
	OptAttrs map[string][]map[string]interface{} // data-link="abc" in option only for select or options
}

type ModelForm

type ModelForm struct {
	Name     []string // [Name, Desc ...]
	Type     []string // [input, select, ....]
	Required []string // [required, "", "", required]
	Help     []string // hint
	Label    []string
	Options  map[string][]map[string]interface{} // for radio, checkbox, select, {text:text, value: value}
	Value    []interface{}
	Extra    map[string]string      //data-link="http://www.google.com"
	ViewArgs map[string]interface{} // storge all args for view
}

ModelForm struct for form info

Jump to

Keyboard shortcuts

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