refactor: move postgres to pg package (#1781)

master
Kevin Wan 3 years ago committed by GitHub
parent 50de01fb49
commit ba8ac974aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -71,8 +71,8 @@ func NewTimingWheel(interval time.Duration, numSlots int, execute Execute) (*Tim
return newTimingWheelWithClock(interval, numSlots, execute, timex.NewTicker(interval))
}
func newTimingWheelWithClock(interval time.Duration, numSlots int, execute Execute, ticker timex.Ticker) (
*TimingWheel, error) {
func newTimingWheelWithClock(interval time.Duration, numSlots int, execute Execute,
ticker timex.Ticker) (*TimingWheel, error) {
tw := &TimingWheel{
interval: interval,
ticker: ticker,

@ -0,0 +1,14 @@
package pg
import (
// imports the driver, don't remove this comment, golint requires.
_ "github.com/lib/pq"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
const postgresDriverName = "postgres"
// New returns a postgres connection.
func New(datasource string, opts ...sqlx.SqlOption) sqlx.SqlConn {
return sqlx.NewSqlConn(postgresDriverName, datasource, opts...)
}

@ -0,0 +1,11 @@
package pg
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPostgreSql(t *testing.T) {
assert.NotNil(t, New("postgre"))
}

@ -1,14 +1,7 @@
package postgres
import (
// imports the driver, don't remove this comment, golint requires.
_ "github.com/lib/pq"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
import "github.com/zeromicro/go-zero/core/stores/pg"
const postgresDriverName = "postgres"
// New returns a postgres connection.
func New(datasource string, opts ...sqlx.SqlOption) sqlx.SqlConn {
return sqlx.NewSqlConn(postgresDriverName, datasource, opts...)
}
// New creates a new postgresql store.
// Deprecated: use pg.New instead.
var New = pg.New

Loading…
Cancel
Save