Skip to content

Commit

Permalink
build: add build constraints and implementations for different Go ver…
Browse files Browse the repository at this point in the history
…sions

- Add a build constraint for go1.13 in `gorm/gorm_test.go`
- Remove unused variable in `mongo/mongodriver/mongodriver.go`
- Add a sessions.Store implementation in `mongo/mongodriver/mongodriver.go`
- Add an empty line in `postgres/postgres.go`
- Add a test case in `postgres/postgres_test.go`
- Remove an unused import 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`
- Add a sessions 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 <[email protected]>
  • Loading branch information
appleboy committed Oct 9, 2023
1 parent 03d5b2c commit 84b14d2
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 5 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
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 84b14d2

Please sign in to comment.