2
0

Apply gofmt -s

And add CI check for that.
This commit is contained in:
Alexey Palazhchenko
2023-01-24 10:59:20 +04:00
committed by Jack Christensen
parent f581584148
commit f839d501a7
8 changed files with 69 additions and 63 deletions
+7 -1
View File
@@ -75,7 +75,7 @@ jobs:
steps: steps:
- name: Set up Go 1.x - name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v3 uses: actions/setup-go@v3
with: with:
go-version: ${{ matrix.go-version }} go-version: ${{ matrix.go-version }}
@@ -104,6 +104,12 @@ jobs:
# PGX_SSL_PASSWORD: ${{ matrix.pgx-ssl-password }} # PGX_SSL_PASSWORD: ${{ matrix.pgx-ssl-password }}
# PGX_TEST_TLS_CLIENT_CONN_STRING: ${{ matrix.pgx-test-tls-client-conn-string }} # PGX_TEST_TLS_CLIENT_CONN_STRING: ${{ matrix.pgx-test-tls-client-conn-string }}
- name: Check formatting
run: |
gofmt -l -s -w .
git status
git diff --exit-code
- name: Test - name: Test
run: go test -race ./... run: go test -race ./...
env: env:
+1 -1
View File
@@ -23,7 +23,7 @@ func TestScript(t *testing.T) {
script.Steps = append(script.Steps, pgmock.ExpectMessage(&pgproto3.Query{String: "select 42"})) script.Steps = append(script.Steps, pgmock.ExpectMessage(&pgproto3.Query{String: "select 42"}))
script.Steps = append(script.Steps, pgmock.SendMessage(&pgproto3.RowDescription{ script.Steps = append(script.Steps, pgmock.SendMessage(&pgproto3.RowDescription{
Fields: []pgproto3.FieldDescription{ Fields: []pgproto3.FieldDescription{
pgproto3.FieldDescription{ {
Name: []byte("?column?"), Name: []byte("?column?"),
TableOID: 0, TableOID: 0,
TableAttributeNumber: 0, TableAttributeNumber: 0,
+19 -19
View File
@@ -77,7 +77,7 @@ func TestParseConfig(t *testing.T) {
}, },
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "localhost", Host: "localhost",
Port: 5432, Port: 5432,
TLSConfig: nil, TLSConfig: nil,
@@ -110,7 +110,7 @@ func TestParseConfig(t *testing.T) {
TLSConfig: nil, TLSConfig: nil,
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "localhost", Host: "localhost",
Port: 5432, Port: 5432,
TLSConfig: &tls.Config{ TLSConfig: &tls.Config{
@@ -137,7 +137,7 @@ func TestParseConfig(t *testing.T) {
}, },
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "localhost", Host: "localhost",
Port: 5432, Port: 5432,
TLSConfig: nil, TLSConfig: nil,
@@ -431,12 +431,12 @@ func TestParseConfig(t *testing.T) {
TLSConfig: nil, TLSConfig: nil,
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "bar", Host: "bar",
Port: defaultPort, Port: defaultPort,
TLSConfig: nil, TLSConfig: nil,
}, },
&pgconn.FallbackConfig{ {
Host: "baz", Host: "baz",
Port: defaultPort, Port: defaultPort,
TLSConfig: nil, TLSConfig: nil,
@@ -456,12 +456,12 @@ func TestParseConfig(t *testing.T) {
TLSConfig: nil, TLSConfig: nil,
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "bar", Host: "bar",
Port: 2, Port: 2,
TLSConfig: nil, TLSConfig: nil,
}, },
&pgconn.FallbackConfig{ {
Host: "baz", Host: "baz",
Port: 3, Port: 3,
TLSConfig: nil, TLSConfig: nil,
@@ -495,12 +495,12 @@ func TestParseConfig(t *testing.T) {
TLSConfig: nil, TLSConfig: nil,
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "bar", Host: "bar",
Port: 5432, Port: 5432,
TLSConfig: nil, TLSConfig: nil,
}, },
&pgconn.FallbackConfig{ {
Host: "baz", Host: "baz",
Port: 5432, Port: 5432,
TLSConfig: nil, TLSConfig: nil,
@@ -520,12 +520,12 @@ func TestParseConfig(t *testing.T) {
TLSConfig: nil, TLSConfig: nil,
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "bar", Host: "bar",
Port: 2, Port: 2,
TLSConfig: nil, TLSConfig: nil,
}, },
&pgconn.FallbackConfig{ {
Host: "baz", Host: "baz",
Port: 3, Port: 3,
TLSConfig: nil, TLSConfig: nil,
@@ -548,31 +548,31 @@ func TestParseConfig(t *testing.T) {
}, },
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "foo", Host: "foo",
Port: defaultPort, Port: defaultPort,
TLSConfig: nil, TLSConfig: nil,
}, },
&pgconn.FallbackConfig{ {
Host: "bar", Host: "bar",
Port: defaultPort, Port: defaultPort,
TLSConfig: &tls.Config{ TLSConfig: &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
ServerName: "bar", ServerName: "bar",
}}, }},
&pgconn.FallbackConfig{ {
Host: "bar", Host: "bar",
Port: defaultPort, Port: defaultPort,
TLSConfig: nil, TLSConfig: nil,
}, },
&pgconn.FallbackConfig{ {
Host: "baz", Host: "baz",
Port: defaultPort, Port: defaultPort,
TLSConfig: &tls.Config{ TLSConfig: &tls.Config{
InsecureSkipVerify: true, InsecureSkipVerify: true,
ServerName: "baz", ServerName: "baz",
}}, }},
&pgconn.FallbackConfig{ {
Host: "baz", Host: "baz",
Port: defaultPort, Port: defaultPort,
TLSConfig: nil, TLSConfig: nil,
@@ -957,7 +957,7 @@ func TestParseConfigEnvLibpq(t *testing.T) {
}, },
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "123.123.123.123", Host: "123.123.123.123",
Port: 5432, Port: 5432,
TLSConfig: nil, TLSConfig: nil,
@@ -1101,7 +1101,7 @@ application_name = spaced string
}, },
RuntimeParams: map[string]string{}, RuntimeParams: map[string]string{},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "abc.example.com", Host: "abc.example.com",
Port: 9999, Port: 9999,
TLSConfig: nil, TLSConfig: nil,
@@ -1123,7 +1123,7 @@ application_name = spaced string
}, },
RuntimeParams: map[string]string{"application_name": "spaced string"}, RuntimeParams: map[string]string{"application_name": "spaced string"},
Fallbacks: []*pgconn.FallbackConfig{ Fallbacks: []*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "def.example.com", Host: "def.example.com",
Port: defaultPort, Port: defaultPort,
TLSConfig: nil, TLSConfig: nil,
+2 -2
View File
@@ -468,7 +468,7 @@ func TestConnectWithFallback(t *testing.T) {
// Prepend current primary config to fallbacks // Prepend current primary config to fallbacks
config.Fallbacks = append([]*pgconn.FallbackConfig{ config.Fallbacks = append([]*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: config.Host, Host: config.Host,
Port: config.Port, Port: config.Port,
TLSConfig: config.TLSConfig, TLSConfig: config.TLSConfig,
@@ -481,7 +481,7 @@ func TestConnectWithFallback(t *testing.T) {
// Prepend bad first fallback // Prepend bad first fallback
config.Fallbacks = append([]*pgconn.FallbackConfig{ config.Fallbacks = append([]*pgconn.FallbackConfig{
&pgconn.FallbackConfig{ {
Host: "localhost", Host: "localhost",
Port: 1, Port: 1,
TLSConfig: config.TLSConfig, TLSConfig: config.TLSConfig,
+4 -4
View File
@@ -233,11 +233,11 @@ func (b *Backend) Receive() (FrontendMessage, error) {
// contextual identification of FrontendMessages. For example, in the // contextual identification of FrontendMessages. For example, in the
// PG message flow documentation for PasswordMessage: // PG message flow documentation for PasswordMessage:
// //
// Byte1('p') // Byte1('p')
// //
// Identifies the message as a password response. Note that this is also used for // Identifies the message as a password response. Note that this is also used for
// GSSAPI, SSPI and SASL response messages. The exact message type can be deduced from // GSSAPI, SSPI and SASL response messages. The exact message type can be deduced from
// the context. // the context.
// //
// Since the Frontend does not know about the state of a backend, it is important // Since the Frontend does not know about the state of a backend, it is important
// to call SetAuthType() after an authentication request is received by the Frontend. // to call SetAuthType() after an authentication request is received by the Frontend.
+1 -1
View File
@@ -22,7 +22,7 @@ type TIDValuer interface {
// //
// When one does // When one does
// //
// select ctid, * from some_table; // select ctid, * from some_table;
// //
// it is the data type of the ctid hidden system column. // it is the data type of the ctid hidden system column.
// //
+32 -32
View File
@@ -2,58 +2,58 @@
// //
// A database/sql connection can be established through sql.Open. // A database/sql connection can be established through sql.Open.
// //
// db, err := sql.Open("pgx", "postgres://pgx_md5:secret@localhost:5432/pgx_test?sslmode=disable") // db, err := sql.Open("pgx", "postgres://pgx_md5:secret@localhost:5432/pgx_test?sslmode=disable")
// if err != nil { // if err != nil {
// return err // return err
// } // }
// //
// Or from a DSN string. // Or from a DSN string.
// //
// db, err := sql.Open("pgx", "user=postgres password=secret host=localhost port=5432 database=pgx_test sslmode=disable") // db, err := sql.Open("pgx", "user=postgres password=secret host=localhost port=5432 database=pgx_test sslmode=disable")
// if err != nil { // if err != nil {
// return err // return err
// } // }
// //
// Or a pgx.ConnConfig can be used to set configuration not accessible via connection string. In this case the // Or a pgx.ConnConfig can be used to set configuration not accessible via connection string. In this case the
// pgx.ConnConfig must first be registered with the driver. This registration returns a connection string which is used // pgx.ConnConfig must first be registered with the driver. This registration returns a connection string which is used
// with sql.Open. // with sql.Open.
// //
// connConfig, _ := pgx.ParseConfig(os.Getenv("DATABASE_URL")) // connConfig, _ := pgx.ParseConfig(os.Getenv("DATABASE_URL"))
// connConfig.Logger = myLogger // connConfig.Logger = myLogger
// connStr := stdlib.RegisterConnConfig(connConfig) // connStr := stdlib.RegisterConnConfig(connConfig)
// db, _ := sql.Open("pgx", connStr) // db, _ := sql.Open("pgx", connStr)
// //
// pgx uses standard PostgreSQL positional parameters in queries. e.g. $1, $2. It does not support named parameters. // pgx uses standard PostgreSQL positional parameters in queries. e.g. $1, $2. It does not support named parameters.
// //
// db.QueryRow("select * from users where id=$1", userID) // db.QueryRow("select * from users where id=$1", userID)
// //
// (*sql.Conn) Raw() can be used to get a *pgx.Conn from the standard database/sql.DB connection pool. This allows // (*sql.Conn) Raw() can be used to get a *pgx.Conn from the standard database/sql.DB connection pool. This allows
// operations that use pgx specific functionality. // operations that use pgx specific functionality.
// //
// // Given db is a *sql.DB // // Given db is a *sql.DB
// conn, err := db.Conn(context.Background()) // conn, err := db.Conn(context.Background())
// if err != nil { // if err != nil {
// // handle error from acquiring connection from DB pool // // handle error from acquiring connection from DB pool
// } // }
// //
// err = conn.Raw(func(driverConn any) error { // err = conn.Raw(func(driverConn any) error {
// conn := driverConn.(*stdlib.Conn).Conn() // conn is a *pgx.Conn // conn := driverConn.(*stdlib.Conn).Conn() // conn is a *pgx.Conn
// // Do pgx specific stuff with conn // // Do pgx specific stuff with conn
// conn.CopyFrom(...) // conn.CopyFrom(...)
// return nil // return nil
// }) // })
// if err != nil { // if err != nil {
// // handle error that occurred while using *pgx.Conn // // handle error that occurred while using *pgx.Conn
// } // }
// //
// PostgreSQL Specific Data Types // # PostgreSQL Specific Data Types
// //
// The pgtype package provides support for PostgreSQL specific types. *pgtype.Map.SQLScanner is an adapter that makes // The pgtype package provides support for PostgreSQL specific types. *pgtype.Map.SQLScanner is an adapter that makes
// these types usable as a sql.Scanner. // these types usable as a sql.Scanner.
// //
// m := pgtype.NewMap() // m := pgtype.NewMap()
// var a []int64 // var a []int64
// err := db.QueryRow("select '{1,2,3}'::bigint[]").Scan(m.SQLScanner(&a)) // err := db.QueryRow("select '{1,2,3}'::bigint[]").Scan(m.SQLScanner(&a))
package stdlib package stdlib
import ( import (
@@ -140,7 +140,7 @@ func RandomizeHostOrderFunc(ctx context.Context, connConfig *pgx.ConnConfig) err
return nil return nil
} }
newFallbacks := append([]*pgconn.FallbackConfig{&pgconn.FallbackConfig{ newFallbacks := append([]*pgconn.FallbackConfig{{
Host: connConfig.Host, Host: connConfig.Host,
Port: connConfig.Port, Port: connConfig.Port,
TLSConfig: connConfig.TLSConfig, TLSConfig: connConfig.TLSConfig,
+3 -3
View File
@@ -1105,9 +1105,9 @@ func TestRandomizeHostOrderFunc(t *testing.T) {
// Test that at some point we connect to all 3 hosts // Test that at some point we connect to all 3 hosts
hostsNotSeenYet := map[string]struct{}{ hostsNotSeenYet := map[string]struct{}{
"host1": struct{}{}, "host1": {},
"host2": struct{}{}, "host2": {},
"host3": struct{}{}, "host3": {},
} }
// If we don't succeed within this many iterations, something is certainly wrong // If we don't succeed within this many iterations, something is certainly wrong