jsonextractionv0
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DROP TABLE queryConfigs;
|
||||
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE queryConfigs (
|
||||
id uuid primary key,
|
||||
queryId uuid not null,
|
||||
config jsonb not null,
|
||||
addedVersion int not null,
|
||||
removedVersion int,
|
||||
foreign key (queryId) references queries(id),
|
||||
unique (queryId, removedVersion)
|
||||
);
|
||||
@@ -0,0 +1,2 @@
|
||||
-- name: GetQueryConfig :one
|
||||
SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 and COALESCE(removedVersion, $2 - 1) < $2;
|
||||
@@ -11,6 +11,7 @@ require (
|
||||
github.com/lib/pq v1.10.9
|
||||
github.com/stretchr/testify v1.10.0
|
||||
github.com/testcontainers/testcontainers-go v0.34.0
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.33.0
|
||||
go.opentelemetry.io/otel/sdk v1.33.0
|
||||
google.golang.org/grpc v1.68.1
|
||||
@@ -27,6 +28,8 @@ require (
|
||||
github.com/jackc/puddle/v2 v2.2.1 // indirect
|
||||
github.com/moby/sys/userns v0.1.0 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.33.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.19.0 // indirect
|
||||
|
||||
@@ -160,6 +160,12 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/testcontainers/testcontainers-go v0.34.0 h1:5fbgF0vIN5u+nD3IWabQwRybuB4GY8G2HHgCkbMzMHo=
|
||||
github.com/testcontainers/testcontainers-go v0.34.0/go.mod h1:6P/kMkQe8yqPHfPWNulFGdFHTD8HB2vLq/231xY2iPQ=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||
github.com/tklauser/go-sysconf v0.3.13 h1:GBUpcahXSpR2xN01jhkNAbTLRk2Yzgggk8IM08lq3r4=
|
||||
github.com/tklauser/go-sysconf v0.3.13/go.mod h1:zwleP4Q4OehZHGn4CYZDipCgg9usW5IJePewFCGVEa0=
|
||||
|
||||
@@ -98,6 +98,14 @@ type Query struct {
|
||||
Type Querytype
|
||||
}
|
||||
|
||||
type Queryconfig struct {
|
||||
ID pgtype.UUID
|
||||
Queryid pgtype.UUID
|
||||
Config []byte
|
||||
Addedversion int32
|
||||
Removedversion pgtype.Int4
|
||||
}
|
||||
|
||||
type Requiredquery struct {
|
||||
ID pgtype.UUID
|
||||
Queryid pgtype.UUID
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.27.0
|
||||
// source: query.sql
|
||||
|
||||
package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const getQueryConfig = `-- name: GetQueryConfig :one
|
||||
SELECT id, config FROM queryConfigs where queryId = $1 and addedVersion >= $2 and COALESCE(removedVersion, $2 - 1) < $2
|
||||
`
|
||||
|
||||
type GetQueryConfigParams struct {
|
||||
Queryid pgtype.UUID
|
||||
Addedversion int32
|
||||
}
|
||||
|
||||
type GetQueryConfigRow struct {
|
||||
ID pgtype.UUID
|
||||
Config []byte
|
||||
}
|
||||
|
||||
func (q *Queries) GetQueryConfig(ctx context.Context, arg GetQueryConfigParams) (GetQueryConfigRow, error) {
|
||||
row := q.db.QueryRow(ctx, getQueryConfig, arg.Queryid, arg.Addedversion)
|
||||
var i GetQueryConfigRow
|
||||
err := row.Scan(&i.ID, &i.Config)
|
||||
return i, err
|
||||
}
|
||||
@@ -1,9 +1,59 @@
|
||||
package jsonextractor
|
||||
|
||||
import "github.com/google/uuid"
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"gotemplate/internal/database"
|
||||
"gotemplate/internal/database/repository"
|
||||
"gotemplate/internal/result"
|
||||
|
||||
func Process(queryId uuid.UUID, queryVersion int32, jsonString string) (string, error) {
|
||||
// TODO - get full query information
|
||||
// TODO - process input
|
||||
return "", nil
|
||||
"github.com/google/uuid"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
type Extractor struct {
|
||||
db *repository.Queries
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Path string `json:"path"`
|
||||
}
|
||||
|
||||
func New(db *repository.Queries) *Extractor {
|
||||
return &Extractor{db}
|
||||
}
|
||||
|
||||
func (e *Extractor) Process(ctx context.Context, queryId uuid.UUID, queryVersion int32, values *[]result.Value) (string, error) {
|
||||
if len(*values) != 1 {
|
||||
return "", fmt.Errorf("JSON Extraction requires 1 result")
|
||||
}
|
||||
|
||||
value := (*values)[0].Value
|
||||
|
||||
byteConfig, err := e.db.GetQueryConfig(ctx, repository.GetQueryConfigParams{
|
||||
Queryid: database.MustToDBUUID(queryId),
|
||||
Addedversion: queryVersion,
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var config Config
|
||||
err = json.Unmarshal(byteConfig.Config, &config)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return e.extract(value, config.Path)
|
||||
}
|
||||
|
||||
func (e *Extractor) extract(jsonString string, path string) (string, error) {
|
||||
value := gjson.Get(jsonString, path)
|
||||
|
||||
if !value.Exists() {
|
||||
return "", fmt.Errorf("JSON path does not exist: %s", path)
|
||||
}
|
||||
|
||||
return value.String(), nil
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"gotemplate/internal/database"
|
||||
"gotemplate/internal/database/repository"
|
||||
"gotemplate/internal/result"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
@@ -57,9 +58,9 @@ func (q *Queue) executeQuery(ctx context.Context, query Query) error {
|
||||
return err
|
||||
}
|
||||
|
||||
cleanValues := make([]ResultValue, len(values))
|
||||
for _, result := range values {
|
||||
cleanValue := q.parseResultValue(result)
|
||||
cleanValues := make([]result.Value, len(values))
|
||||
for _, r := range values {
|
||||
cleanValue := result.ParseResultValue(r)
|
||||
cleanValues = append(cleanValues, cleanValue)
|
||||
}
|
||||
|
||||
@@ -71,16 +72,8 @@ func (q *Queue) executeQuery(ctx context.Context, query Query) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (q *Queue) parseResultValue(result repository.ListResultValuesByIDRow) ResultValue {
|
||||
return ResultValue{
|
||||
ID: database.MustToUUID(result.ID),
|
||||
QueryID: database.MustToUUID(result.Queryid),
|
||||
Value: result.Value,
|
||||
}
|
||||
}
|
||||
|
||||
func (q *Queue) getResult(ctx context.Context, query Query, resultValues *[]ResultValue) error {
|
||||
value, err := q.prepareResult(query, resultValues)
|
||||
func (q *Queue) getResult(ctx context.Context, query Query, resultValues *[]result.Value) error {
|
||||
value, err := q.prepareResult(ctx, query, resultValues)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
package query
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
jsonextractor "gotemplate/internal/jsonExtractor"
|
||||
"gotemplate/internal/queryProcessor"
|
||||
"gotemplate/internal/result"
|
||||
)
|
||||
|
||||
func (q *Queue) prepareResult(query Query, resultValues *[]ResultValue) (string, error) {
|
||||
switch query.Type {
|
||||
func (q *Queue) prepareResult(ctx context.Context, query Query, resultValues *[]result.Value) (string, error) {
|
||||
processor, err := q.getProcessor(query.Type)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return processor.Process(ctx, query.ID, query.Version, resultValues)
|
||||
}
|
||||
|
||||
func (q *Queue) getProcessor(queryType QueryType) (queryProcessor.Processor, error) {
|
||||
switch queryType {
|
||||
case QueryTypeJsonExtractor:
|
||||
return jsonextractor.Process(query.ID, query.Version, (*resultValues)[0].Value)
|
||||
return jsonextractor.New(q.db), nil
|
||||
default:
|
||||
return "", fmt.Errorf("attempting to process invalid query type")
|
||||
return nil, fmt.Errorf("attempting to process invalid query type")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,6 @@ type Result struct {
|
||||
QueryVersion int32
|
||||
}
|
||||
|
||||
type ResultValue struct {
|
||||
ID uuid.UUID
|
||||
QueryID uuid.UUID
|
||||
Value string
|
||||
}
|
||||
|
||||
type Queue struct {
|
||||
unsyncedQueue *[]Query
|
||||
collectorQueries *[]Query
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package queryProcessor
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gotemplate/internal/result"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Processor interface {
|
||||
Process(ctx context.Context, queryId uuid.UUID, queryVersion int32, values *[]result.Value) (string, error)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package result
|
||||
|
||||
import (
|
||||
"gotemplate/internal/database"
|
||||
"gotemplate/internal/database/repository"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type Value struct {
|
||||
ID uuid.UUID
|
||||
QueryID uuid.UUID
|
||||
Value string
|
||||
}
|
||||
|
||||
func ParseResultValue(result repository.ListResultValuesByIDRow) Value {
|
||||
return Value{
|
||||
ID: database.MustToUUID(result.ID),
|
||||
QueryID: database.MustToUUID(result.Queryid),
|
||||
Value: result.Value,
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,8 @@ func TestSync(t *testing.T) {
|
||||
Name: "document_name",
|
||||
}
|
||||
|
||||
dbCollectorId, err := database.ToDBUUID(uuid.New())
|
||||
assert.Nil(t, err)
|
||||
dbJobID, err := database.ToDBUUID(doc.JobID)
|
||||
assert.Nil(t, err)
|
||||
dbCollectorId := database.MustToDBUUID(uuid.New())
|
||||
dbJobID := database.MustToDBUUID(doc.JobID)
|
||||
minCleanVersion := int32(1)
|
||||
minTextVersion := int32(1)
|
||||
db.ExpectQuery("name: GetCollectorFromJobID :one").WithArgs(dbJobID).
|
||||
@@ -42,10 +40,8 @@ func TestSync(t *testing.T) {
|
||||
pgxmock.NewRows([]string{"id", "jobId", "minCleanVersion", "minTextVersion"}).
|
||||
AddRow(dbCollectorId, dbJobID, minCleanVersion, minTextVersion),
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
|
||||
dbDocID, err := database.ToDBUUID(doc.ID)
|
||||
assert.Nil(t, err)
|
||||
dbDocID := database.MustToDBUUID(doc.ID)
|
||||
db.ExpectQuery("name: ListResultsByDocumentID :many").WithArgs(dbDocID, minCleanVersion, minTextVersion).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "queryId", "queryVersion"}).
|
||||
@@ -58,6 +54,5 @@ func TestSync(t *testing.T) {
|
||||
)
|
||||
|
||||
err = docSvc.Sync(ctx, &doc)
|
||||
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
package document_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gotemplate/internal/database"
|
||||
"gotemplate/internal/database/repository"
|
||||
jsonextractor "gotemplate/internal/jsonExtractor"
|
||||
"gotemplate/internal/result"
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/pashagolub/pgxmock/v3"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestJSONProcess(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
db, err := pgxmock.NewConn()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pgxmock database: %v", err)
|
||||
}
|
||||
defer db.Close(ctx)
|
||||
|
||||
queries := repository.New(db)
|
||||
|
||||
extractor := jsonextractor.New(queries)
|
||||
|
||||
queryID := uuid.New()
|
||||
queryVersion := int32(1)
|
||||
entryValue := "value"
|
||||
|
||||
jsonString := fmt.Sprintf("{\"key\": \"%s\"}", entryValue)
|
||||
values := &[]result.Value{
|
||||
{ID: uuid.New(), QueryID: uuid.New(), Value: jsonString},
|
||||
}
|
||||
|
||||
config := "{\"path\":\"key\"}"
|
||||
|
||||
db.ExpectQuery("name: GetQueryConfig :one").WithArgs(database.MustToDBUUID(queryID), queryVersion).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "config"}).
|
||||
AddRow(pgtype.UUID{}, []byte(config)),
|
||||
)
|
||||
|
||||
value, err := extractor.Process(ctx, queryID, queryVersion, values)
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, entryValue, value)
|
||||
}
|
||||
|
||||
func TestJSONProcessJSON(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
db, err := pgxmock.NewConn()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pgxmock database: %v", err)
|
||||
}
|
||||
defer db.Close(ctx)
|
||||
|
||||
queries := repository.New(db)
|
||||
|
||||
extractor := jsonextractor.New(queries)
|
||||
|
||||
queryID := uuid.New()
|
||||
queryVersion := int32(1)
|
||||
entryValue := "value"
|
||||
|
||||
jsonString := fmt.Sprintf("{\"key\": \"%s\"}", entryValue)
|
||||
values := &[]result.Value{
|
||||
{ID: uuid.New(), QueryID: uuid.New(), Value: jsonString},
|
||||
}
|
||||
|
||||
config := "{\"path\":\"invalid_key\"}"
|
||||
|
||||
db.ExpectQuery("name: GetQueryConfig :one").WithArgs(database.MustToDBUUID(queryID), queryVersion).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "config"}).
|
||||
AddRow(pgtype.UUID{}, []byte(config)),
|
||||
)
|
||||
|
||||
value, err := extractor.Process(ctx, queryID, queryVersion, values)
|
||||
assert.EqualError(t, err, "JSON path does not exist: invalid_key")
|
||||
assert.Empty(t, value)
|
||||
|
||||
config = "{\"path\":\"\"}"
|
||||
|
||||
db.ExpectQuery("name: GetQueryConfig :one").WithArgs(database.MustToDBUUID(queryID), queryVersion).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "config"}).
|
||||
AddRow(pgtype.UUID{}, []byte(config)),
|
||||
)
|
||||
|
||||
value, err = extractor.Process(ctx, queryID, queryVersion, values)
|
||||
assert.EqualError(t, err, "JSON path does not exist: ")
|
||||
assert.Empty(t, value)
|
||||
|
||||
config = "{\"path\":}"
|
||||
|
||||
db.ExpectQuery("name: GetQueryConfig :one").WithArgs(database.MustToDBUUID(queryID), queryVersion).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "config"}).
|
||||
AddRow(pgtype.UUID{}, []byte(config)),
|
||||
)
|
||||
|
||||
value, err = extractor.Process(ctx, queryID, queryVersion, values)
|
||||
assert.EqualError(t, err, "invalid character '}' looking for beginning of value")
|
||||
assert.Empty(t, value)
|
||||
|
||||
config = "{\"path\":\"key\"}"
|
||||
|
||||
db.ExpectQuery("name: GetQueryConfig :one").WithArgs(database.MustToDBUUID(queryID), queryVersion).
|
||||
WillReturnRows(
|
||||
pgxmock.NewRows([]string{"id", "config"}),
|
||||
)
|
||||
|
||||
value, err = extractor.Process(ctx, queryID, queryVersion, values)
|
||||
assert.EqualError(t, err, "no rows in result set")
|
||||
assert.Empty(t, value)
|
||||
}
|
||||
|
||||
func TestJSONProcessResults(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
|
||||
db, err := pgxmock.NewConn()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to open pgxmock database: %v", err)
|
||||
}
|
||||
defer db.Close(ctx)
|
||||
|
||||
queries := repository.New(db)
|
||||
|
||||
extractor := jsonextractor.New(queries)
|
||||
|
||||
queryID := uuid.New()
|
||||
queryVersion := int32(1)
|
||||
|
||||
results := &[]result.Value{}
|
||||
value, err := extractor.Process(ctx, queryID, queryVersion, results)
|
||||
assert.EqualError(t, err, "JSON Extraction requires 1 result")
|
||||
assert.Empty(t, value)
|
||||
|
||||
results = &[]result.Value{
|
||||
{ID: uuid.New(), QueryID: uuid.New(), Value: ""},
|
||||
{ID: uuid.New(), QueryID: uuid.New(), Value: ""},
|
||||
}
|
||||
value, err = extractor.Process(ctx, queryID, queryVersion, results)
|
||||
assert.EqualError(t, err, "JSON Extraction requires 1 result")
|
||||
assert.Empty(t, value)
|
||||
|
||||
results = &[]result.Value{
|
||||
{ID: uuid.New(), QueryID: uuid.New(), Value: ""},
|
||||
{ID: uuid.New(), QueryID: uuid.New(), Value: ""},
|
||||
{ID: uuid.New(), QueryID: uuid.New(), Value: ""},
|
||||
}
|
||||
value, err = extractor.Process(ctx, queryID, queryVersion, results)
|
||||
assert.EqualError(t, err, "JSON Extraction requires 1 result")
|
||||
assert.Empty(t, value)
|
||||
}
|
||||
@@ -34,7 +34,6 @@ func TestQueue(t *testing.T) {
|
||||
pgxmock.NewRows([]string{"id", "jobId", "minCleanVersion", "minTextVersion"}).
|
||||
AddRow(dbCollectorID, dbJobID, int32(1), int32(1)),
|
||||
)
|
||||
assert.Nil(t, err)
|
||||
|
||||
coll, err := collector.NewByJobId(ctx, queries, jobID)
|
||||
assert.Nil(t, err)
|
||||
@@ -70,7 +69,6 @@ func TestQueue(t *testing.T) {
|
||||
}
|
||||
|
||||
db.ExpectQuery("name: GetCollectorQueries :many").WithArgs(dbCollectorID).WillReturnRows(rows)
|
||||
assert.Nil(t, err)
|
||||
|
||||
results := []query.Result{
|
||||
{ID: uuid.New(), QueryID: queryFourID, QueryVersion: queryFourVersion},
|
||||
@@ -95,31 +93,21 @@ func TestQueue(t *testing.T) {
|
||||
assert.Equal(t, expectedQueries, q.GetQueue())
|
||||
|
||||
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs([]pgtype.UUID{}).WillReturnRows(rows)
|
||||
assert.Nil(t, err)
|
||||
db.ExpectExec("name: SetResult :exec").WithArgs(pgxmock.AnyArg(), database.MustToDBUUID(querySixID), database.MustToDBUUID(docID), pgxmock.AnyArg(), cleanVersion, textVersion, querySixVersion).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
assert.Nil(t, err)
|
||||
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs(pgxmock.AnyArg()).WillReturnRows(rows)
|
||||
assert.Nil(t, err)
|
||||
db.ExpectExec("name: SetResult :exec").WithArgs(pgxmock.AnyArg(), database.MustToDBUUID(queryFiveID), database.MustToDBUUID(docID), pgxmock.AnyArg(), cleanVersion, textVersion, queryFiveVersion).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
assert.Nil(t, err)
|
||||
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs(pgxmock.AnyArg()).WillReturnRows(rows)
|
||||
assert.Nil(t, err)
|
||||
db.ExpectExec("name: SetResult :exec").WithArgs(pgxmock.AnyArg(), database.MustToDBUUID(queryThreeID), database.MustToDBUUID(docID), pgxmock.AnyArg(), cleanVersion, textVersion, queryThreeVersion).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
assert.Nil(t, err)
|
||||
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs(pgxmock.AnyArg()).WillReturnRows(rows)
|
||||
assert.Nil(t, err)
|
||||
db.ExpectExec("name: SetResult :exec").WithArgs(pgxmock.AnyArg(), database.MustToDBUUID(queryTwoID), database.MustToDBUUID(docID), pgxmock.AnyArg(), cleanVersion, textVersion, queryTwoVersion).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
assert.Nil(t, err)
|
||||
db.ExpectQuery("name: ListResultValuesByID :many").WithArgs(pgxmock.AnyArg()).WillReturnRows(rows)
|
||||
assert.Nil(t, err)
|
||||
db.ExpectExec("name: SetResult :exec").WithArgs(pgxmock.AnyArg(), database.MustToDBUUID(queryOneID), database.MustToDBUUID(docID), pgxmock.AnyArg(), cleanVersion, textVersion, queryOneVersion).
|
||||
WillReturnResult(pgxmock.NewResult("", 1))
|
||||
assert.Nil(t, err)
|
||||
|
||||
err = q.Execute(ctx)
|
||||
assert.Nil(t, err)
|
||||
assert.EqualError(t, err, "JSON Extraction requires 1 result")
|
||||
}
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package winterm
|
||||
|
||||
-1
@@ -63,7 +63,6 @@ type Marshaler interface {
|
||||
//
|
||||
// Both generic interface{} and concrete types are valid unmarshal destination types. When unmarshaling a document
|
||||
// into an empty interface the Unmarshaler will store one of these values:
|
||||
//
|
||||
// bool, for boolean values
|
||||
// document.Number, for arbitrary-precision numbers (int64, float64, big.Int, big.Float)
|
||||
// string, for string values
|
||||
|
||||
+5
-5
@@ -4,21 +4,21 @@ shape serializer function in which a xml.Value will be passed around.
|
||||
|
||||
Resources followed: https://smithy.io/2.0/spec/protocol-traits.html#xml-bindings
|
||||
|
||||
# Member Element
|
||||
Member Element
|
||||
|
||||
Member element should be used to encode xml shapes into xml elements except for flattened xml shapes. Member element
|
||||
write their own element start tag. These elements should always be closed.
|
||||
|
||||
# Flattened Element
|
||||
Flattened Element
|
||||
|
||||
Flattened element should be used to encode shapes marked with flattened trait into xml elements. Flattened element
|
||||
do not write a start tag, and thus should not be closed.
|
||||
|
||||
# Simple types encoding
|
||||
Simple types encoding
|
||||
|
||||
All simple type methods on value such as String(), Long() etc; auto close the associated member element.
|
||||
|
||||
# Array
|
||||
Array
|
||||
|
||||
Array returns the collection encoder. It has two modes, wrapped and flattened encoding.
|
||||
|
||||
@@ -32,7 +32,7 @@ If a shape is marked as flattened, Array() will use the shape element name as wr
|
||||
|
||||
<flattenedAarray>apple</flattenedArray><flattenedArray>tree</flattenedArray>
|
||||
|
||||
# Map
|
||||
Map
|
||||
|
||||
Map is the map encoder. It has two modes, wrapped and flattened encoding.
|
||||
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
// handler. A handler could be something like an HTTP Client that round trips an
|
||||
// API operation over HTTP.
|
||||
//
|
||||
// # Smithy Middleware Stack
|
||||
// Smithy Middleware Stack
|
||||
//
|
||||
// A Stack is a collection of middleware that wrap a handler. The stack can be
|
||||
// broken down into discreet steps. Each step may contain zero or more middleware
|
||||
@@ -48,7 +48,7 @@
|
||||
// the request message. Deserializes the response into a structured type or
|
||||
// error above stacks can react to.
|
||||
//
|
||||
// # Adding Middleware to a Stack Step
|
||||
// Adding Middleware to a Stack Step
|
||||
//
|
||||
// Middleware can be added to a step front or back, or relative, by name, to an
|
||||
// existing middleware in that stack. If a middleware does not have a name, a
|
||||
|
||||
-2
@@ -167,7 +167,6 @@ func (b *ExponentialBackOff) Reset() {
|
||||
}
|
||||
|
||||
// NextBackOff calculates the next backoff interval using the formula:
|
||||
//
|
||||
// Randomized interval = RetryInterval * (1 ± RandomizationFactor)
|
||||
func (b *ExponentialBackOff) NextBackOff() time.Duration {
|
||||
// Make sure we have not gone over the maximum elapsed time.
|
||||
@@ -201,7 +200,6 @@ func (b *ExponentialBackOff) incrementCurrentInterval() {
|
||||
}
|
||||
|
||||
// Returns a random value from the following interval:
|
||||
//
|
||||
// [currentInterval - randomizationFactor * currentInterval, currentInterval + randomizationFactor * currentInterval].
|
||||
func getRandomValueFromInterval(randomizationFactor, random float64, currentInterval time.Duration) time.Duration {
|
||||
if randomizationFactor == 0 {
|
||||
|
||||
-1
@@ -18,7 +18,6 @@
|
||||
// tag is deprecated and thus should not be used.
|
||||
// Go versions prior to 1.4 are disabled because they use a different layout
|
||||
// for interfaces which make the implementation of unsafeReflectValue more complex.
|
||||
//go:build !js && !appengine && !safe && !disableunsafe && go1.4
|
||||
// +build !js,!appengine,!safe,!disableunsafe,go1.4
|
||||
|
||||
package spew
|
||||
|
||||
-1
@@ -16,7 +16,6 @@
|
||||
// when the code is running on Google App Engine, compiled by GopherJS, or
|
||||
// "-tags safe" is added to the go build command line. The "disableunsafe"
|
||||
// tag is deprecated and thus should not be used.
|
||||
//go:build js || appengine || safe || disableunsafe || !go1.4
|
||||
// +build js appengine safe disableunsafe !go1.4
|
||||
|
||||
package spew
|
||||
|
||||
+5
-5
@@ -254,14 +254,14 @@ pointer addresses used to indirect to the final value. It provides the
|
||||
following features over the built-in printing facilities provided by the fmt
|
||||
package:
|
||||
|
||||
- Pointers are dereferenced and followed
|
||||
- Circular data structures are detected and handled properly
|
||||
- Custom Stringer/error interfaces are optionally invoked, including
|
||||
* Pointers are dereferenced and followed
|
||||
* Circular data structures are detected and handled properly
|
||||
* Custom Stringer/error interfaces are optionally invoked, including
|
||||
on unexported types
|
||||
- Custom types which only implement the Stringer/error interfaces via
|
||||
* Custom types which only implement the Stringer/error interfaces via
|
||||
a pointer receiver are optionally invoked when passing non-pointer
|
||||
variables
|
||||
- Byte arrays and slices are dumped like the hexdump -C command which
|
||||
* Byte arrays and slices are dumped like the hexdump -C command which
|
||||
includes offsets, byte values in hex, and ASCII output
|
||||
|
||||
The configuration options are controlled by modifying the public members
|
||||
|
||||
+24
-30
@@ -21,36 +21,35 @@ debugging.
|
||||
A quick overview of the additional features spew provides over the built-in
|
||||
printing facilities for Go data types are as follows:
|
||||
|
||||
- Pointers are dereferenced and followed
|
||||
- Circular data structures are detected and handled properly
|
||||
- Custom Stringer/error interfaces are optionally invoked, including
|
||||
* Pointers are dereferenced and followed
|
||||
* Circular data structures are detected and handled properly
|
||||
* Custom Stringer/error interfaces are optionally invoked, including
|
||||
on unexported types
|
||||
- Custom types which only implement the Stringer/error interfaces via
|
||||
* Custom types which only implement the Stringer/error interfaces via
|
||||
a pointer receiver are optionally invoked when passing non-pointer
|
||||
variables
|
||||
- Byte arrays and slices are dumped like the hexdump -C command which
|
||||
* Byte arrays and slices are dumped like the hexdump -C command which
|
||||
includes offsets, byte values in hex, and ASCII output (only when using
|
||||
Dump style)
|
||||
|
||||
There are two different approaches spew allows for dumping Go data structures:
|
||||
|
||||
- Dump style which prints with newlines, customizable indentation,
|
||||
* Dump style which prints with newlines, customizable indentation,
|
||||
and additional debug information such as types and all pointer addresses
|
||||
used to indirect to the final value
|
||||
- A custom Formatter interface that integrates cleanly with the standard fmt
|
||||
* A custom Formatter interface that integrates cleanly with the standard fmt
|
||||
package and replaces %v, %+v, %#v, and %#+v to provide inline printing
|
||||
similar to the default %v while providing the additional functionality
|
||||
outlined above and passing unsupported format verbs such as %x and %q
|
||||
along to fmt
|
||||
|
||||
# Quick Start
|
||||
Quick Start
|
||||
|
||||
This section demonstrates how to quickly get started with spew. See the
|
||||
sections below for further details on formatting and configuration options.
|
||||
|
||||
To dump a variable with full newlines, indentation, type, and pointer
|
||||
information use Dump, Fdump, or Sdump:
|
||||
|
||||
spew.Dump(myVar1, myVar2, ...)
|
||||
spew.Fdump(someWriter, myVar1, myVar2, ...)
|
||||
str := spew.Sdump(myVar1, myVar2, ...)
|
||||
@@ -59,13 +58,12 @@ Alternatively, if you would prefer to use format strings with a compacted inline
|
||||
printing style, use the convenience wrappers Printf, Fprintf, etc with
|
||||
%v (most compact), %+v (adds pointer addresses), %#v (adds types), or
|
||||
%#+v (adds types and pointer addresses):
|
||||
|
||||
spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2)
|
||||
spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
|
||||
spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2)
|
||||
spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4)
|
||||
|
||||
# Configuration Options
|
||||
Configuration Options
|
||||
|
||||
Configuration of spew is handled by fields in the ConfigState type. For
|
||||
convenience, all of the top-level functions use a global state available
|
||||
@@ -76,38 +74,37 @@ equivalent to the top-level functions. This allows concurrent configuration
|
||||
options. See the ConfigState documentation for more details.
|
||||
|
||||
The following configuration options are available:
|
||||
|
||||
- Indent
|
||||
* Indent
|
||||
String to use for each indentation level for Dump functions.
|
||||
It is a single space by default. A popular alternative is "\t".
|
||||
|
||||
- MaxDepth
|
||||
* MaxDepth
|
||||
Maximum number of levels to descend into nested data structures.
|
||||
There is no limit by default.
|
||||
|
||||
- DisableMethods
|
||||
* DisableMethods
|
||||
Disables invocation of error and Stringer interface methods.
|
||||
Method invocation is enabled by default.
|
||||
|
||||
- DisablePointerMethods
|
||||
* DisablePointerMethods
|
||||
Disables invocation of error and Stringer interface methods on types
|
||||
which only accept pointer receivers from non-pointer variables.
|
||||
Pointer method invocation is enabled by default.
|
||||
|
||||
- DisablePointerAddresses
|
||||
* DisablePointerAddresses
|
||||
DisablePointerAddresses specifies whether to disable the printing of
|
||||
pointer addresses. This is useful when diffing data structures in tests.
|
||||
|
||||
- DisableCapacities
|
||||
* DisableCapacities
|
||||
DisableCapacities specifies whether to disable the printing of
|
||||
capacities for arrays, slices, maps and channels. This is useful when
|
||||
diffing data structures in tests.
|
||||
|
||||
- ContinueOnMethod
|
||||
* ContinueOnMethod
|
||||
Enables recursion into types after invoking error and Stringer interface
|
||||
methods. Recursion after method invocation is disabled by default.
|
||||
|
||||
- SortKeys
|
||||
* SortKeys
|
||||
Specifies map keys should be sorted before being printed. Use
|
||||
this to have a more deterministic, diffable output. Note that
|
||||
only native types (bool, int, uint, floats, uintptr and string)
|
||||
@@ -116,12 +113,12 @@ The following configuration options are available:
|
||||
reflect.Value.String() output which guarantees display
|
||||
stability. Natural map order is used by default.
|
||||
|
||||
- SpewKeys
|
||||
* SpewKeys
|
||||
Specifies that, as a last resort attempt, map keys should be
|
||||
spewed to strings and sorted by those strings. This is only
|
||||
considered if SortKeys is true.
|
||||
|
||||
# Dump Usage
|
||||
Dump Usage
|
||||
|
||||
Simply call spew.Dump with a list of variables you want to dump:
|
||||
|
||||
@@ -136,7 +133,7 @@ A third option is to call spew.Sdump to get the formatted output as a string:
|
||||
|
||||
str := spew.Sdump(myVar1, myVar2, ...)
|
||||
|
||||
# Sample Dump Output
|
||||
Sample Dump Output
|
||||
|
||||
See the Dump example for details on the setup of the types and variables being
|
||||
shown here.
|
||||
@@ -153,14 +150,13 @@ shown here.
|
||||
|
||||
Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C
|
||||
command as shown.
|
||||
|
||||
([]uint8) (len=32 cap=32) {
|
||||
00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... |
|
||||
00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0|
|
||||
00000020 31 32 |12|
|
||||
}
|
||||
|
||||
# Custom Formatter
|
||||
Custom Formatter
|
||||
|
||||
Spew provides a custom formatter that implements the fmt.Formatter interface
|
||||
so that it integrates cleanly with standard fmt package printing functions. The
|
||||
@@ -174,7 +170,7 @@ standard fmt package for formatting. In addition, the custom formatter ignores
|
||||
the width and precision arguments (however they will still work on the format
|
||||
specifiers not handled by the custom formatter).
|
||||
|
||||
# Custom Formatter Usage
|
||||
Custom Formatter Usage
|
||||
|
||||
The simplest way to make use of the spew custom formatter is to call one of the
|
||||
convenience functions such as spew.Printf, spew.Println, or spew.Printf. The
|
||||
@@ -188,17 +184,15 @@ functions have syntax you are most likely already familiar with:
|
||||
|
||||
See the Index for the full list convenience functions.
|
||||
|
||||
# Sample Formatter Output
|
||||
Sample Formatter Output
|
||||
|
||||
Double pointer to a uint8:
|
||||
|
||||
%v: <**>5
|
||||
%+v: <**>(0xf8400420d0->0xf8400420c8)5
|
||||
%#v: (**uint8)5
|
||||
%#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5
|
||||
|
||||
Pointer to circular struct with a uint8 field and a pointer to itself:
|
||||
|
||||
%v: <*>{1 <*><shown>}
|
||||
%+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)<shown>}
|
||||
%#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)<shown>}
|
||||
@@ -207,7 +201,7 @@ Pointer to circular struct with a uint8 field and a pointer to itself:
|
||||
See the Printf example for details on the setup of variables being shown
|
||||
here.
|
||||
|
||||
# Errors
|
||||
Errors
|
||||
|
||||
Since it is possible for custom Stringer/error interfaces to panic, spew
|
||||
detects them and handles them internally by printing the panic information
|
||||
|
||||
+5
-5
@@ -488,14 +488,14 @@ pointer addresses used to indirect to the final value. It provides the
|
||||
following features over the built-in printing facilities provided by the fmt
|
||||
package:
|
||||
|
||||
- Pointers are dereferenced and followed
|
||||
- Circular data structures are detected and handled properly
|
||||
- Custom Stringer/error interfaces are optionally invoked, including
|
||||
* Pointers are dereferenced and followed
|
||||
* Circular data structures are detected and handled properly
|
||||
* Custom Stringer/error interfaces are optionally invoked, including
|
||||
on unexported types
|
||||
- Custom types which only implement the Stringer/error interfaces via
|
||||
* Custom types which only implement the Stringer/error interfaces via
|
||||
a pointer receiver are optionally invoked when passing non-pointer
|
||||
variables
|
||||
- Byte arrays and slices are dumped like the hexdump -C command which
|
||||
* Byte arrays and slices are dumped like the hexdump -C command which
|
||||
includes offsets, byte values in hex, and ASCII output
|
||||
|
||||
The configuration options are controlled by an exported package global,
|
||||
|
||||
-2
@@ -1,6 +1,4 @@
|
||||
//go:build go1.8
|
||||
// +build go1.8
|
||||
|
||||
// Code generated by "httpsnoop/codegen"; DO NOT EDIT.
|
||||
|
||||
package httpsnoop
|
||||
|
||||
-2
@@ -1,6 +1,4 @@
|
||||
//go:build !go1.8
|
||||
// +build !go1.8
|
||||
|
||||
// Code generated by "httpsnoop/codegen"; DO NOT EDIT.
|
||||
|
||||
package httpsnoop
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package oleutil
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package oleutil
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package oleutil
|
||||
|
||||
-1
@@ -1,7 +1,6 @@
|
||||
// This file is here so go get succeeds as without it errors with:
|
||||
// no buildable Go source files in ...
|
||||
//
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package oleutil
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
+1
-1
@@ -84,7 +84,7 @@ func (sac *SafeArrayConversion) ToValueArray() (values []interface{}) {
|
||||
safeArrayGetElement(sac.Array, i, unsafe.Pointer(&v))
|
||||
values[i] = v
|
||||
case VT_BSTR:
|
||||
v, _ := safeArrayGetElementString(sac.Array, i)
|
||||
v , _ := safeArrayGetElementString(sac.Array, i)
|
||||
values[i] = v
|
||||
case VT_VARIANT:
|
||||
var v VARIANT
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build 386
|
||||
// +build 386
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build amd64
|
||||
// +build amd64
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build arm
|
||||
// +build arm
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows && 386
|
||||
// +build windows,386
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows && amd64
|
||||
// +build windows,amd64
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows && arm
|
||||
// +build windows,arm
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build ppc64le
|
||||
// +build ppc64le
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build s390x
|
||||
// +build s390x
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !windows
|
||||
// +build !windows
|
||||
|
||||
package ole
|
||||
|
||||
-1
@@ -29,7 +29,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//go:build purego || appengine || js
|
||||
// +build purego appengine js
|
||||
|
||||
// This file contains an implementation of proto field accesses using package reflect.
|
||||
|
||||
-1
@@ -26,7 +26,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//go:build purego || appengine || js
|
||||
// +build purego appengine js
|
||||
|
||||
// This file contains an implementation of proto field accesses using package reflect.
|
||||
|
||||
-1
@@ -29,7 +29,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//go:build !purego && !appengine && !js
|
||||
// +build !purego,!appengine,!js
|
||||
|
||||
// This file contains the implementation of the proto field accesses using package unsafe.
|
||||
|
||||
-1
@@ -26,7 +26,6 @@
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
//go:build !purego && !appengine && !js
|
||||
// +build !purego,!appengine,!js
|
||||
|
||||
// This file contains the implementation of the proto field accesses using package unsafe.
|
||||
|
||||
-2
@@ -2004,14 +2004,12 @@ func makeUnmarshalMap(f *reflect.StructField) unmarshaler {
|
||||
|
||||
// makeUnmarshalOneof makes an unmarshaler for oneof fields.
|
||||
// for:
|
||||
//
|
||||
// message Msg {
|
||||
// oneof F {
|
||||
// int64 X = 1;
|
||||
// float64 Y = 2;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// typ is the type of the concrete entry for a oneof case (e.g. Msg_X).
|
||||
// ityp is the interface type of the oneof field (e.g. isMsg_F).
|
||||
// unmarshal is the unmarshaler for the base type of the oneof case (e.g. int64).
|
||||
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build js
|
||||
// +build js
|
||||
|
||||
package uuid
|
||||
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !js
|
||||
// +build !js
|
||||
|
||||
package uuid
|
||||
|
||||
+1
@@ -25,6 +25,7 @@ var jsonNull = []byte("null")
|
||||
// } else {
|
||||
// // NULL value
|
||||
// }
|
||||
//
|
||||
type NullUUID struct {
|
||||
UUID UUID
|
||||
Valid bool // Valid is true if UUID is not NULL
|
||||
|
||||
-2
@@ -187,12 +187,10 @@ func Must(uuid UUID, err error) UUID {
|
||||
}
|
||||
|
||||
// Validate returns an error if s is not a properly formatted UUID in one of the following formats:
|
||||
//
|
||||
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
// {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
|
||||
//
|
||||
// It returns an error if the format is invalid, otherwise nil.
|
||||
func Validate(s string) error {
|
||||
switch len(s) {
|
||||
|
||||
-1
@@ -19,7 +19,6 @@ var typeSQLScanner = reflect.TypeOf((*sql.Scanner)(nil)).Elem()
|
||||
// slice of any dimension.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
// db.Query(`SELECT * FROM t WHERE id = ANY($1)`, pq.Array([]int{235, 401}))
|
||||
//
|
||||
// var x []sql.NullInt64
|
||||
|
||||
+37
-24
@@ -27,7 +27,9 @@ You can also connect to a database using a URL. For example:
|
||||
connStr := "postgres://pqgotest:password@localhost/pqgotest?sslmode=verify-full"
|
||||
db, err := sql.Open("postgres", connStr)
|
||||
|
||||
# Connection String Parameters
|
||||
|
||||
Connection String Parameters
|
||||
|
||||
|
||||
Similarly to libpq, when establishing a connection using pq you are expected to
|
||||
supply a connection string containing zero or more parameters.
|
||||
@@ -40,29 +42,29 @@ them in the options parameter.
|
||||
For compatibility with libpq, the following special connection parameters are
|
||||
supported:
|
||||
|
||||
- dbname - The name of the database to connect to
|
||||
- user - The user to sign in as
|
||||
- password - The user's password
|
||||
- host - The host to connect to. Values that start with / are for unix
|
||||
* dbname - The name of the database to connect to
|
||||
* user - The user to sign in as
|
||||
* password - The user's password
|
||||
* host - The host to connect to. Values that start with / are for unix
|
||||
domain sockets. (default is localhost)
|
||||
- port - The port to bind to. (default is 5432)
|
||||
- sslmode - Whether or not to use SSL (default is require, this is not
|
||||
* port - The port to bind to. (default is 5432)
|
||||
* sslmode - Whether or not to use SSL (default is require, this is not
|
||||
the default for libpq)
|
||||
- fallback_application_name - An application_name to fall back to if one isn't provided.
|
||||
- connect_timeout - Maximum wait for connection, in seconds. Zero or
|
||||
* fallback_application_name - An application_name to fall back to if one isn't provided.
|
||||
* connect_timeout - Maximum wait for connection, in seconds. Zero or
|
||||
not specified means wait indefinitely.
|
||||
- sslcert - Cert file location. The file must contain PEM encoded data.
|
||||
- sslkey - Key file location. The file must contain PEM encoded data.
|
||||
- sslrootcert - The location of the root certificate file. The file
|
||||
* sslcert - Cert file location. The file must contain PEM encoded data.
|
||||
* sslkey - Key file location. The file must contain PEM encoded data.
|
||||
* sslrootcert - The location of the root certificate file. The file
|
||||
must contain PEM encoded data.
|
||||
|
||||
Valid values for sslmode are:
|
||||
|
||||
- disable - No SSL
|
||||
- require - Always SSL (skip verification)
|
||||
- verify-ca - Always SSL (verify that the certificate presented by the
|
||||
* disable - No SSL
|
||||
* require - Always SSL (skip verification)
|
||||
* verify-ca - Always SSL (verify that the certificate presented by the
|
||||
server was signed by a trusted CA)
|
||||
- verify-full - Always SSL (verify that the certification presented by
|
||||
* verify-full - Always SSL (verify that the certification presented by
|
||||
the server was signed by a trusted CA and the server host name
|
||||
matches the one in the certificate)
|
||||
|
||||
@@ -96,7 +98,9 @@ provided connection parameters.
|
||||
The pgpass mechanism as described in http://www.postgresql.org/docs/current/static/libpq-pgpass.html
|
||||
is supported, but on Windows PGPASSFILE must be specified explicitly.
|
||||
|
||||
# Queries
|
||||
|
||||
Queries
|
||||
|
||||
|
||||
database/sql does not dictate any specific format for parameter
|
||||
markers in query strings, and pq uses the Postgres-native ordinal markers,
|
||||
@@ -121,7 +125,9 @@ For more details on RETURNING, see the Postgres documentation:
|
||||
|
||||
For additional instructions on querying see the documentation for the database/sql package.
|
||||
|
||||
# Data Types
|
||||
|
||||
Data Types
|
||||
|
||||
|
||||
Parameters pass through driver.DefaultParameterConverter before they are handled
|
||||
by this package. When the binary_parameters connection option is enabled,
|
||||
@@ -139,7 +145,9 @@ This package returns the following types for values from the PostgreSQL backend:
|
||||
|
||||
All other types are returned directly from the backend as []byte values in text format.
|
||||
|
||||
# Errors
|
||||
|
||||
Errors
|
||||
|
||||
|
||||
pq may return errors of type *pq.Error which can be interrogated for error details:
|
||||
|
||||
@@ -149,7 +157,8 @@ pq may return errors of type *pq.Error which can be interrogated for error detai
|
||||
|
||||
See the pq.Error type for details.
|
||||
|
||||
# Bulk imports
|
||||
|
||||
Bulk imports
|
||||
|
||||
You can perform bulk imports by preparing a statement returned by pq.CopyIn (or
|
||||
pq.CopyInSchema) in an explicit transaction (sql.Tx). The returned statement
|
||||
@@ -197,7 +206,9 @@ Usage example:
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
# Notifications
|
||||
|
||||
Notifications
|
||||
|
||||
|
||||
PostgreSQL supports a simple publish/subscribe model over database
|
||||
connections. See http://www.postgresql.org/docs/current/static/sql-notify.html
|
||||
@@ -230,7 +241,9 @@ bytes by the PostgreSQL server.
|
||||
You can find a complete, working example of Listener usage at
|
||||
https://godoc.org/github.com/lib/pq/example/listen.
|
||||
|
||||
# Kerberos Support
|
||||
|
||||
Kerberos Support
|
||||
|
||||
|
||||
If you need support for Kerberos authentication, add the following to your main
|
||||
package:
|
||||
@@ -246,10 +259,10 @@ don't have to download unnecessary dependencies.
|
||||
|
||||
When imported, additional connection string parameters are supported:
|
||||
|
||||
- krbsrvname - GSS (Kerberos) service name when constructing the
|
||||
* krbsrvname - GSS (Kerberos) service name when constructing the
|
||||
SPN (default is `postgres`). This will be combined with the host
|
||||
to form the full SPN: `krbsrvname/host`.
|
||||
- krbspn - GSS (Kerberos) SPN. This takes priority over
|
||||
* krbspn - GSS (Kerberos) SPN. This takes priority over
|
||||
`krbsrvname` if present.
|
||||
*/
|
||||
package pq
|
||||
|
||||
+5
-5
@@ -330,10 +330,10 @@ func (l *ListenerConn) sendSimpleQuery(q string) (err error) {
|
||||
|
||||
// ExecSimpleQuery executes a "simple query" (i.e. one with no bindable
|
||||
// parameters) on the connection. The possible return values are:
|
||||
// 1. "executed" is true; the query was executed to completion on the
|
||||
// 1) "executed" is true; the query was executed to completion on the
|
||||
// database server. If the query failed, err will be set to the error
|
||||
// returned by the database, otherwise err will be nil.
|
||||
// 2. If "executed" is false, the query could not be executed on the remote
|
||||
// 2) If "executed" is false, the query could not be executed on the remote
|
||||
// server. err will be non-nil.
|
||||
//
|
||||
// After a call to ExecSimpleQuery has returned an executed=false value, the
|
||||
@@ -541,12 +541,12 @@ func (l *Listener) NotificationChannel() <-chan *Notification {
|
||||
// connection can not be re-established.
|
||||
//
|
||||
// Listen will only fail in three conditions:
|
||||
// 1. The channel is already open. The returned error will be
|
||||
// 1) The channel is already open. The returned error will be
|
||||
// ErrChannelAlreadyOpen.
|
||||
// 2. The query was executed on the remote server, but PostgreSQL returned an
|
||||
// 2) The query was executed on the remote server, but PostgreSQL returned an
|
||||
// error message in response to the query. The returned error will be a
|
||||
// pq.Error containing the information the server supplied.
|
||||
// 3. Close is called on the Listener before the request could be completed.
|
||||
// 3) Close is called on the Listener before the request could be completed.
|
||||
//
|
||||
// The channel name is case-sensitive.
|
||||
func (l *Listener) Listen(channel string) error {
|
||||
|
||||
+3
@@ -25,6 +25,7 @@
|
||||
// Package scram implements a SCRAM-{SHA-1,etc} client per RFC5802.
|
||||
//
|
||||
// http://tools.ietf.org/html/rfc5802
|
||||
//
|
||||
package scram
|
||||
|
||||
import (
|
||||
@@ -52,6 +53,7 @@ import (
|
||||
// if client.Err() != nil {
|
||||
// // auth failed
|
||||
// }
|
||||
//
|
||||
type Client struct {
|
||||
newHash func() hash.Hash
|
||||
|
||||
@@ -72,6 +74,7 @@ type Client struct {
|
||||
// For SCRAM-SHA-256, for example, use:
|
||||
//
|
||||
// client := scram.NewClient(sha256.New, user, pass)
|
||||
//
|
||||
func NewClient(newHash func() hash.Hash, user, pass string) *Client {
|
||||
c := &Client{
|
||||
newHash: newHash,
|
||||
|
||||
+4
-3
@@ -19,7 +19,7 @@
|
||||
// More importantly, it provides tools and wrappers to work with
|
||||
// hash.Hash-based digests with little effort.
|
||||
//
|
||||
// # Basics
|
||||
// Basics
|
||||
//
|
||||
// The format of a digest is simply a string with two parts, dubbed the
|
||||
// "algorithm" and the "digest", separated by a colon:
|
||||
@@ -42,7 +42,7 @@
|
||||
// obtained, comparisons are cheap, quick and simple to express with the
|
||||
// standard equality operator.
|
||||
//
|
||||
// # Verification
|
||||
// Verification
|
||||
//
|
||||
// The main benefit of using the Digest type is simple verification against a
|
||||
// given digest. The Verifier interface, modeled after the stdlib hash.Hash
|
||||
@@ -50,7 +50,7 @@
|
||||
// writing is complete, calling the Verifier.Verified method will indicate
|
||||
// whether or not the stream of bytes matches the target digest.
|
||||
//
|
||||
// # Missing Features
|
||||
// Missing Features
|
||||
//
|
||||
// In addition to the above, we intend to add the following features to this
|
||||
// package:
|
||||
@@ -58,4 +58,5 @@
|
||||
// 1. A Digester type that supports write sink digest calculation.
|
||||
//
|
||||
// 2. Suspend and resume of ongoing digest calculations to support efficient digest verification in the registry.
|
||||
//
|
||||
package digest
|
||||
|
||||
+1
@@ -20,3 +20,4 @@ type anyArgument struct{}
|
||||
func (a anyArgument) Match(_ interface{}) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -11,7 +11,7 @@
|
||||
// programmers to add context to the failure path in their code in a way
|
||||
// that does not destroy the original value of the error.
|
||||
//
|
||||
// # Adding context to an error
|
||||
// Adding context to an error
|
||||
//
|
||||
// The errors.Wrap function returns a new error that adds context to the
|
||||
// original error by recording a stack trace at the point Wrap is called,
|
||||
@@ -27,7 +27,7 @@
|
||||
// operations: annotating an error with a stack trace and with a message,
|
||||
// respectively.
|
||||
//
|
||||
// # Retrieving the cause of an error
|
||||
// Retrieving the cause of an error
|
||||
//
|
||||
// Using errors.Wrap constructs a stack of errors, adding context to the
|
||||
// preceding error. Depending on the nature of the error it may be necessary
|
||||
@@ -52,7 +52,7 @@
|
||||
// Although the causer interface is not exported by this package, it is
|
||||
// considered a part of its stable public interface.
|
||||
//
|
||||
// # Formatted printing of errors
|
||||
// Formatted printing of errors
|
||||
//
|
||||
// All error values returned from this package implement fmt.Formatter and can
|
||||
// be formatted by the fmt package. The following verbs are supported:
|
||||
@@ -63,7 +63,7 @@
|
||||
// %+v extended format. Each Frame of the error's StackTrace will
|
||||
// be printed in detail.
|
||||
//
|
||||
// # Retrieving the stack trace of an error or wrapper
|
||||
// Retrieving the stack trace of an error or wrapper
|
||||
//
|
||||
// New, Errorf, Wrap, and Wrapf record a stack trace at the point they are
|
||||
// invoked. This information can be retrieved with the following interface:
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build go1.13
|
||||
// +build go1.13
|
||||
|
||||
package errors
|
||||
|
||||
-3
@@ -199,12 +199,9 @@ func (m *SequenceMatcher) isBJunk(s string) bool {
|
||||
// If IsJunk is not defined:
|
||||
//
|
||||
// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where
|
||||
//
|
||||
// alo <= i <= i+k <= ahi
|
||||
// blo <= j <= j+k <= bhi
|
||||
//
|
||||
// and for all (i',j',k') meeting those conditions,
|
||||
//
|
||||
// k >= k'
|
||||
// i <= i'
|
||||
// and if i == i', j <= j'
|
||||
|
||||
+1
-1
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
Package logrus is a structured logger for Go, completely API compatible with the standard library logger.
|
||||
|
||||
|
||||
The simplest way to use Logrus is simply the package-level exported logger:
|
||||
|
||||
package main
|
||||
@@ -18,7 +19,6 @@ The simplest way to use Logrus is simply the package-level exported logger:
|
||||
}
|
||||
|
||||
Output:
|
||||
|
||||
time="2015-09-07T08:48:33Z" level=info msg="A walrus appears" animal=walrus number=1 size=10
|
||||
|
||||
For a full guide visit https://github.com/sirupsen/logrus
|
||||
|
||||
+3
-3
@@ -347,9 +347,9 @@ func (logger *Logger) Exit(code int) {
|
||||
logger.ExitFunc(code)
|
||||
}
|
||||
|
||||
// When file is opened with appending mode, it's safe to
|
||||
// write concurrently to a file (within 4k message on Linux).
|
||||
// In these cases user can choose to disable the lock.
|
||||
//When file is opened with appending mode, it's safe to
|
||||
//write concurrently to a file (within 4k message on Linux).
|
||||
//In these cases user can choose to disable the lock.
|
||||
func (logger *Logger) SetNoLock() {
|
||||
logger.mu.Disable()
|
||||
}
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build appengine
|
||||
// +build appengine
|
||||
|
||||
package logrus
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && !js
|
||||
// +build darwin dragonfly freebsd netbsd openbsd
|
||||
// +build !js
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build js
|
||||
// +build js
|
||||
|
||||
package logrus
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build js || nacl || plan9
|
||||
// +build js nacl plan9
|
||||
|
||||
package logrus
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !appengine && !js && !windows && !nacl && !plan9
|
||||
// +build !appengine,!js,!windows,!nacl,!plan9
|
||||
|
||||
package logrus
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build (linux || aix || zos) && !js
|
||||
// +build linux aix zos
|
||||
// +build !js
|
||||
|
||||
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
//go:build !appengine && !js && windows
|
||||
// +build !appengine,!js,windows
|
||||
|
||||
package logrus
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user