Skip to content

Commit

Permalink
format project
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuxiujia committed Dec 29, 2018
1 parent 33e6ff0 commit 05e3965
Show file tree
Hide file tree
Showing 17 changed files with 98 additions and 97 deletions.
2 changes: 1 addition & 1 deletion RegexReplaceArg_test.go
Expand Up @@ -38,7 +38,7 @@ func Test_Access_Arg(t *testing.T) {
var string = "-----#{bean.Name}------#{bean.Child.Age}---"

var arg = replaceArg(string, param, GoMybatisSqlArgTypeConvert{})
if arg != "-----father------11---"{
if arg != "-----father------11---" {
t.Fatal("replaceArgFail")
}
fmt.Println(arg)
Expand Down
2 changes: 1 addition & 1 deletion SessionType.go
Expand Up @@ -3,7 +3,7 @@ package GoMybatis
type SessionType = int

const (
SessionType_Default SessionType = iota
SessionType_Default SessionType = iota
SessionType_Local
SessionType_TransationRM
SessionType_UnKnow
Expand Down
4 changes: 1 addition & 3 deletions SqlResultDecodeUtil_test.go
Expand Up @@ -86,7 +86,6 @@ func Test_Convert_Map(t *testing.T) {
var resMapArray = make([]map[string][]byte, 0)
resMapArray = append(resMapArray, resMap)


var result map[string]string
var error = GoMybatisSqlResultDecoder{}.Decode(nil, resMapArray, &result)
if error != nil {
Expand Down Expand Up @@ -231,7 +230,6 @@ func Test_Decode_Interface(t *testing.T) {
fmt.Println("Test_Decode_Interface", result)
}


func Benchmark_Ignore_Case_Underscores(b *testing.B) {
b.StopTimer()
var GoMybatisSqlResultDecoder = GoMybatisSqlResultDecoder{}
Expand Down Expand Up @@ -259,4 +257,4 @@ func Benchmark_Ignore_Case_Underscores(b *testing.B) {
GoMybatisSqlResultDecoder.Decode(nil, res, &result)
}

}
}
4 changes: 2 additions & 2 deletions TransactionDefinition.go
Expand Up @@ -7,7 +7,7 @@ type ISOLATION int

//隔离级别
const (
ISOLATION_DEFAULT ISOLATION = iota - 1
ISOLATION_DEFAULT ISOLATION = iota - 1
ISOLATION_READ_UNCOMMITTED
ISOLATION_READ_COMMITTED
ISOLATION_REPEATABLE_READ
Expand All @@ -16,7 +16,7 @@ const (

//传播行为
const (
PROPAGATION_REQUIRED PROPAGATION = iota
PROPAGATION_REQUIRED PROPAGATION = iota
PROPAGATION_SUPPORTS
PROPAGATION_MANDATORY
PROPAGATION_REQUIRES_NEW
Expand Down
2 changes: 1 addition & 1 deletion TransactionFactory.go
Expand Up @@ -41,7 +41,7 @@ func (this *TransactionFactory) Append(transactionId string, transaction Transac
if transactionId == "" {
return
}
var old,_ = this.GetTransactionStatus(transactionId)
var old, _ = this.GetTransactionStatus(transactionId)
if old != nil {
this.SetTransactionStatus(transactionId, old)
}
Expand Down
6 changes: 3 additions & 3 deletions TransactionManager.go
Expand Up @@ -14,7 +14,7 @@ const (
Transaction_Status_Rollback //回滚事务
)

func (status Transaction_Status)ToString() string {
func (status Transaction_Status) ToString() string {
switch status {
case Transaction_Status_NO:
return "Transaction_Status_NO"
Expand Down Expand Up @@ -143,7 +143,7 @@ func (this DefaultTransationManager) DoTransaction(dto TransactionReqDTO) Transa
Error: err.Error(),
}
}
log.Println("[TransactionManager] do transactionId=", dto.TransactionId,",sessionId=",transcationStatus.Transaction.Session.Id(),"status=",dto.Status.ToString())
log.Println("[TransactionManager] do transactionId=", dto.TransactionId, ",sessionId=", transcationStatus.Transaction.Session.Id(), "status=", dto.Status.ToString())

if dto.Status == Transaction_Status_NO {
defer transcationStatus.Flush() //关闭
Expand Down Expand Up @@ -205,7 +205,7 @@ func (this DefaultTransationManager) DoAction(dto TransactionReqDTO, transcation
return TransactionRspDTO
}
if dto.ActionType == ActionType_Exec {
log.Println("[TransactionManager] TransactionId:",dto.TransactionId,",Exec:", dto.Sql)
log.Println("[TransactionManager] TransactionId:", dto.TransactionId, ",Exec:", dto.Sql)
var res, e = transcationStatus.Transaction.Session.Exec(dto.Sql)
var err string
if e != nil {
Expand Down
24 changes: 12 additions & 12 deletions TransactionManager_test.go
@@ -1,13 +1,13 @@
package GoMybatis

import (
"errors"
"fmt"
_ "github.com/go-sql-driver/mysql"
"github.com/zhuxiujia/GoMybatis/example"
"github.com/zhuxiujia/GoMybatis/utils"
"strconv"
"testing"
"errors"
)

var manager DefaultTransationManager
Expand All @@ -31,7 +31,7 @@ func TestManager(t *testing.T) {
TestPropertyServiceA: TestPropertyServiceA,
TestPropertyServiceB: TestPropertyServiceB,
}
err=TestOrderService.Transform(utils.CreateUUID(), "20181023162632152fd236d6877ff4", "20180926172013b85403d3715d46ed", 100)
err = TestOrderService.Transform(utils.CreateUUID(), "20181023162632152fd236d6877ff4", "20180926172013b85403d3715d46ed", 100)
if err != nil {
t.Fatal(err)
}
Expand All @@ -51,10 +51,10 @@ func (TestPropertyServiceA) Add(transactionId string, id string, amt int) error
Sql: sql,
}
var result = manager.DoTransaction(dto)
fmt.Println(dto.TransactionId,result.Exec)
fmt.Println(dto.TransactionId, result.Exec)
dto.Status = Transaction_Status_Commit
rspDTO := manager.DoTransaction(dto) //commit
if rspDTO.Error!=""{
if rspDTO.Error != "" {
return errors.New(rspDTO.Error)
}
return nil
Expand All @@ -74,10 +74,10 @@ func (TestPropertyServiceB) Reduce(transactionId string, id string, amt int) err
Sql: sql,
}
var result = manager.DoTransaction(dto)
fmt.Println(dto.TransactionId,result.Exec)
fmt.Println(dto.TransactionId, result.Exec)
dto.Status = Transaction_Status_Commit
rspDTO := manager.DoTransaction(dto) //commit
if rspDTO.Error!=""{
if rspDTO.Error != "" {
return errors.New(rspDTO.Error)
}
return nil
Expand All @@ -99,8 +99,8 @@ func (this TestOrderService) Transform(transactionId string, outid string, inId
Sql: "",
}
rspDTO := manager.DoTransaction(dto) //开启事务
if rspDTO.Error!=""{
return errors.New(rspDTO.Error)
if rspDTO.Error != "" {
return errors.New(rspDTO.Error)
}
//事务id=2018092d6172014a2a4c8a949f1004623,已存在的事务不可提交commit,只能提交状态rollback和Pause
var e1 = this.TestPropertyServiceB.Reduce(transactionId, outid, amount)
Expand All @@ -109,8 +109,8 @@ func (this TestOrderService) Transform(transactionId string, outid string, inId
}

dto.Status = Transaction_Status_Rollback
rspDTO=manager.DoTransaction(dto)
if rspDTO.Error!=""{
rspDTO = manager.DoTransaction(dto)
if rspDTO.Error != "" {
return errors.New(rspDTO.Error)
}
//事务id=2018092d6172014a2a4c8a949f1004623,已存在的事务不可提交commit,只能提交状态rollback和Pause
Expand All @@ -122,8 +122,8 @@ func (this TestOrderService) Transform(transactionId string, outid string, inId
//manager.Rollback(transactionId)
//事务id=2018092d6172014a2a4c8a949f1004623,原始事务可提交commit,rollback和Pause
dto.Status = Transaction_Status_Commit
rspDTO=manager.DoTransaction(dto)
if rspDTO.Error!=""{
rspDTO = manager.DoTransaction(dto)
if rspDTO.Error != "" {
return errors.New(rspDTO.Error)
}
return nil
Expand Down
6 changes: 3 additions & 3 deletions TransationRMClient.go
Expand Up @@ -79,9 +79,9 @@ func (this *TransationRMClient) Call(arg TransactionReqDTO, result *TransactionR
return error
}

func (this *TransationRMClient) Close() error{
if this.Client!=nil{
func (this *TransationRMClient) Close() error {
if this.Client != nil {
return this.Client.Close()
}
return nil
}
}
2 changes: 1 addition & 1 deletion TransationRM_test.go
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestTransationRM(t *testing.T) {
if example.ExampleDriverName == "" || example.MysqlUri == "" || example.MysqlUri == "*" {
if example.MysqlUri == "" || example.MysqlUri == "*" {
fmt.Println("no mysql config in project, you must set the mysql link!")
return
}
Expand Down
6 changes: 3 additions & 3 deletions TypeConvertAdapter.go
Expand Up @@ -28,8 +28,8 @@ type GoMybatisExpressionTypeConvert struct {

//表达式类型转换器
func (this GoMybatisExpressionTypeConvert) Convert(arg SqlArg) interface{} {
if arg.Type.Kind() == reflect.Struct && arg.Type.String() == Adapter_DateType{
return arg.Value.(time.Time).Nanosecond()
if arg.Type.Kind() == reflect.Struct && arg.Type.String() == Adapter_DateType {
return arg.Value.(time.Time).Nanosecond()
}
return arg.Value
}
Expand Down Expand Up @@ -61,7 +61,7 @@ func (this GoMybatisSqlArgTypeConvert) Convert(arg SqlArg) string {
argStr.WriteString(`'`)
return argStr.String()
case reflect.Struct:
if argType.String() == Adapter_DateType{
if argType.String() == Adapter_DateType {
var argStr bytes.Buffer
argStr.WriteString(`'`)
argStr.WriteString(argValue.(time.Time).Format(Adapter_FormateDate))
Expand Down
2 changes: 1 addition & 1 deletion TypeConvertAdapter_test.go
Expand Up @@ -12,7 +12,7 @@ func Test_Adapter(t *testing.T) {
Value: a,
Type: reflect.TypeOf(a),
})
if convertResult != true{
if convertResult != true {
t.Fatal(`Test_Adapter fail convertResult != true`)
}
fmt.Println(convertResult)
Expand Down
2 changes: 1 addition & 1 deletion XmlLoader_test.go
Expand Up @@ -16,7 +16,7 @@ func Test_Load_Xml(t *testing.T) {
defer file.Close()
bytes, _ := ioutil.ReadAll(file)
var xmlItems = LoadMapperXml(bytes)
if xmlItems==nil{
if xmlItems == nil {
t.Fatal(`Test_Load_Xml fail,LoadMapperXml "example/Example_ActivityMapper.xml"`)
}
fmt.Println(xmlItems)
Expand Down
2 changes: 1 addition & 1 deletion example/Example_config.go
Expand Up @@ -2,4 +2,4 @@ package example

//mysql链接格式为 用户名:密码@(数据库链接地址:端口)/数据库名称 例如root:root@(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local
//此处请按格式填写你的mysql链接,这里用*号代替
const MysqlUri = "*"
const MysqlUri = "*"
96 changes: 48 additions & 48 deletions lib/github.com/Knetic/govaluate/OperatorSymbol.go
Expand Up @@ -7,64 +7,64 @@ package govaluate
type OperatorSymbol int

const (
VALUE OperatorSymbol = iota
LITERAL
NOOP
EQ
NEQ
GT
LT
GTE
LTE
REQ
NREQ
IN
VALUE OperatorSymbol = iota
LITERAL
NOOP
EQ
NEQ
GT
LT
GTE
LTE
REQ
NREQ
IN

AND
OR
AND
OR

PLUS
MINUS
BITWISE_AND
BITWISE_OR
BITWISE_XOR
BITWISE_LSHIFT
BITWISE_RSHIFT
MULTIPLY
DIVIDE
MODULUS
EXPONENT
PLUS
MINUS
BITWISE_AND
BITWISE_OR
BITWISE_XOR
BITWISE_LSHIFT
BITWISE_RSHIFT
MULTIPLY
DIVIDE
MODULUS
EXPONENT

NEGATE
INVERT
BITWISE_NOT
NEGATE
INVERT
BITWISE_NOT

TERNARY_TRUE
TERNARY_FALSE
COALESCE
TERNARY_TRUE
TERNARY_FALSE
COALESCE

FUNCTIONAL
ACCESS
SEPARATE
FUNCTIONAL
ACCESS
SEPARATE
)

type operatorPrecedence int

const (
noopPrecedence operatorPrecedence = iota
valuePrecedence
functionalPrecedence
prefixPrecedence
exponentialPrecedence
additivePrecedence
bitwisePrecedence
bitwiseShiftPrecedence
multiplicativePrecedence
comparatorPrecedence
ternaryPrecedence
logicalAndPrecedence
logicalOrPrecedence
separatePrecedence
noopPrecedence operatorPrecedence = iota
valuePrecedence
functionalPrecedence
prefixPrecedence
exponentialPrecedence
additivePrecedence
bitwisePrecedence
bitwiseShiftPrecedence
multiplicativePrecedence
comparatorPrecedence
ternaryPrecedence
logicalAndPrecedence
logicalOrPrecedence
separatePrecedence
)

func findOperatorPrecedenceForSymbol(symbol OperatorSymbol) operatorPrecedence {
Expand Down

0 comments on commit 05e3965

Please sign in to comment.