Merge pull request #488 from nemec784/fix/warnings/should_omit_type

golint: should omit (type|2nd value) ...
This commit is contained in:
Lunny Xiao 2016-11-09 21:43:34 +08:00 committed by GitHub
commit 765833d39b
9 changed files with 26 additions and 21 deletions

View File

@ -24,7 +24,7 @@ func mysqlEngine() (*xorm.Engine, error) {
return xorm.NewEngine("mysql", "root:@/test?charset=utf8")
}
var u *User = &User{}
var u = &User{}
func test(engine *xorm.Engine) {
err := engine.CreateTables(u)

View File

@ -15,10 +15,10 @@ type Status struct {
}
var (
Registed Status = Status{"Registed", "white"}
Approved Status = Status{"Approved", "green"}
Removed Status = Status{"Removed", "red"}
Statuses map[string]Status = map[string]Status{
Registed = Status{"Registed", "white"}
Approved = Status{"Approved", "green"}
Removed = Status{"Removed", "red"}
Statuses = map[string]Status{
Registed.Name: Registed,
Approved.Name: Approved,
Removed.Name: Removed,

View File

@ -24,7 +24,7 @@ func mysqlEngine() (*xorm.Engine, error) {
return xorm.NewEngine("mysql", "root:@/test?charset=utf8")
}
var u *User = &User{}
var u = &User{}
func test(engine *xorm.Engine) {
err := engine.CreateTables(u)

View File

@ -24,7 +24,7 @@ func mysqlEngine() (*xorm.Engine, error) {
return xorm.NewEngine("mysql", "root:@/test?charset=utf8")
}
var u *User = &User{}
var u = &User{}
func test(engine *xorm.Engine) {
err := engine.CreateTables(u)

View File

@ -257,8 +257,9 @@ func (db *mssql) SqlType(c *core.Column) string {
return core.Int
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
hasLen1 := (c.Length > 0)
hasLen2 := (c.Length2 > 0)
if hasLen2 {
res += "(" + strconv.Itoa(c.Length) + "," + strconv.Itoa(c.Length2) + ")"
} else if hasLen1 {

View File

@ -201,7 +201,7 @@ func (db *mysql) SqlType(c *core.Column) string {
res = core.Enum
res += "("
opts := ""
for v, _ := range c.EnumOptions {
for v := range c.EnumOptions {
opts += fmt.Sprintf(",'%v'", v)
}
res += strings.TrimLeft(opts, ",")
@ -210,7 +210,7 @@ func (db *mysql) SqlType(c *core.Column) string {
res = core.Set
res += "("
opts := ""
for v, _ := range c.SetOptions {
for v := range c.SetOptions {
opts += fmt.Sprintf(",'%v'", v)
}
res += strings.TrimLeft(opts, ",")
@ -226,8 +226,8 @@ func (db *mysql) SqlType(c *core.Column) string {
res = t
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
hasLen1 := (c.Length > 0)
hasLen2 := (c.Length2 > 0)
if res == core.BigInt && !hasLen1 && !hasLen2 {
c.Length = 20

View File

@ -525,8 +525,9 @@ func (db *oracle) SqlType(c *core.Column) string {
res = t
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
hasLen1 := (c.Length > 0)
hasLen2 := (c.Length2 > 0)
if hasLen2 {
res += "(" + strconv.Itoa(c.Length) + "," + strconv.Itoa(c.Length2) + ")"
} else if hasLen1 {

View File

@ -812,8 +812,9 @@ func (db *postgres) SqlType(c *core.Column) string {
res = t
}
var hasLen1 bool = (c.Length > 0)
var hasLen2 bool = (c.Length2 > 0)
hasLen1 := (c.Length > 0)
hasLen2 := (c.Length2 > 0)
if hasLen2 {
res += "(" + strconv.Itoa(c.Length) + "," + strconv.Itoa(c.Length2) + ")"
} else if hasLen1 {
@ -879,9 +880,10 @@ func (db *postgres) ModifyColumnSql(tableName string, col *core.Column) string {
}
func (db *postgres) DropIndexSql(tableName string, index *core.Index) string {
quote := db.Quote
//var unique string
var idxName string = index.Name
quote := db.Quote
idxName := index.Name
if !strings.HasPrefix(idxName, "UQE_") &&
!strings.HasPrefix(idxName, "IDX_") {
if index.Type == core.UniqueType {

View File

@ -237,9 +237,10 @@ func (db *sqlite3) TableCheckSql(tableName string) (string, []interface{}) {
}
func (db *sqlite3) DropIndexSql(tableName string, index *core.Index) string {
quote := db.Quote
//var unique string
var idxName string = index.Name
quote := db.Quote
idxName := index.Name
if !strings.HasPrefix(idxName, "UQE_") &&
!strings.HasPrefix(idxName, "IDX_") {
if index.Type == core.UniqueType {