diff --git a/lru_cacher.go b/lru_cacher.go index 855cce2e..9b995c2d 100644 --- a/lru_cacher.go +++ b/lru_cacher.go @@ -92,7 +92,7 @@ func (m *LRUCacher) GC() { } } -// Get all bean's ids according to sql and parameter from cache +// GetIds returns all bean's ids according to sql and parameter from cache func (m *LRUCacher) GetIds(tableName, sql string) interface{} { m.mutex.Lock() defer m.mutex.Unlock() @@ -121,7 +121,7 @@ func (m *LRUCacher) GetIds(tableName, sql string) interface{} { return nil } -// Get bean according tableName and id from cache +// GetBean returns bean according tableName and id from cache func (m *LRUCacher) GetBean(tableName string, id string) interface{} { m.mutex.Lock() defer m.mutex.Unlock() diff --git a/memory_store.go b/memory_store.go index 60330995..caf12b10 100644 --- a/memory_store.go +++ b/memory_store.go @@ -12,7 +12,7 @@ import ( var _ core.CacheStore = NewMemoryStore() -// memory store +// MemoryStore represents in-memory store type MemoryStore struct { store map[interface{}]interface{} mutex sync.RWMutex diff --git a/mssql_dialect.go b/mssql_dialect.go index a4d5a02f..2c6fede4 100644 --- a/mssql_dialect.go +++ b/mssql_dialect.go @@ -5,7 +5,6 @@ package xorm import ( - "errors" "fmt" "strconv" "strings" @@ -380,8 +379,7 @@ func (db *mssql) GetColumns(tableName string) ([]string, map[string]*core.Column if _, ok := core.SqlTypes[ct]; ok { col.SQLType = core.SQLType{Name: ct, DefaultLength: 0, DefaultLength2: 0} } else { - return nil, nil, errors.New(fmt.Sprintf("unknow colType %v for %v - %v", - ct, tableName, col.Name)) + return nil, nil, fmt.Errorf("Unknown colType %v for %v - %v", ct, tableName, col.Name) } } diff --git a/mysql_dialect.go b/mysql_dialect.go index 2ff57f1c..0ac5bad8 100644 --- a/mysql_dialect.go +++ b/mysql_dialect.go @@ -6,7 +6,6 @@ package xorm import ( "crypto/tls" - "errors" "fmt" "strconv" "strings" @@ -375,7 +374,7 @@ func (db *mysql) GetColumns(tableName string) ([]string, map[string]*core.Column if _, ok := core.SqlTypes[colType]; ok { col.SQLType = core.SQLType{Name: colType, DefaultLength: len1, DefaultLength2: len2} } else { - return nil, nil, errors.New(fmt.Sprintf("unkonw colType %v", colType)) + return nil, nil, fmt.Errorf("Unknown colType %v", colType) } if colKey == "PRI" { diff --git a/oracle_dialect.go b/oracle_dialect.go index a8b9d286..d4aee930 100644 --- a/oracle_dialect.go +++ b/oracle_dialect.go @@ -5,7 +5,6 @@ package xorm import ( - "errors" "fmt" "strconv" "strings" @@ -757,7 +756,7 @@ func (db *oracle) GetColumns(tableName string) ([]string, map[string]*core.Colum } if _, ok := core.SqlTypes[col.SQLType.Name]; !ok { - return nil, nil, errors.New(fmt.Sprintf("unkonw colType %v %v", *dataType, col.SQLType)) + return nil, nil, fmt.Errorf("Unknown colType %v %v", *dataType, col.SQLType) } col.Length = dataLen diff --git a/postgres_dialect.go b/postgres_dialect.go index 2fc1e09e..27daabc6 100644 --- a/postgres_dialect.go +++ b/postgres_dialect.go @@ -5,7 +5,6 @@ package xorm import ( - "errors" "fmt" "strconv" "strings" @@ -990,7 +989,7 @@ WHERE c.relkind = 'r'::char AND c.relname = $1 AND s.table_schema = $2 AND f.att col.SQLType = core.SQLType{Name: strings.ToUpper(dataType), DefaultLength: 0, DefaultLength2: 0} } if _, ok := core.SqlTypes[col.SQLType.Name]; !ok { - return nil, nil, errors.New(fmt.Sprintf("unknow colType: %v", dataType)) + return nil, nil, fmt.Errorf("Unknown colType: %v", dataType) } col.Length = maxLen diff --git a/processors.go b/processors.go index 8f95ae3b..271bad2b 100644 --- a/processors.go +++ b/processors.go @@ -4,17 +4,17 @@ package xorm -// Executed before an object is initially persisted to the database +// BeforeInsertProcessor executed before an object is initially persisted to the database type BeforeInsertProcessor interface { BeforeInsert() } -// Executed before an object is updated +// BeforeUpdateProcessor executed before an object is updated type BeforeUpdateProcessor interface { BeforeUpdate() } -// Executed before an object is deleted +// BeforeDeleteProcessor executed before an object is deleted type BeforeDeleteProcessor interface { BeforeDelete() } @@ -34,17 +34,17 @@ type AfterSetProcessor interface { //} // -- -// Executed after an object is persisted to the database +// AfterInsertProcessor executed after an object is persisted to the database type AfterInsertProcessor interface { AfterInsert() } -// Executed after an object has been updated +// AfterUpdateProcessor executed after an object has been updated type AfterUpdateProcessor interface { AfterUpdate() } -// Executed after an object has been deleted +// AfterDeleteProcessor executed after an object has been deleted type AfterDeleteProcessor interface { AfterDelete() } diff --git a/session.go b/session.go index 54957562..0223d1ef 100644 --- a/session.go +++ b/session.go @@ -371,7 +371,7 @@ func (session *Session) DB() *core.DB { return session.db } -// Cond return session's conditions +// Conds returns session query conditions func (session *Session) Conds() builder.Cond { return session.Statement.cond } diff --git a/statement.go b/statement.go index dc426946..944de956 100644 --- a/statement.go +++ b/statement.go @@ -128,7 +128,7 @@ func (statement *Statement) Alias(alias string) *Statement { return statement } -// Sql add the raw sql statement +// SQL adds raw sql statement func (statement *Statement) SQL(query interface{}, args ...interface{}) *Statement { switch query.(type) { case (*builder.Builder): @@ -795,14 +795,14 @@ func (statement *Statement) col2NewColsWithQuote(columns ...string) []string { return newColumns } -// Generate "Distince col1, col2 " statment +// Distinct generates "DISTINCT col1, col2 " statement func (statement *Statement) Distinct(columns ...string) *Statement { statement.IsDistinct = true statement.Cols(columns...) return statement } -// Generate "SELECT ... FOR UPDATE" statment +// ForUpdate generates "SELECT ... FOR UPDATE" statement func (statement *Statement) ForUpdate() *Statement { statement.IsForUpdate = true return statement