func (scope *Scope) FieldValueByName(name string) (interface{}, error) {
	return FieldValueByName(name, scope.Value)
}
FieldValueByName to get column's value and existence
package gorm
import (
	"errors"
	"fmt"
	"go/ast"
	"strings"
	"time"
	"reflect"
	"regexp"
)
type Scope struct {
	Value           interface{}
	indirectValue   *reflect.Value
	Search          *search
	Sql             string
	SqlVars         []interface{}
	db              *DB
	skipLeft        bool
	primaryKeyField *Field
	instanceId      string
	fields          map[string]*Field
}
func (scope *Scope) IndirectValue() reflect.Value {
	if scope.indirectValue == nil {
		value := reflect.Indirect(reflect.ValueOf(scope.Value))
		scope.indirectValue = &value
	}
	return *scope.indirectValue
}
func (db *DB) NewScope(value interface{}) *Scope {
	db.Value = value
	return &Scope{db: db, Search: db.search, Value: value}
}
func (scope *Scope) NeedPtr() *Scope {
	reflectKind := reflect.ValueOf(scope.Value).Kind()
	if !((reflectKind == reflect.Invalid) || (reflectKind == reflect.Ptr)) {
		err := errors.New(fmt.Sprintf("%v %v\n", fileWithLineNum(), "using unaddressable value"))
		scope.Err(err)
		fmt.Printf(err.Error())
	}
	return scope
}
func (scope *Scope) New(value interface{}) *Scope {
	return &Scope{db: scope.db, Search: &search{}, Value: value}
}
func (scope *Scope) NewDB() *DB {
	return scope.db.New()
}
func (scope *Scope) DB() sqlCommon {
	return scope.db.db
}
func (scope *Scope) SkipLeft() {
	scope.skipLeft = true
}
func (scope *Scope) Quote(str string) string {
	return scope.Dialect().Quote(str)
}
func (scope *Scope) Dialect() Dialect {
	return scope.db.parent.dialect
}
func (scope *Scope) Err(err error) error {
	if err != nil {
		scope.db.err(err)
	}
	return err
}
func (scope *Scope) Log(v ...interface{}) {
	scope.db.log(v...)
}
func (scope *Scope) HasError() bool {
	return scope.db.Error != nil
}
func (scope *Scope) PrimaryKeyField() *Field {
	if scope.primaryKeyField == nil {
		var indirectValue = scope.IndirectValue()
		clone := scope
		if indirectValue.Kind() == reflect.Slice {
			clone = scope.New(reflect.New(indirectValue.Type().Elem()).Elem().Interface())
		}
		for _, field := range clone.Fields() {
			if field.IsPrimaryKey {
				scope.primaryKeyField = field
				break
			}
		}
	}
	return scope.primaryKeyField
}
func (scope *Scope) PrimaryKey() string {
	if field := scope.PrimaryKeyField(); field != nil {
		return field.DBName
	} else {
		return ""
	}
}
func (scope *Scope) PrimaryKeyZero() bool {
	return isBlank(reflect.ValueOf(scope.PrimaryKeyValue()))
}
func (scope *Scope) PrimaryKeyValue() interface{} {
	if field := scope.PrimaryKeyField(); field != nil {
		return field.Field.Interface()
	} else {
		return 0
	}
}
func (scope *Scope) HasColumn(column string) bool {
	clone := scope
	if scope.IndirectValue().Kind() == reflect.Slice {
		value := reflect.New(scope.IndirectValue().Type().Elem()).Interface()
		clone = scope.New(value)
	}
	dbName := ToSnake(column)
	field, hasColumn := clone.Fields(false)[dbName]
	return hasColumn && !field.IsIgnored
}