Format code with gofmt

This commit is contained in:
Paolo Galeone 2014-04-03 09:46:51 +02:00
parent 3d642c1987
commit 1fc176d679
2 changed files with 24 additions and 24 deletions

View File

@ -13,14 +13,14 @@ import (
) )
type Scope struct { type Scope struct {
Value interface{} Value interface{}
Search *search Search *search
Sql string Sql string
SqlVars []interface{} SqlVars []interface{}
db *DB db *DB
_values map[string]interface{} _values map[string]interface{}
skipLeft bool skipLeft bool
primaryKey string primaryKey string
} }
// NewScope create scope for callbacks, including DB's search information // NewScope create scope for callbacks, including DB's search information
@ -79,11 +79,11 @@ func (scope *Scope) HasError() bool {
// PrimaryKey get the primary key's column name // PrimaryKey get the primary key's column name
func (scope *Scope) PrimaryKey() string { func (scope *Scope) PrimaryKey() string {
if scope.primaryKey != "" { if scope.primaryKey != "" {
return scope.primaryKey return scope.primaryKey
} }
scope.primaryKey = scope.getPrimaryKey() scope.primaryKey = scope.getPrimaryKey()
return scope.primaryKey return scope.primaryKey
} }
@ -247,10 +247,10 @@ func (scope *Scope) Fields() []*Field {
// Search for primary key tag identifier // Search for primary key tag identifier
field.isPrimaryKey = scope.PrimaryKey() == field.DBName || fieldStruct.Tag.Get("primaryKey") != "" field.isPrimaryKey = scope.PrimaryKey() == field.DBName || fieldStruct.Tag.Get("primaryKey") != ""
fmt.Printf("Name: %s\n isPrimaryKey: %v\n\n",field.DBName, field.isPrimaryKey) fmt.Printf("Name: %s\n isPrimaryKey: %v\n\n", field.DBName, field.isPrimaryKey)
if field.isPrimaryKey { if field.isPrimaryKey {
scope.primaryKey = field.DBName scope.primaryKey = field.DBName
} }
if scope.db != nil { if scope.db != nil {
field.Tag = fieldStruct.Tag field.Tag = fieldStruct.Tag

View File

@ -5,12 +5,12 @@ import (
"database/sql/driver" "database/sql/driver"
"errors" "errors"
"fmt" "fmt"
"go/ast"
"reflect" "reflect"
"regexp" "regexp"
"strconv" "strconv"
"strings" "strings"
"time" "time"
"go/ast"
) )
func (scope *Scope) primaryCondiation(value interface{}) string { func (scope *Scope) primaryCondiation(value interface{}) string {
@ -488,12 +488,12 @@ func (scope *Scope) getPrimaryKey() string {
continue continue
} }
// if primaryKey tag found, return column name // if primaryKey tag found, return column name
if fieldStruct.Tag.Get("primaryKey") != "" { if fieldStruct.Tag.Get("primaryKey") != "" {
return toSnake(fieldStruct.Name) return toSnake(fieldStruct.Name)
} }
} }
//If primaryKey tag not found, fallback to id //If primaryKey tag not found, fallback to id
return "id" return "id"
} }