ls 4 years ago
parent
commit
146bbaeb2f
4 changed files with 4 additions and 7 deletions
  1. 2 2
      types/bool.go
  2. 2 2
      types/string.go
  3. 0 2
      wechat/request.go
  4. 0 1
      wechat/response.go

+ 2 - 2
types/bool.go

@@ -2,7 +2,6 @@ package types
 
 import (
 	"database/sql/driver"
-	"errors"
 )
 
 // BitBool is an implementation of a bool for the MySQL type BIT(1).
@@ -23,7 +22,8 @@ func (b BitBool) Value() (driver.Value, error) {
 func (b *BitBool) Scan(src interface{}) error {
 	v, ok := src.([]byte)
 	if !ok {
-		return errors.New("bad []byte type assertion")
+		*b = false
+		return nil
 	}
 	*b = v[0] == 1
 	return nil

+ 2 - 2
types/string.go

@@ -2,7 +2,6 @@ package types
 
 import (
 	"database/sql/driver"
-	"errors"
 )
 
 // TextNull is an implementation of a string for the MySQL type char/varchar/text ....
@@ -20,7 +19,8 @@ func (s *TextNull) Scan(src interface{}) error {
 	if src != nil {
 		v, ok := src.([]byte)
 		if !ok {
-			return errors.New("bad []byte type assertion")
+			*s = TextNull("")
+			return nil
 		}
 
 		*s = TextNull(v)

+ 0 - 2
wechat/request.go

@@ -10,7 +10,6 @@ import (
 )
 
 func checkJSONError(msg myth.HTTPMessage) (jq *myth.JSONQuery, err error) {
-	//fmt.Println(msg.StatusCode, string(msg.Body))
 	if msg.StatusCode == 200 {
 		jq, err = msg.JSONQuery()
 		if err != nil {
@@ -59,7 +58,6 @@ func getBody(uri string) (msg myth.HTTPMessage, err error) {
 	if err != nil {
 		return
 	}
-	//fmt.Println(msg.StatusCode, string(msg.Body))
 	if msg.StatusCode == 200 {
 		jq := &myth.JSONQuery{}
 		jq, err = msg.JSONQuery()

+ 0 - 1
wechat/response.go

@@ -39,7 +39,6 @@ func ReplyNews(msg Message, items []ArticleItem) (reply ReplyMessage) {
 	reply.Articles = articles
 
 	//bs, _ := xml.Marshal(reply)
-	//fmt.Println(string(bs))
 
 	return
 }