Skip to content

Commit

Permalink
build: remove unused variables and add build constraints for go1.10 a…
Browse files Browse the repository at this point in the history
…nd go1.11

- Add a build constraint for go1.13 in `gorm/gorm_test.go`
- Remove unused variable in `mongo/mongodriver/mongodriver.go`
- Remove unused variable in `mongo/mongomgo/mongomgo.go`
- Add an empty import in `postgres/postgres.go`
- Add a test case in `postgres/postgres_test.go`
- Add a build constraint for go1.10 in `session_options_go1.10.go`
- Add a build constraint for go1.11 in `session_options_go1.11.go`
- Remove unused import in `session_options_go1.11.go`
- Add a build constraint for go1.10 in `tester/tester_options_samesite_go1.10.go`
- Add a build constraint for go1.11 in `tester/tester_options_samesite_go1.11.go`

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed Oct 10, 2023
1 parent 03d5b2c commit 4858a5a
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions gorm/gorm_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.13
// +build go1.13

package gorm
Expand Down
4 changes: 1 addition & 3 deletions mongo/mongodriver/mongodriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import (
"go.mongodb.org/mongo-driver/mongo"
)

var (
_ sessions.Store = (*store)(nil)
)
var _ sessions.Store = (*store)(nil)

Check failure on line 9 in mongo/mongodriver/mongodriver.go

View workflow job for this annotation

GitHub Actions / ubuntu-latest @ Go 1.18

cannot use (*store)(nil) (value of type *store) as "github.com/gin-contrib/sessions".Store value in variable declaration: *store does not implement "github.com/gin-contrib/sessions".Store (missing method Get) (typecheck)

func NewStore(c *mongo.Collection, maxAge int, ensureTTL bool, keyPairs ...[]byte) sessions.Store {
return &store{mongostore.NewMongoStore(c, maxAge, ensureTTL, keyPairs...)}

Check failure on line 12 in mongo/mongodriver/mongodriver.go

View workflow job for this annotation

GitHub Actions / ubuntu-latest @ Go 1.18

cannot use &store{…} (value of type *store) as "github.com/gin-contrib/sessions".Store value in return statement: *store does not implement "github.com/gin-contrib/sessions".Store (missing method Get) (typecheck)
Expand Down
4 changes: 1 addition & 3 deletions mongo/mongomgo/mongomgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import (
"github.com/kidstuff/mongostore"
)

var (
_ sessions.Store = (*store)(nil)
)
var _ sessions.Store = (*store)(nil)

func NewStore(c *mgo.Collection, maxAge int, ensureTTL bool, keyPairs ...[]byte) sessions.Store {
return &store{mongostore.NewMongoStore(c, maxAge, ensureTTL, keyPairs...)}
Expand Down
1 change: 1 addition & 0 deletions postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package postgres

import (
"database/sql"

"github.com/antonlindstrom/pgstore"
"github.com/gin-contrib/sessions"
)
Expand Down
3 changes: 2 additions & 1 deletion postgres/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package postgres

import (
"database/sql"
"testing"

"github.com/gin-contrib/sessions"
"github.com/gin-contrib/sessions/tester"
"testing"
)

const postgresTestServer = "postgres://testuser:testpw@localhost:5432/testdb?sslmode=disable"
Expand Down
1 change: 1 addition & 0 deletions session_options_go1.10.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.11
// +build !go1.11

package sessions
Expand Down
4 changes: 3 additions & 1 deletion session_options_go1.11.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//go:build go1.11
// +build go1.11

package sessions

import (
gsessions "github.com/gorilla/sessions"
"net/http"

gsessions "github.com/gorilla/sessions"
)

// Options stores configuration for a session or session store.
Expand Down
1 change: 1 addition & 0 deletions tester/tester_options_samesite_go1.10.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !go1.11
// +build !go1.11

package tester
Expand Down
1 change: 1 addition & 0 deletions tester/tester_options_samesite_go1.11.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build go1.11
// +build go1.11

package tester
Expand Down

0 comments on commit 4858a5a

Please sign in to comment.