Skip to content

Commit b56af23

Browse files
authored
Merge pull request #172 from thedevsaddam/v1
Add go-module support and fix lint issues
2 parents a8c1880 + ca085d9 commit b56af23

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

expr.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (e aliasExpr) ToSql() (sql string, args []interface{}, err error) {
7878
// .Where(Eq{"id": 1})
7979
type Eq map[string]interface{}
8080

81-
func (eq Eq) toSql(useNotOpr bool) (sql string, args []interface{}, err error) {
81+
func (eq Eq) toSQL(useNotOpr bool) (sql string, args []interface{}, err error) {
8282
if len(eq) == 0 {
8383
// Empty Sql{} evaluates to true.
8484
sql = sqlTrue
@@ -102,7 +102,7 @@ func (eq Eq) toSql(useNotOpr bool) (sql string, args []interface{}, err error) {
102102

103103
sortedKeys := getSortedKeys(eq)
104104
for _, key := range sortedKeys {
105-
expr := ""
105+
var expr string
106106
val := eq[key]
107107

108108
switch v := val.(type) {
@@ -149,7 +149,7 @@ func (eq Eq) toSql(useNotOpr bool) (sql string, args []interface{}, err error) {
149149
}
150150

151151
func (eq Eq) ToSql() (sql string, args []interface{}, err error) {
152-
return eq.toSql(false)
152+
return eq.toSQL(false)
153153
}
154154

155155
// NotEq is syntactic sugar for use with Where/Having/Set methods.
@@ -158,7 +158,7 @@ func (eq Eq) ToSql() (sql string, args []interface{}, err error) {
158158
type NotEq Eq
159159

160160
func (neq NotEq) ToSql() (sql string, args []interface{}, err error) {
161-
return Eq(neq).toSql(true)
161+
return Eq(neq).toSQL(true)
162162
}
163163

164164
// Like is syntactic sugar for use with LIKE conditions.
@@ -238,7 +238,7 @@ func (lt Lt) toSql(opposite, orEq bool) (sql string, args []interface{}, err err
238238

239239
sortedKeys := getSortedKeys(lt)
240240
for _, key := range sortedKeys {
241-
expr := ""
241+
var expr string
242242
val := lt[key]
243243

244244
switch v := val.(type) {
@@ -304,12 +304,12 @@ func (c conj) join(sep, defaultExpr string) (sql string, args []interface{}, err
304304
}
305305
var sqlParts []string
306306
for _, sqlizer := range c {
307-
partSql, partArgs, err := sqlizer.ToSql()
307+
partSQL, partArgs, err := sqlizer.ToSql()
308308
if err != nil {
309309
return "", nil, err
310310
}
311-
if partSql != "" {
312-
sqlParts = append(sqlParts, partSql)
311+
if partSQL != "" {
312+
sqlParts = append(sqlParts, partSQL)
313313
args = append(args, partArgs...)
314314
}
315315
}
@@ -319,12 +319,14 @@ func (c conj) join(sep, defaultExpr string) (sql string, args []interface{}, err
319319
return
320320
}
321321

322+
// And conjunction Sqlizers
322323
type And conj
323324

324325
func (a And) ToSql() (string, []interface{}, error) {
325326
return conj(a).join(" AND ", sqlTrue)
326327
}
327328

329+
// Or conjunction Sqlizers
328330
type Or conj
329331

330332
func (o Or) ToSql() (string, []interface{}, error) {

go.mod

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module github.com/Masterminds/squirrel
2+
3+
require (
4+
github.com/davecgh/go-spew v1.1.1 // indirect
5+
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0
6+
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
7+
github.com/pmezard/go-difflib v1.0.0 // indirect
8+
github.com/stretchr/testify v1.2.2
9+
)

go.sum

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 h1:SOEGU9fKiNWd/HOJuq6+3iTQz8KNCLtVX6idSoTLdUw=
4+
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0/go.mod h1:dXGbAdH5GtBTC4WfIxhKZfyBF/HBFgRZSWwZ9g/He9o=
5+
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 h1:P6pPBnrTSX3DEVR4fDembhRWSsG5rVo6hYhAB/ADZrk=
6+
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6FmdpVm2joNMFikkuWg0EoCKLGUMNw=
7+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
8+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
9+
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
10+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

0 commit comments

Comments
 (0)