mirror of
https://github.com/astaxie/beego.git
synced 2024-12-22 22:10:48 +00:00
Merge pull request #2512 from sergeylanzman/add-unconvert
add unconverted support
This commit is contained in:
commit
8dbf9eb0bf
@ -33,6 +33,7 @@ install:
|
||||
- go get github.com/ssdb/gossdb/ssdb
|
||||
- go get github.com/cloudflare/golz4
|
||||
- go get github.com/gogo/protobuf/proto
|
||||
- go get -u github.com/mdempsky/unconvert
|
||||
before_script:
|
||||
- psql --version
|
||||
- sh -c "if [ '$ORM_DRIVER' = 'postgres' ]; then psql -c 'create database orm_test;' -U postgres; fi"
|
||||
@ -47,5 +48,6 @@ after_script:
|
||||
- rm -rf ./res/var/*
|
||||
script:
|
||||
- go test -v ./...
|
||||
- unconvert $(go list ./... | grep -v /vendor/)
|
||||
addons:
|
||||
postgresql: "9.4"
|
||||
|
4
cache/ssdb/ssdb.go
vendored
4
cache/ssdb/ssdb.go
vendored
@ -53,7 +53,7 @@ func (rc *Cache) GetMulti(keys []string) []interface{} {
|
||||
resSize := len(res)
|
||||
if err == nil {
|
||||
for i := 1; i < resSize; i += 2 {
|
||||
values = append(values, string(res[i+1]))
|
||||
values = append(values, res[i+1])
|
||||
}
|
||||
return values
|
||||
}
|
||||
@ -175,7 +175,7 @@ func (rc *Cache) ClearAll() error {
|
||||
}
|
||||
keys := []string{}
|
||||
for i := 1; i < size; i += 2 {
|
||||
keys = append(keys, string(resp[i]))
|
||||
keys = append(keys, resp[i])
|
||||
}
|
||||
_, e := rc.conn.Do("multi_del", keys)
|
||||
if e != nil {
|
||||
|
@ -345,7 +345,7 @@ func assignSingleConfig(p interface{}, ac config.Configer) {
|
||||
case reflect.String:
|
||||
pf.SetString(ac.DefaultString(name, pf.String()))
|
||||
case reflect.Int, reflect.Int64:
|
||||
pf.SetInt(int64(ac.DefaultInt64(name, pf.Int())))
|
||||
pf.SetInt(ac.DefaultInt64(name, pf.Int()))
|
||||
case reflect.Bool:
|
||||
pf.SetBool(ac.DefaultBool(name, pf.Bool()))
|
||||
case reflect.Struct:
|
||||
|
@ -395,7 +395,7 @@ func sovLog(x uint64) (n int) {
|
||||
return n
|
||||
}
|
||||
func sozLog(x uint64) (n int) {
|
||||
return sovLog(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
return sovLog((x << 1) ^ (x >> 63))
|
||||
}
|
||||
func (m *Log) Unmarshal(data []byte) error {
|
||||
var hasFields [1]uint64
|
||||
|
@ -106,7 +106,7 @@ func (s *SMTPWriter) sendMail(hostAddressWithPort string, auth smtp.Auth, fromAd
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = w.Write([]byte(msgContent))
|
||||
_, err = w.Write(msgContent)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -92,11 +92,11 @@ func (f StrTo) Int64() (int64, error) {
|
||||
i := new(big.Int)
|
||||
ni, ok := i.SetString(f.String(), 10) // octal
|
||||
if !ok {
|
||||
return int64(v), err
|
||||
return v, err
|
||||
}
|
||||
return ni.Int64(), nil
|
||||
}
|
||||
return int64(v), err
|
||||
return v, err
|
||||
}
|
||||
|
||||
// Uint string to uint
|
||||
@ -130,11 +130,11 @@ func (f StrTo) Uint64() (uint64, error) {
|
||||
i := new(big.Int)
|
||||
ni, ok := i.SetString(f.String(), 10)
|
||||
if !ok {
|
||||
return uint64(v), err
|
||||
return v, err
|
||||
}
|
||||
return ni.Uint64(), nil
|
||||
}
|
||||
return uint64(v), err
|
||||
return v, err
|
||||
}
|
||||
|
||||
// String string to string
|
||||
|
@ -150,7 +150,7 @@ func (lp *Provider) SessionRegenerate(oldsid, sid string) (session.Store, error)
|
||||
if len(kvs) == 0 {
|
||||
kv = make(map[interface{}]interface{})
|
||||
} else {
|
||||
kv, err = session.DecodeGob([]byte(kvs))
|
||||
kv, err = session.DecodeGob(kvs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -46,26 +46,25 @@ func Substr(s string, start, length int) string {
|
||||
|
||||
// HTML2str returns escaping text convert from html.
|
||||
func HTML2str(html string) string {
|
||||
src := string(html)
|
||||
|
||||
re, _ := regexp.Compile("\\<[\\S\\s]+?\\>")
|
||||
src = re.ReplaceAllStringFunc(src, strings.ToLower)
|
||||
html = re.ReplaceAllStringFunc(html, strings.ToLower)
|
||||
|
||||
//remove STYLE
|
||||
re, _ = regexp.Compile("\\<style[\\S\\s]+?\\</style\\>")
|
||||
src = re.ReplaceAllString(src, "")
|
||||
html = re.ReplaceAllString(html, "")
|
||||
|
||||
//remove SCRIPT
|
||||
re, _ = regexp.Compile("\\<script[\\S\\s]+?\\</script\\>")
|
||||
src = re.ReplaceAllString(src, "")
|
||||
html = re.ReplaceAllString(html, "")
|
||||
|
||||
re, _ = regexp.Compile("\\<[\\S\\s]+?\\>")
|
||||
src = re.ReplaceAllString(src, "\n")
|
||||
html = re.ReplaceAllString(html, "\n")
|
||||
|
||||
re, _ = regexp.Compile("\\s{2,}")
|
||||
src = re.ReplaceAllString(src, "\n")
|
||||
html = re.ReplaceAllString(html, "\n")
|
||||
|
||||
return strings.TrimSpace(src)
|
||||
return strings.TrimSpace(html)
|
||||
}
|
||||
|
||||
// DateFormat takes a time and a layout string and returns a string with the formatted date. Used by the template parser as "dateformat"
|
||||
@ -193,7 +192,7 @@ func Str2html(raw string) template.HTML {
|
||||
}
|
||||
|
||||
// Htmlquote returns quoted html string.
|
||||
func Htmlquote(src string) string {
|
||||
func Htmlquote(text string) string {
|
||||
//HTML编码为实体符号
|
||||
/*
|
||||
Encodes `text` for raw use in HTML.
|
||||
@ -201,8 +200,6 @@ func Htmlquote(src string) string {
|
||||
'<'&">'
|
||||
*/
|
||||
|
||||
text := string(src)
|
||||
|
||||
text = strings.Replace(text, "&", "&", -1) // Must be done first!
|
||||
text = strings.Replace(text, "<", "<", -1)
|
||||
text = strings.Replace(text, ">", ">", -1)
|
||||
@ -216,7 +213,7 @@ func Htmlquote(src string) string {
|
||||
}
|
||||
|
||||
// Htmlunquote returns unquoted html string.
|
||||
func Htmlunquote(src string) string {
|
||||
func Htmlunquote(text string) string {
|
||||
//实体符号解释为HTML
|
||||
/*
|
||||
Decodes `text` that's HTML quoted.
|
||||
@ -227,7 +224,6 @@ func Htmlunquote(src string) string {
|
||||
// strings.Replace(s, old, new, n)
|
||||
// 在s字符串中,把old字符串替换为new字符串,n表示替换的次数,小于0表示全部替换
|
||||
|
||||
text := string(src)
|
||||
text = strings.Replace(text, " ", " ", -1)
|
||||
text = strings.Replace(text, "”", "”", -1)
|
||||
text = strings.Replace(text, "“", "“", -1)
|
||||
@ -262,19 +258,17 @@ func URLFor(endpoint string, values ...interface{}) string {
|
||||
}
|
||||
|
||||
// AssetsJs returns script tag with src string.
|
||||
func AssetsJs(src string) template.HTML {
|
||||
text := string(src)
|
||||
func AssetsJs(text string) template.HTML {
|
||||
|
||||
text = "<script src=\"" + src + "\"></script>"
|
||||
text = "<script src=\"" + text + "\"></script>"
|
||||
|
||||
return template.HTML(text)
|
||||
}
|
||||
|
||||
// AssetsCSS returns stylesheet link tag with src string.
|
||||
func AssetsCSS(src string) template.HTML {
|
||||
text := string(src)
|
||||
func AssetsCSS(text string) template.HTML {
|
||||
|
||||
text = "<link href=\"" + src + "\" rel=\"stylesheet\" />"
|
||||
text = "<link href=\"" + text + "\" rel=\"stylesheet\" />"
|
||||
|
||||
return template.HTML(text)
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ func randomBrightness(c color.RGBA, max uint8) color.RGBA {
|
||||
uint8(int(c.R) + n),
|
||||
uint8(int(c.G) + n),
|
||||
uint8(int(c.B) + n),
|
||||
uint8(c.A),
|
||||
c.A,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user