diff --git a/.go_style b/.go_style new file mode 100644 index 00000000..26682eed --- /dev/null +++ b/.go_style @@ -0,0 +1,16 @@ +{ + "file_line": 500, + "func_line": 80, + "params_num":4, + "results_num":3, + "formated": true, + "pkg_name": true, + "camel_name":true, + "ignore":[ + "a/*", + "b/*/c/*.go" + ], + "fatal":[ + "formated" + ] +} diff --git a/admin.go b/admin.go index 0ef4f93f..fa9ef3b3 100644 --- a/admin.go +++ b/admin.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/app.go b/app.go index d0a47665..cc7f218e 100644 --- a/app.go +++ b/app.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/beego.go b/beego.go index e6484802..05737a88 100644 --- a/beego.go +++ b/beego.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/cache/cache.go b/cache/cache.go index c4baeba3..472c7c9a 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/cache/cache_test.go b/cache/cache_test.go index 4ba1fb8a..9426e159 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/cache/conv.go b/cache/conv.go index 202939b3..7f06992c 100644 --- a/cache/conv.go +++ b/cache/conv.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/cache/conv_test.go b/cache/conv_test.go index f6756fc4..d98db9e3 100644 --- a/cache/conv_test.go +++ b/cache/conv_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/cache/file.go b/cache/file.go index 62febac3..dd9fd843 100644 --- a/cache/file.go +++ b/cache/file.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/cache/memcache/memcache.go b/cache/memcache/memcache.go index 7b473dff..a7c9f197 100644 --- a/cache/memcache/memcache.go +++ b/cache/memcache/memcache.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/cache/memory.go b/cache/memory.go index 00e055e8..68147d96 100644 --- a/cache/memory.go +++ b/cache/memory.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/cache/redis/redis.go b/cache/redis/redis.go index b532ca85..6ce1ff18 100644 --- a/cache/redis/redis.go +++ b/cache/redis/redis.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package cache import ( diff --git a/config.go b/config.go index 1984e3cd..55290cd5 100644 --- a/config.go +++ b/config.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/config/config.go b/config/config.go index c7454fe0..8e719562 100644 --- a/config/config.go +++ b/config/config.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/fake.go b/config/fake.go index 1ddf8298..dba1a470 100644 --- a/config/fake.go +++ b/config/fake.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/ini.go b/config/ini.go index 500d07c1..ba3fd23a 100644 --- a/config/ini.go +++ b/config/ini.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/ini_test.go b/config/ini_test.go index e5e6b9ab..fc4d88dd 100644 --- a/config/ini_test.go +++ b/config/ini_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/json.go b/config/json.go index 8cac5e21..332280f4 100644 --- a/config/json.go +++ b/config/json.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/json_test.go b/config/json_test.go index 849febd0..80f5148c 100644 --- a/config/json_test.go +++ b/config/json_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/xml/xml.go b/config/xml/xml.go index 05171a37..fbd15190 100644 --- a/config/xml/xml.go +++ b/config/xml/xml.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/xml/xml_test.go b/config/xml/xml_test.go index ba6ebbd6..dac1a527 100644 --- a/config/xml/xml_test.go +++ b/config/xml/xml_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/yaml/yaml.go b/config/yaml/yaml.go index 8cae5109..5d2d2b84 100644 --- a/config/yaml/yaml.go +++ b/config/yaml/yaml.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config/yaml/yaml_test.go b/config/yaml/yaml_test.go index 3a8d68dc..ca066c72 100644 --- a/config/yaml/yaml_test.go +++ b/config/yaml/yaml_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package config import ( diff --git a/config_test.go b/config_test.go index 70bbf0d6..9b355c45 100644 --- a/config_test.go +++ b/config_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/context/context.go b/context/context.go index 15a05c90..8ef8233f 100644 --- a/context/context.go +++ b/context/context.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package context import ( diff --git a/context/input.go b/context/input.go index 46b31352..13f78fbc 100644 --- a/context/input.go +++ b/context/input.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package context import ( diff --git a/context/input_test.go b/context/input_test.go index b6d1f9d5..dc554786 100644 --- a/context/input_test.go +++ b/context/input_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package context import ( diff --git a/context/output.go b/context/output.go index aa9efb4c..b46c6a2d 100644 --- a/context/output.go +++ b/context/output.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package context import ( diff --git a/controller.go b/controller.go index 6f7b510c..f486bc36 100644 --- a/controller.go +++ b/controller.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/docs.go b/docs.go index 07b25dd4..8dfd3d82 100644 --- a/docs.go +++ b/docs.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/filter.go b/filter.go index 4f99c300..d9024f9a 100644 --- a/filter.go +++ b/filter.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego // FilterRouter defines filter operation before controller handler execution. diff --git a/filter_test.go b/filter_test.go index e6056599..089fea03 100644 --- a/filter_test.go +++ b/filter_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/flash.go b/flash.go index 66cb1f07..68de09c9 100644 --- a/flash.go +++ b/flash.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/flash_test.go b/flash_test.go index b3ecc4c5..383a10b7 100644 --- a/flash_test.go +++ b/flash_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/forms/elements/button.go b/forms/elements/button.go new file mode 100644 index 00000000..4a9e5ba6 --- /dev/null +++ b/forms/elements/button.go @@ -0,0 +1,15 @@ +package elements + +type Button struct { + Element +} + +func NewButton() *Button { + b := &Button{} + b.options = make(map[string]interface{}) + b.attributes = make(map[string]interface{}) + b.labelAttributes = make(map[string]interface{}) + b.labelOptions = make(map[string]interface{}) + b.SetAttribute("type", "button") + return b +} diff --git a/forms/elements/captcha.go b/forms/elements/captcha.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/captcha.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/checkbox.go b/forms/elements/checkbox.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/checkbox.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/csrf.go b/forms/elements/csrf.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/csrf.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/date.go b/forms/elements/date.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/date.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/element.go b/forms/elements/element.go new file mode 100644 index 00000000..ccb914c4 --- /dev/null +++ b/forms/elements/element.go @@ -0,0 +1,232 @@ +package elements + +type LableInterface interface { + SetLable(label string) + GetLable() (label string) + SetLabelAttributes(labelattrs map[string]interface{}) + GetLabelAttributes() (labelattrs map[string]interface{}) + SetLabelOptions(labelOptions map[string]interface{}) + GetLabelOptions() (labelOptions map[string]interface{}) + ClearLabelOptions() + RemoveLabelOptions(keys []string) + SetLabelOption(key string, val interface{}) + GetLabelOption(key string) (val interface{}) + RemoveLabelOption(key string) + HasLabelOption(key string) bool +} + +type ElementInterface interface { + SetName(name string) + GetName() (name string) + SetOptions(options map[string]interface{}) + SetOption(key string, val interface{}) + GetOptions() (options map[string]interface{}) + GetOption(key string) (val interface{}) + SetAttribute(key string, val interface{}) + GetAttribute(key string) (val interface{}) + RemoveAttribute(key string) + HasAttribute(key string) bool + SetAttributes(attributes map[string]interface{}) + GetAttributes() (attributes map[string]interface{}) + RemoveAttributes(keys []string) + ClearAttributes() + SetValue(val interface{}) + GetValue() (val interface{}) + SetMessages(msg string) + GetMessages() (msg string) + SetValidator(v ValidatorInterface) + Valid(val interface{}) bool + GetMessage() string + LableInterface +} + +type ValidatorInterface interface { + IsValid(val interface{}) bool + GetMessages() (msg string) +} + +type Element struct { + options map[string]interface{} + attributes map[string]interface{} + labelAttributes map[string]interface{} + labelOptions map[string]interface{} + value interface{} + lable string + messages string + validator ValidatorInterface +} + +func (e *Element) SetName(name string) { + e.SetAttribute("name", name) +} + +func (e *Element) GetName() (name string) { + return e.GetAttribute("name").(string) +} + +func (e *Element) SetOptions(options map[string]interface{}) { + if val, ok := options["label"]; ok { + e.SetLable(val.(string)) + } + + if val, ok := options["label_attributes"]; ok { + e.SetLabelAttributes(val.(map[string]interface{})) + } + + if val, ok := options["label_options"]; ok { + e.SetLabelOptions(val.(map[string]interface{})) + } + e.options = options +} + +func (e *Element) SetOption(key string, val interface{}) { + e.options[key] = val +} + +func (e *Element) GetOptions() (options map[string]interface{}) { + return e.options +} + +func (e *Element) GetOption(key string) (val interface{}) { + if val, ok := e.options[key]; ok { + return val + } + return nil +} + +func (e *Element) SetAttribute(key string, val interface{}) { + e.attributes[key] = val +} + +func (e *Element) GetAttribute(key string) (val interface{}) { + if val, ok := e.attributes[key]; ok { + return val + } + return nil +} + +func (e *Element) RemoveAttribute(key string) { + delete(e.attributes, key) +} + +func (e *Element) HasAttribute(key string) bool { + if _, ok := e.attributes[key]; ok { + return true + } + return false +} + +func (e *Element) SetAttributes(attributes map[string]interface{}) { + for key, val := range attributes { + e.SetAttribute(key, val) + } +} + +func (e *Element) GetAttributes() (attributes map[string]interface{}) { + return e.attributes +} + +func (e *Element) RemoveAttributes(keys []string) { + for _, key := range keys { + e.RemoveAttribute(key) + } +} + +func (e *Element) ClearAttributes() { + e.attributes = make(map[string]interface{}) +} + +func (e *Element) SetValue(val interface{}) { + e.value = val +} + +func (e *Element) GetValue() (val interface{}) { + return e.value +} + +func (e *Element) SetLable(label string) { + e.lable = label +} + +func (e *Element) GetLable() (label string) { + return e.lable +} + +func (e *Element) SetLabelAttributes(labelattrs map[string]interface{}) { + e.labelAttributes = labelattrs +} + +func (e *Element) GetLabelAttributes() (labelattrs map[string]interface{}) { + return e.labelAttributes +} + +func (e *Element) SetLabelOptions(labelOptions map[string]interface{}) { + for key, val := range labelOptions { + e.SetLabelOption(key, val) + } +} + +func (e *Element) GetLabelOptions() (labelOptions map[string]interface{}) { + return e.labelOptions +} + +func (e *Element) ClearLabelOptions() { + e.labelOptions = make(map[string]interface{}) +} + +func (e *Element) RemoveLabelOptions(keys []string) { + for _, key := range keys { + e.RemoveLabelOption(key) + } +} + +func (e *Element) SetLabelOption(key string, val interface{}) { + e.labelOptions[key] = val +} + +func (e *Element) GetLabelOption(key string) (val interface{}) { + if v, ok := e.labelOptions[key]; ok { + return v + } + return nil +} + +func (e *Element) RemoveLabelOption(key string) { + delete(e.labelOptions, key) +} + +func (e *Element) HasLabelOption(key string) bool { + if _, ok := e.labelOptions[key]; ok { + return true + } + return false +} + +func (e *Element) SetMessages(msg string) { + e.messages = msg +} + +func (e *Element) GetMessages() (msg string) { + return e.messages +} + +func (e *Element) SetValidator(v ValidatorInterface) { + e.validator = v +} + +func (e *Element) Valid(val interface{}) bool { + if e.validator == nil { + return true + } + if e.validator.IsValid(val) { + return true + } + return false +} + +func (e *Element) GetMessage() string { + if e.validator == nil { + return "" + } + return e.validator.GetMessages() +} diff --git a/forms/elements/email.go b/forms/elements/email.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/email.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/file.go b/forms/elements/file.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/file.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/hidden.go b/forms/elements/hidden.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/hidden.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/image.go b/forms/elements/image.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/image.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/multicheckbox.go b/forms/elements/multicheckbox.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/multicheckbox.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/number.go b/forms/elements/number.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/number.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/password.go b/forms/elements/password.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/password.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/radio.go b/forms/elements/radio.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/radio.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/range.go b/forms/elements/range.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/range.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/select.go b/forms/elements/select.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/select.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/submit.go b/forms/elements/submit.go new file mode 100644 index 00000000..faa88a5a --- /dev/null +++ b/forms/elements/submit.go @@ -0,0 +1,15 @@ +package elements + +type Submit struct { + Element +} + +func NewSubmit() *Submit { + b := &Submit{} + b.options = make(map[string]interface{}) + b.attributes = make(map[string]interface{}) + b.labelAttributes = make(map[string]interface{}) + b.labelOptions = make(map[string]interface{}) + b.SetAttribute("type", "submit") + return b +} diff --git a/forms/elements/text.go b/forms/elements/text.go new file mode 100644 index 00000000..c1050c3d --- /dev/null +++ b/forms/elements/text.go @@ -0,0 +1,15 @@ +package elements + +type Text struct { + Element +} + +func NewText() *Text { + b := &Text{} + b.options = make(map[string]interface{}) + b.attributes = make(map[string]interface{}) + b.labelAttributes = make(map[string]interface{}) + b.labelOptions = make(map[string]interface{}) + b.SetAttribute("type", "text") + return b +} diff --git a/forms/elements/textarea.go b/forms/elements/textarea.go new file mode 100644 index 00000000..c879ec49 --- /dev/null +++ b/forms/elements/textarea.go @@ -0,0 +1,15 @@ +package elements + +type Textarea struct { + Element +} + +func NewTextarea() *Textarea { + b := &Textarea{} + b.options = make(map[string]interface{}) + b.attributes = make(map[string]interface{}) + b.labelAttributes = make(map[string]interface{}) + b.labelOptions = make(map[string]interface{}) + b.SetAttribute("type", "textarea") + return b +} diff --git a/forms/elements/time.go b/forms/elements/time.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/time.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/elements/url.go b/forms/elements/url.go new file mode 100644 index 00000000..395f9955 --- /dev/null +++ b/forms/elements/url.go @@ -0,0 +1 @@ +package elements \ No newline at end of file diff --git a/forms/form.go b/forms/form.go new file mode 100644 index 00000000..b554037d --- /dev/null +++ b/forms/form.go @@ -0,0 +1,57 @@ +// Beego (http://beego.me/) +// @description beego is an open-source, high-performance web framework for the Go programming language. +// @link http://github.com/astaxie/beego for the canonical source repository +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// @authors astaxie + +package forms + +import ( + "github.com/astaxie/beego/forms/elements" +) + +type Form struct { + elements map[string]elements.ElementInterface +} + +func NewForm() *Form { + f := &Form{} + f.elements = make(map[string]elements.ElementInterface) + return f +} + +func (f *Form) Init() *Form { + f.elements = make(map[string]elements.ElementInterface) +} + +func (f *Form) Valid(data map[string]interface{}) bool { + for k, val := range data { + if e, ok := f.elements[k]; ok { + if !e.Valid(val) { + return false + } + } + } + return true +} + +func (f *Form) SetData() { + +} + +func (f *Form) Bind() { + +} + +func (f *Form) SaveData() { + +} + +func (f *Form) AddElement(e elements.ElementInterface) { + name := e.GetName() + f.elements[name] = e +} + +func (f *Form) Render() string { + +} diff --git a/forms/form_test.go b/forms/form_test.go new file mode 100644 index 00000000..6a1a78b9 --- /dev/null +++ b/forms/form_test.go @@ -0,0 +1,21 @@ +package forms + +import ( + "fmt" + "testing" + + "./elements" +) + +func formTest(t *testing.T) { + rf := NewForm() + username := elements.NewText() + username.SetAttribute("name", "username") + username.SetAttribute("id", "username") + rf.AddElement(username) + + button := elements.NewSubmit() + rf.AddElement(rf) + + fmt.Println(rf.Render()) +} diff --git a/httplib/httplib.go b/httplib/httplib.go index 53b8e6ca..e60ac7ac 100644 --- a/httplib/httplib.go +++ b/httplib/httplib.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package httplib import ( diff --git a/httplib/httplib_test.go b/httplib/httplib_test.go index 64de6596..9a94116e 100644 --- a/httplib/httplib_test.go +++ b/httplib/httplib_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package httplib import ( diff --git a/log.go b/log.go index 5465dc1a..2a6793b0 100644 --- a/log.go +++ b/log.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/logs/conn.go b/logs/conn.go index d36fa364..e7b0464f 100644 --- a/logs/conn.go +++ b/logs/conn.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/conn_test.go b/logs/conn_test.go index aa50b41d..3108ca15 100644 --- a/logs/conn_test.go +++ b/logs/conn_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/console.go b/logs/console.go index c5c72faa..e552c92d 100644 --- a/logs/console.go +++ b/logs/console.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/console_test.go b/logs/console_test.go index 30e1e4c6..fe08d4f8 100644 --- a/logs/console_test.go +++ b/logs/console_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/file.go b/logs/file.go index a7f4c724..512df983 100644 --- a/logs/file.go +++ b/logs/file.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/file_test.go b/logs/file_test.go index 65d543ba..bc88d607 100644 --- a/logs/file_test.go +++ b/logs/file_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/log.go b/logs/log.go index b3dedf98..b62105ec 100644 --- a/logs/log.go +++ b/logs/log.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/smtp.go b/logs/smtp.go index d5c7101d..b45b2fbb 100644 --- a/logs/smtp.go +++ b/logs/smtp.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/logs/smtp_test.go b/logs/smtp_test.go index 96cd3759..58e15134 100644 --- a/logs/smtp_test.go +++ b/logs/smtp_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package logs import ( diff --git a/memzipfile.go b/memzipfile.go index a100b59d..2fce9b81 100644 --- a/memzipfile.go +++ b/memzipfile.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/middleware/error.go b/middleware/error.go index 10d4fc53..743180cb 100644 --- a/middleware/error.go +++ b/middleware/error.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package middleware import ( diff --git a/middleware/exceptions.go b/middleware/exceptions.go index a6a18ff0..4165c3e6 100644 --- a/middleware/exceptions.go +++ b/middleware/exceptions.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package middleware import "fmt" diff --git a/middleware/i18n.go b/middleware/i18n.go index 5c44dc4a..3009b46d 100644 --- a/middleware/i18n.go +++ b/middleware/i18n.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package middleware import ( diff --git a/mime.go b/mime.go index ada6d099..57487398 100644 --- a/mime.go +++ b/mime.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/namespace.go b/namespace.go index 985ded3b..c8ec2488 100644 --- a/namespace.go +++ b/namespace.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/namespace_test.go b/namespace_test.go index 64bd8dec..7587f4b2 100644 --- a/namespace_test.go +++ b/namespace_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/orm/cmd.go b/orm/cmd.go index a15727ae..e31b0ef4 100644 --- a/orm/cmd.go +++ b/orm/cmd.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/cmd_utils.go b/orm/cmd_utils.go index ffb354e0..82f125d3 100644 --- a/orm/cmd_utils.go +++ b/orm/cmd_utils.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/db.go b/orm/db.go index 847ab0d5..f4a9f42c 100644 --- a/orm/db.go +++ b/orm/db.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/db_alias.go b/orm/db_alias.go index 816441a6..a8f64edf 100644 --- a/orm/db_alias.go +++ b/orm/db_alias.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/db_mysql.go b/orm/db_mysql.go index e024b2a1..85582966 100644 --- a/orm/db_mysql.go +++ b/orm/db_mysql.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/db_oracle.go b/orm/db_oracle.go index 5c93e3c8..c8321c5a 100644 --- a/orm/db_oracle.go +++ b/orm/db_oracle.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm // oracle dbBaser diff --git a/orm/db_postgres.go b/orm/db_postgres.go index 4609d8ca..ac94446e 100644 --- a/orm/db_postgres.go +++ b/orm/db_postgres.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/db_sqlite.go b/orm/db_sqlite.go index de2bf63d..8f6aae76 100644 --- a/orm/db_sqlite.go +++ b/orm/db_sqlite.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/db_tables.go b/orm/db_tables.go index 21d18876..56e19759 100644 --- a/orm/db_tables.go +++ b/orm/db_tables.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/db_utils.go b/orm/db_utils.go index 8d895e43..713eb51c 100644 --- a/orm/db_utils.go +++ b/orm/db_utils.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/models.go b/orm/models.go index 2d82a204..c1c51deb 100644 --- a/orm/models.go +++ b/orm/models.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/models_boot.go b/orm/models_boot.go index eb3fce66..138a4844 100644 --- a/orm/models_boot.go +++ b/orm/models_boot.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/models_fields.go b/orm/models_fields.go index f328999d..dd99596f 100644 --- a/orm/models_fields.go +++ b/orm/models_fields.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/models_info_f.go b/orm/models_info_f.go index 622791d9..ebd140f7 100644 --- a/orm/models_info_f.go +++ b/orm/models_info_f.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/models_info_m.go b/orm/models_info_m.go index f759fa33..e9d2e65f 100644 --- a/orm/models_info_m.go +++ b/orm/models_info_m.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/models_test.go b/orm/models_test.go index 2b42fd52..99377bfa 100644 --- a/orm/models_test.go +++ b/orm/models_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/models_utils.go b/orm/models_utils.go index bf331fed..1d19a466 100644 --- a/orm/models_utils.go +++ b/orm/models_utils.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm.go b/orm/orm.go index 947a453c..96cb3430 100644 --- a/orm/orm.go +++ b/orm/orm.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm_conds.go b/orm/orm_conds.go index 0110ac18..c5a57305 100644 --- a/orm/orm_conds.go +++ b/orm/orm_conds.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm_log.go b/orm/orm_log.go index cde61449..ad9ae70c 100644 --- a/orm/orm_log.go +++ b/orm/orm_log.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm_object.go b/orm/orm_object.go index 82067026..1a91d789 100644 --- a/orm/orm_object.go +++ b/orm/orm_object.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm_querym2m.go b/orm/orm_querym2m.go index bcd67660..c525d42e 100644 --- a/orm/orm_querym2m.go +++ b/orm/orm_querym2m.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm_queryset.go b/orm/orm_queryset.go index c6e8f19d..5c651023 100644 --- a/orm/orm_queryset.go +++ b/orm/orm_queryset.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm_raw.go b/orm/orm_raw.go index 373aaf1b..5936e590 100644 --- a/orm/orm_raw.go +++ b/orm/orm_raw.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/orm_test.go b/orm/orm_test.go index 016e103b..d8b48ef4 100644 --- a/orm/orm_test.go +++ b/orm/orm_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/types.go b/orm/types.go index 77585570..f104513a 100644 --- a/orm/types.go +++ b/orm/types.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/orm/utils.go b/orm/utils.go index d2326fc1..a0bb94a3 100644 --- a/orm/utils.go +++ b/orm/utils.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie, slene - package orm import ( diff --git a/parser.go b/parser.go index f8818295..35382741 100644 --- a/parser.go +++ b/parser.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/plugins/auth/basic.go b/plugins/auth/basic.go index 16aea240..feafc0c9 100644 --- a/plugins/auth/basic.go +++ b/plugins/auth/basic.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package auth // Example: diff --git a/router.go b/router.go index 52e641c0..e43e55fe 100644 --- a/router.go +++ b/router.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( @@ -66,6 +65,8 @@ var ( "DelSession", "SessionRegenerateID", "DestroySession", "IsAjax", "GetSecureCookie", "SetSecureCookie", "XsrfToken", "CheckXsrfCookie", "XsrfFormHtml", "GetControllerAndAction"} + + url_placeholder = "{{placeholder}}" ) // To append a slice's value into "exceptMethod", for controller's methods shouldn't reflect to AutoRouter @@ -428,6 +429,7 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin } } if t.wildcard != nil { + url = path.Join(url, url_placeholder) ok, u := p.geturl(t.wildcard, url, controllName, methodName, params) if ok { return ok, u @@ -456,15 +458,14 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin if find { if l.regexps == nil { if len(l.wildcards) == 0 { - return true, url + return true, strings.Replace(url, "/"+url_placeholder, "", 1) } if len(l.wildcards) == 1 { if v, ok := params[l.wildcards[0]]; ok { delete(params, l.wildcards[0]) - return true, url + "/" + v + tourl(params) - } - if l.wildcards[0] == ":splat" { - return true, url + tourl(params) + return true, strings.Replace(url, url_placeholder, v, 1) + tourl(params) + } else { + return false, "" } } if len(l.wildcards) == 3 && l.wildcards[0] == "." { @@ -472,7 +473,7 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin if e, isok := params[":ext"]; isok { delete(params, ":path") delete(params, ":ext") - return true, url + "/" + p + "." + e + tourl(params) + return true, strings.Replace(url, url_placeholder, p+"."+e, -1) + tourl(params) } } } @@ -483,7 +484,8 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin continue } if u, ok := params[v]; ok { - url += "/" + u + delete(params, v) + url = strings.Replace(url, url_placeholder, u, 1) } else { if canskip { canskip = false @@ -493,7 +495,7 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin } } } - return true, url + return true, url + tourl(params) } else { var i int var startreg bool @@ -516,11 +518,11 @@ func (p *ControllerRegistor) geturl(t *Tree, url, controllName, methodName strin } } if l.regexps.MatchString(regurl) { - if url == "/" { - return true, url + regurl + tourl(params) - } else { - return true, url + "/" + regurl + tourl(params) + ps := strings.Split(regurl, "/") + for _, p := range ps { + url = strings.Replace(url, url_placeholder, p, 1) } + return true, url + tourl(params) } } } diff --git a/router_test.go b/router_test.go index e96a1403..d4d80fa0 100644 --- a/router_test.go +++ b/router_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( @@ -95,10 +94,10 @@ func TestUrlFor(t *testing.T) { func TestUrlFor3(t *testing.T) { handler := NewControllerRegister() handler.AddAuto(&TestController{}) - if a := handler.UrlFor("TestController.Myext"); a != "/test/myext" { + if a := handler.UrlFor("TestController.Myext"); a != "/test/myext" && a != "/Test/Myext" { t.Errorf("TestController.Myext must equal to /test/myext, but get " + a) } - if a := handler.UrlFor("TestController.GetUrl"); a != "/test/geturl" { + if a := handler.UrlFor("TestController.GetUrl"); a != "/test/geturl" && a != "/Test/GetUrl" { t.Errorf("TestController.GetUrl must equal to /test/geturl, but get " + a) } } @@ -106,8 +105,14 @@ func TestUrlFor3(t *testing.T) { func TestUrlFor2(t *testing.T) { handler := NewControllerRegister() handler.Add("/v1/:v/cms_:id(.+)_:page(.+).html", &TestController{}, "*:List") + handler.Add("/v1/:username/edit", &TestController{}, "get:GetUrl") handler.Add("/v1/:v(.+)_cms/ttt_:id(.+)_:page(.+).html", &TestController{}, "*:Param") handler.Add("/:year:int/:month:int/:title/:entid", &TestController{}) + if handler.UrlFor("TestController.GetUrl", ":username", "astaxie") != "/v1/astaxie/edit" { + Info(handler.UrlFor("TestController.GetUrl")) + t.Errorf("TestController.List must equal to /v1/astaxie/edit") + } + if handler.UrlFor("TestController.List", ":v", "za", ":id", "12", ":page", "123") != "/v1/za/cms_12_123.html" { Info(handler.UrlFor("TestController.List")) @@ -162,6 +167,18 @@ func TestAutoFunc(t *testing.T) { } } +func TestAutoFunc2(t *testing.T) { + r, _ := http.NewRequest("GET", "/Test/List", nil) + w := httptest.NewRecorder() + + handler := NewControllerRegister() + handler.AddAuto(&TestController{}) + handler.ServeHTTP(w, r) + if w.Body.String() != "i am list" { + t.Errorf("user define func can't run") + } +} + func TestAutoFuncParams(t *testing.T) { r, _ := http.NewRequest("GET", "/test/params/2009/11/12", nil) w := httptest.NewRecorder() diff --git a/session/couchbase/sess_couchbase.go b/session/couchbase/sess_couchbase.go index b033d67e..7d15654d 100644 --- a/session/couchbase/sess_couchbase.go +++ b/session/couchbase/sess_couchbase.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/memcache/sess_memcache.go b/session/memcache/sess_memcache.go index 1558e239..8712743a 100644 --- a/session/memcache/sess_memcache.go +++ b/session/memcache/sess_memcache.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/mysql/sess_mysql.go b/session/mysql/sess_mysql.go index dc0d1506..39f31230 100644 --- a/session/mysql/sess_mysql.go +++ b/session/mysql/sess_mysql.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session // mysql session support need create table as sql: diff --git a/session/postgres/sess_postgresql.go b/session/postgres/sess_postgresql.go index 4e3aca75..1796da2f 100644 --- a/session/postgres/sess_postgresql.go +++ b/session/postgres/sess_postgresql.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session /* diff --git a/session/redis/sess_redis.go b/session/redis/sess_redis.go index 0d7032f1..13527f15 100644 --- a/session/redis/sess_redis.go +++ b/session/redis/sess_redis.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/sess_cookie.go b/session/sess_cookie.go index 5a75e402..08b1ce38 100644 --- a/session/sess_cookie.go +++ b/session/sess_cookie.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/sess_cookie_test.go b/session/sess_cookie_test.go index 475b836b..0a5831e1 100644 --- a/session/sess_cookie_test.go +++ b/session/sess_cookie_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/sess_file.go b/session/sess_file.go index 38bfa95b..38de7a90 100644 --- a/session/sess_file.go +++ b/session/sess_file.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/sess_mem.go b/session/sess_mem.go index 676d6058..deec8190 100644 --- a/session/sess_mem.go +++ b/session/sess_mem.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/sess_mem_test.go b/session/sess_mem_test.go index 79684953..6bcbd157 100644 --- a/session/sess_mem_test.go +++ b/session/sess_mem_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/sess_test.go b/session/sess_test.go index 535f0c4c..ed9acd9d 100644 --- a/session/sess_test.go +++ b/session/sess_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/sess_utils.go b/session/sess_utils.go index cdf0e99b..63bf3d9c 100644 --- a/session/sess_utils.go +++ b/session/sess_utils.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/session/session.go b/session/session.go index c4b281b7..04ecb986 100644 --- a/session/session.go +++ b/session/session.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package session import ( diff --git a/staticfile.go b/staticfile.go index d74aa223..52ab6dc4 100644 --- a/staticfile.go +++ b/staticfile.go @@ -1,11 +1,11 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie package beego diff --git a/swagger/docsSpec.go b/swagger/docsSpec.go index 23149a20..fd054c52 100644 --- a/swagger/docsSpec.go +++ b/swagger/docsSpec.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package swagger const SwaggerVersion = "1.2" diff --git a/template.go b/template.go index ad1902d2..69a286c2 100644 --- a/template.go +++ b/template.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego //@todo add template funcs diff --git a/template_test.go b/template_test.go index fc2a90a0..a18dc09f 100644 --- a/template_test.go +++ b/template_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/templatefunc.go b/templatefunc.go index 274e3af9..da1ebc56 100644 --- a/templatefunc.go +++ b/templatefunc.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( @@ -361,10 +360,10 @@ func RenderForm(obj interface{}) template.HTML { fieldT := objT.Field(i) - label, name, fType, ignored := parseFormTag(fieldT) - if ignored { - continue - } + label, name, fType, ignored := parseFormTag(fieldT) + if ignored { + continue + } raw = append(raw, renderFormField(label, name, fType, fieldV.Interface())) } @@ -373,60 +372,60 @@ func RenderForm(obj interface{}) template.HTML { // renderFormField returns a string containing HTML of a single form field. func renderFormField(label, name, fType string, value interface{}) string { - if isValidForInput(fType) { - return fmt.Sprintf(`%v`, label, name, fType, value) - } + if isValidForInput(fType) { + return fmt.Sprintf(`%v`, label, name, fType, value) + } - return fmt.Sprintf(`%v<%v name="%v">%v`, label, fType, name, value, fType) + return fmt.Sprintf(`%v<%v name="%v">%v`, label, fType, name, value, fType) } // isValidForInput checks if fType is a valid value for the `type` property of an HTML input element. func isValidForInput(fType string) bool { - validInputTypes := strings.Fields("text password checkbox radio submit reset hidden image file button search email url tel number range date month week time datetime datetime-local color") - for _, validType := range validInputTypes { - if fType == validType { - return true - } - } - return false + validInputTypes := strings.Fields("text password checkbox radio submit reset hidden image file button search email url tel number range date month week time datetime datetime-local color") + for _, validType := range validInputTypes { + if fType == validType { + return true + } + } + return false } // parseFormTag takes the stuct-tag of a StructField and parses the `form` value. // returned are the form label, name-property, type and wether the field should be ignored. func parseFormTag(fieldT reflect.StructField) (label, name, fType string, ignored bool) { - tags := strings.Split(fieldT.Tag.Get("form"), ",") - label = fieldT.Name + ": " - name = fieldT.Name - fType = "text" - ignored = false; + tags := strings.Split(fieldT.Tag.Get("form"), ",") + label = fieldT.Name + ": " + name = fieldT.Name + fType = "text" + ignored = false - switch len(tags) { - case 1: - if tags[0] == "-" { - ignored = true - } - if len(tags[0]) > 0 { - name = tags[0] - } - case 2: - if len(tags[0]) > 0 { - name = tags[0] - } - if len(tags[1]) > 0 { - fType = tags[1] - } - case 3: - if len(tags[0]) > 0 { - name = tags[0] - } - if len(tags[1]) > 0 { - fType = tags[1] - } - if len(tags[2]) > 0 { - label = tags[2] - } - } - return + switch len(tags) { + case 1: + if tags[0] == "-" { + ignored = true + } + if len(tags[0]) > 0 { + name = tags[0] + } + case 2: + if len(tags[0]) > 0 { + name = tags[0] + } + if len(tags[1]) > 0 { + fType = tags[1] + } + case 3: + if len(tags[0]) > 0 { + name = tags[0] + } + if len(tags[1]) > 0 { + fType = tags[1] + } + if len(tags[2]) > 0 { + label = tags[2] + } + } + return } func isStructPtr(t reflect.Type) bool { diff --git a/templatefunc_test.go b/templatefunc_test.go index 373b11fa..fabbb431 100644 --- a/templatefunc_test.go +++ b/templatefunc_test.go @@ -1,21 +1,20 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( "html/template" "net/url" + "reflect" "testing" "time" - "reflect" ) func TestSubstr(t *testing.T) { @@ -141,17 +140,17 @@ func TestParseForm(t *testing.T) { func TestRenderForm(t *testing.T) { type user struct { - Id int `form:"-"` - tag string `form:"tag"` - Name interface{} `form:"username"` - Age int `form:"age,text,年龄:"` - Sex string - Email []string - Intro string `form:",textarea"` + Id int `form:"-"` + tag string `form:"tag"` + Name interface{} `form:"username"` + Age int `form:"age,text,年龄:"` + Sex string + Email []string + Intro string `form:",textarea"` Ignored string `form:"-"` } - u := user{Name: "test", Intro: "Some Text"} + u := user{Name: "test", Intro: "Some Text"} output := RenderForm(u) if output != template.HTML("") { t.Errorf("output should be empty but got %v", output) @@ -168,51 +167,51 @@ func TestRenderForm(t *testing.T) { } func TestRenderFormField(t *testing.T) { - html := renderFormField("Label: ", "Name", "text", "Value") - if html != `Label: ` { - t.Errorf("Wrong html output for input[type=text]: %v ", html) - } + html := renderFormField("Label: ", "Name", "text", "Value") + if html != `Label: ` { + t.Errorf("Wrong html output for input[type=text]: %v ", html) + } - html = renderFormField("Label: ", "Name", "textarea", "Value") - if html != `Label: ` { - t.Errorf("Wrong html output for textarea: %v ", html) - } + html = renderFormField("Label: ", "Name", "textarea", "Value") + if html != `Label: ` { + t.Errorf("Wrong html output for textarea: %v ", html) + } } func TestParseFormTag(t *testing.T) { - // create struct to contain field with different types of struct-tag `form` + // create struct to contain field with different types of struct-tag `form` type user struct { All int `form:"name,text,年龄:"` NoName int `form:",hidden,年龄:"` - OnlyLabel int `form:",,年龄:"` - OnlyName int `form:"name"` - Ignored int `form:"-"` - } + OnlyLabel int `form:",,年龄:"` + OnlyName int `form:"name"` + Ignored int `form:"-"` + } objT := reflect.TypeOf(&user{}).Elem() - label, name, fType, ignored := parseFormTag(objT.Field(0)) - if !(name == "name" && label == "年龄:" && fType == "text" && ignored == false) { + label, name, fType, ignored := parseFormTag(objT.Field(0)) + if !(name == "name" && label == "年龄:" && fType == "text" && ignored == false) { t.Errorf("Form Tag with name, label and type was not correctly parsed.") - } + } - label, name, fType, ignored = parseFormTag(objT.Field(1)) - if !(name == "NoName" && label == "年龄:" && fType == "hidden" && ignored == false) { + label, name, fType, ignored = parseFormTag(objT.Field(1)) + if !(name == "NoName" && label == "年龄:" && fType == "hidden" && ignored == false) { t.Errorf("Form Tag with label and type but without name was not correctly parsed.") - } + } - label, name, fType, ignored = parseFormTag(objT.Field(2)) - if !(name == "OnlyLabel" && label == "年龄:" && fType == "text" && ignored == false) { + label, name, fType, ignored = parseFormTag(objT.Field(2)) + if !(name == "OnlyLabel" && label == "年龄:" && fType == "text" && ignored == false) { t.Errorf("Form Tag containing only label was not correctly parsed.") - } + } - label, name, fType, ignored = parseFormTag(objT.Field(3)) - if !(name == "name" && label == "OnlyName: " && fType == "text" && ignored == false) { - t.Errorf("Form Tag containing only name was not correctly parsed.") - } + label, name, fType, ignored = parseFormTag(objT.Field(3)) + if !(name == "name" && label == "OnlyName: " && fType == "text" && ignored == false) { + t.Errorf("Form Tag containing only name was not correctly parsed.") + } - label, name, fType, ignored = parseFormTag(objT.Field(4)) - if (ignored == false) { - t.Errorf("Form Tag that should be ignored was not correctly parsed.") - } + label, name, fType, ignored = parseFormTag(objT.Field(4)) + if ignored == false { + t.Errorf("Form Tag that should be ignored was not correctly parsed.") + } } diff --git a/testing/assertions.go b/testing/assertions.go new file mode 100644 index 00000000..7fa4c199 --- /dev/null +++ b/testing/assertions.go @@ -0,0 +1,10 @@ +// Beego (http://beego.me/) +// +// @description beego is an open-source, high-performance web framework for the Go programming language. +// +// @link http://github.com/astaxie/beego for the canonical source repository +// +// @license http://github.com/astaxie/beego/blob/master/LICENSE +// +// @authors astaxie +package testing diff --git a/testing/client.go b/testing/client.go index a185da55..0819d508 100644 --- a/testing/client.go +++ b/testing/client.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package testing import ( diff --git a/toolbox/debug.go b/toolbox/debug.go index 614a673d..3b0ee803 100644 --- a/toolbox/debug.go +++ b/toolbox/debug.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/toolbox/debug_test.go b/toolbox/debug_test.go index 290bed7c..08f0661f 100644 --- a/toolbox/debug_test.go +++ b/toolbox/debug_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/toolbox/healthcheck.go b/toolbox/healthcheck.go index 4332586f..dc195549 100644 --- a/toolbox/healthcheck.go +++ b/toolbox/healthcheck.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox //type DatabaseCheck struct { diff --git a/toolbox/profile.go b/toolbox/profile.go index a3588ac3..0e0aaa40 100644 --- a/toolbox/profile.go +++ b/toolbox/profile.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/toolbox/profile_test.go b/toolbox/profile_test.go index 1a3345e8..cb3135d5 100644 --- a/toolbox/profile_test.go +++ b/toolbox/profile_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/toolbox/statistics.go b/toolbox/statistics.go index 74632ee3..fed8cc2b 100644 --- a/toolbox/statistics.go +++ b/toolbox/statistics.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/toolbox/statistics_test.go b/toolbox/statistics_test.go index 1fb99b76..fc6e4dce 100644 --- a/toolbox/statistics_test.go +++ b/toolbox/statistics_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/toolbox/task.go b/toolbox/task.go index 81fdf110..439035a1 100644 --- a/toolbox/task.go +++ b/toolbox/task.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/toolbox/task_test.go b/toolbox/task_test.go index 0a9f50ad..a1e85166 100644 --- a/toolbox/task_test.go +++ b/toolbox/task_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package toolbox import ( diff --git a/tree.go b/tree.go index f2bc6aa9..1bf72f9d 100644 --- a/tree.go +++ b/tree.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import ( diff --git a/tree_test.go b/tree_test.go index 0a30f677..589b64ca 100644 --- a/tree_test.go +++ b/tree_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package beego import "testing" diff --git a/utils/caller.go b/utils/caller.go index 3ba9e94f..6684880a 100644 --- a/utils/caller.go +++ b/utils/caller.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/caller_test.go b/utils/caller_test.go index 13b289e0..95262d75 100644 --- a/utils/caller_test.go +++ b/utils/caller_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/captcha/captcha.go b/utils/captcha/captcha.go index 80c7e77d..5354423e 100644 --- a/utils/captcha/captcha.go +++ b/utils/captcha/captcha.go @@ -1,13 +1,13 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - +// // an example for use captcha // // ``` diff --git a/utils/captcha/image.go b/utils/captcha/image.go index 6abfc0a4..cde4932a 100644 --- a/utils/captcha/image.go +++ b/utils/captcha/image.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package captcha import ( diff --git a/utils/captcha/image_test.go b/utils/captcha/image_test.go index 09c119c5..393262c8 100644 --- a/utils/captcha/image_test.go +++ b/utils/captcha/image_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package captcha import ( diff --git a/utils/captcha/siprng.go b/utils/captcha/siprng.go index 4afca3bf..54d6e93b 100644 --- a/utils/captcha/siprng.go +++ b/utils/captcha/siprng.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package captcha import ( diff --git a/utils/captcha/siprng_test.go b/utils/captcha/siprng_test.go index 54b5d5be..f6d31055 100644 --- a/utils/captcha/siprng_test.go +++ b/utils/captcha/siprng_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package captcha import "testing" diff --git a/utils/file.go b/utils/file.go index aead5e7b..ad221c92 100644 --- a/utils/file.go +++ b/utils/file.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/file_test.go b/utils/file_test.go index 5c72b040..0805415a 100644 --- a/utils/file_test.go +++ b/utils/file_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/mail.go b/utils/mail.go index d8f79f26..d0383ade 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/mail_test.go b/utils/mail_test.go index 84660a8e..f09f5b78 100644 --- a/utils/mail_test.go +++ b/utils/mail_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import "testing" diff --git a/utils/rand.go b/utils/rand.go index d521dfab..23cf3926 100644 --- a/utils/rand.go +++ b/utils/rand.go @@ -1,11 +1,11 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie package utils diff --git a/utils/safemap.go b/utils/safemap.go index 2df14a53..27c63eba 100644 --- a/utils/safemap.go +++ b/utils/safemap.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/safemap_test.go b/utils/safemap_test.go index 6c2da5bd..32034e91 100644 --- a/utils/safemap_test.go +++ b/utils/safemap_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/slice.go b/utils/slice.go index 786f47a9..6092e79a 100644 --- a/utils/slice.go +++ b/utils/slice.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/utils/slice_test.go b/utils/slice_test.go index fb9c1d1d..a1c053c6 100644 --- a/utils/slice_test.go +++ b/utils/slice_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package utils import ( diff --git a/validation/util.go b/validation/util.go index e8ca8a1c..91d2a735 100644 --- a/validation/util.go +++ b/validation/util.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package validation import ( diff --git a/validation/util_test.go b/validation/util_test.go index bcd0c0e5..ca99a7ab 100644 --- a/validation/util_test.go +++ b/validation/util_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package validation import ( diff --git a/validation/validation.go b/validation/validation.go index 477676a7..b86b565f 100644 --- a/validation/validation.go +++ b/validation/validation.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package validation import ( diff --git a/validation/validation_test.go b/validation/validation_test.go index d43a5938..ff279b64 100644 --- a/validation/validation_test.go +++ b/validation/validation_test.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package validation import ( diff --git a/validation/validators.go b/validation/validators.go index 5cab1c0f..5a468d67 100644 --- a/validation/validators.go +++ b/validation/validators.go @@ -1,13 +1,12 @@ // Beego (http://beego.me/) - +// // @description beego is an open-source, high-performance web framework for the Go programming language. - +// // @link http://github.com/astaxie/beego for the canonical source repository - +// // @license http://github.com/astaxie/beego/blob/master/LICENSE - +// // @authors astaxie - package validation import (