├── .github
├── FUNDING.yml
└── workflows
│ ├── codeql.yml
│ ├── dependency-review.yml
│ ├── go.yml
│ └── qodana_code_quality.yml
├── .gitignore
├── .idea
├── .gitignore
├── aws.xml
├── bullet-cloud-api.iml
├── inspectionProfiles
│ └── Project_Default.xml
├── modules.xml
└── vcs.xml
├── api.js
├── bullet.env
├── cmd
├── main.go
└── main_test.go
├── docker.yaml
├── dockerfile
├── go.mod
├── go.sum
├── internal
├── addresses
│ ├── repository.go
│ └── repository_mock.go
├── auth
│ ├── jwt.go
│ ├── middleware.go
│ └── password.go
├── cart
│ ├── repository.go
│ └── repository_mock.go
├── categories
│ ├── repository.go
│ └── repository_mock.go
├── config
│ └── config.go
├── database
│ ├── db.go
│ └── migrations
│ │ ├── 000001_create_users_table.down.sql
│ │ ├── 000001_create_users_table.up.sql
│ │ ├── 000002_create_products_table.down.sql
│ │ ├── 000002_create_products_table.up.sql
│ │ ├── 000003_create_categories_table.down.sql
│ │ ├── 000003_create_categories_table.up.sql
│ │ ├── 000004_create_addresses_table.down.sql
│ │ ├── 000004_create_addresses_table.up.sql
│ │ ├── 000005_create_cart_tables.down.sql
│ │ ├── 000005_create_cart_tables.up.sql
│ │ ├── 000006_create_order_tables.down.sql
│ │ ├── 000006_create_order_tables.up.sql
│ │ ├── 000007_add_rls_policies.down.sql
│ │ └── 000007_add_rls_policies.up.sql
├── handlers
│ ├── auth_handler.go
│ ├── auth_handler_test.go
│ ├── cart_handler.go
│ ├── cart_handler_test.go
│ ├── category_handler.go
│ ├── category_handler_test.go
│ ├── health_handler.go
│ ├── order_handler.go
│ ├── product_handler.go
│ ├── product_handler_test.go
│ ├── test_helpers_test.go
│ ├── user_handler.go
│ └── user_handler_test.go
├── models
│ ├── address.go
│ ├── cart.go
│ ├── cart_item.go
│ ├── category.go
│ ├── order.go
│ ├── order_item.go
│ ├── product.go
│ └── user.go
├── orders
│ └── repository.go
├── products
│ ├── repository.go
│ └── repository_mock.go
├── users
│ ├── repository.go
│ └── repository_mock.go
└── webutils
│ └── json_helpers.go
├── output
├── .swagger-codegen-ignore
├── .swagger-codegen
│ └── VERSION
├── README.md
└── swagger.yaml
├── public
├── demo.png
├── demo2.png
├── git-api.png
├── readme.md
└── teste2.jpeg
├── qodana.yaml
├── readme.md
├── render.yaml
├── swagger.yaml
└── vendor
├── github.com
├── davecgh
│ └── go-spew
│ │ ├── LICENSE
│ │ └── spew
│ │ ├── bypass.go
│ │ ├── bypasssafe.go
│ │ ├── common.go
│ │ ├── config.go
│ │ ├── doc.go
│ │ ├── dump.go
│ │ ├── format.go
│ │ └── spew.go
├── golang-jwt
│ └── jwt
│ │ └── v5
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── MIGRATION_GUIDE.md
│ │ ├── README.md
│ │ ├── SECURITY.md
│ │ ├── VERSION_HISTORY.md
│ │ ├── claims.go
│ │ ├── doc.go
│ │ ├── ecdsa.go
│ │ ├── ecdsa_utils.go
│ │ ├── ed25519.go
│ │ ├── ed25519_utils.go
│ │ ├── errors.go
│ │ ├── errors_go1_20.go
│ │ ├── errors_go_other.go
│ │ ├── hmac.go
│ │ ├── map_claims.go
│ │ ├── none.go
│ │ ├── parser.go
│ │ ├── parser_option.go
│ │ ├── registered_claims.go
│ │ ├── rsa.go
│ │ ├── rsa_pss.go
│ │ ├── rsa_utils.go
│ │ ├── signing_method.go
│ │ ├── staticcheck.conf
│ │ ├── token.go
│ │ ├── token_option.go
│ │ ├── types.go
│ │ └── validator.go
├── google
│ └── uuid
│ │ ├── CHANGELOG.md
│ │ ├── CONTRIBUTING.md
│ │ ├── CONTRIBUTORS
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── dce.go
│ │ ├── doc.go
│ │ ├── hash.go
│ │ ├── marshal.go
│ │ ├── node.go
│ │ ├── node_js.go
│ │ ├── node_net.go
│ │ ├── null.go
│ │ ├── sql.go
│ │ ├── time.go
│ │ ├── util.go
│ │ ├── uuid.go
│ │ ├── version1.go
│ │ ├── version4.go
│ │ ├── version6.go
│ │ └── version7.go
├── gorilla
│ └── mux
│ │ ├── .editorconfig
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── Makefile
│ │ ├── README.md
│ │ ├── doc.go
│ │ ├── middleware.go
│ │ ├── mux.go
│ │ ├── regexp.go
│ │ ├── route.go
│ │ └── test_helpers.go
├── jackc
│ ├── pgpassfile
│ │ ├── .travis.yml
│ │ ├── LICENSE
│ │ ├── README.md
│ │ └── pgpass.go
│ ├── pgservicefile
│ │ ├── LICENSE
│ │ ├── README.md
│ │ └── pgservicefile.go
│ ├── pgx
│ │ └── v5
│ │ │ ├── .gitignore
│ │ │ ├── CHANGELOG.md
│ │ │ ├── CONTRIBUTING.md
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── Rakefile
│ │ │ ├── batch.go
│ │ │ ├── conn.go
│ │ │ ├── copy_from.go
│ │ │ ├── derived_types.go
│ │ │ ├── doc.go
│ │ │ ├── extended_query_builder.go
│ │ │ ├── internal
│ │ │ ├── iobufpool
│ │ │ │ └── iobufpool.go
│ │ │ ├── pgio
│ │ │ │ ├── README.md
│ │ │ │ ├── doc.go
│ │ │ │ └── write.go
│ │ │ ├── sanitize
│ │ │ │ ├── benchmmark.sh
│ │ │ │ └── sanitize.go
│ │ │ └── stmtcache
│ │ │ │ ├── lru_cache.go
│ │ │ │ ├── stmtcache.go
│ │ │ │ └── unlimited_cache.go
│ │ │ ├── large_objects.go
│ │ │ ├── named_args.go
│ │ │ ├── pgconn
│ │ │ ├── README.md
│ │ │ ├── auth_scram.go
│ │ │ ├── config.go
│ │ │ ├── ctxwatch
│ │ │ │ └── context_watcher.go
│ │ │ ├── defaults.go
│ │ │ ├── defaults_windows.go
│ │ │ ├── doc.go
│ │ │ ├── errors.go
│ │ │ ├── internal
│ │ │ │ └── bgreader
│ │ │ │ │ └── bgreader.go
│ │ │ ├── krb5.go
│ │ │ └── pgconn.go
│ │ │ ├── pgproto3
│ │ │ ├── README.md
│ │ │ ├── authentication_cleartext_password.go
│ │ │ ├── authentication_gss.go
│ │ │ ├── authentication_gss_continue.go
│ │ │ ├── authentication_md5_password.go
│ │ │ ├── authentication_ok.go
│ │ │ ├── authentication_sasl.go
│ │ │ ├── authentication_sasl_continue.go
│ │ │ ├── authentication_sasl_final.go
│ │ │ ├── backend.go
│ │ │ ├── backend_key_data.go
│ │ │ ├── big_endian.go
│ │ │ ├── bind.go
│ │ │ ├── bind_complete.go
│ │ │ ├── cancel_request.go
│ │ │ ├── chunkreader.go
│ │ │ ├── close.go
│ │ │ ├── close_complete.go
│ │ │ ├── command_complete.go
│ │ │ ├── copy_both_response.go
│ │ │ ├── copy_data.go
│ │ │ ├── copy_done.go
│ │ │ ├── copy_fail.go
│ │ │ ├── copy_in_response.go
│ │ │ ├── copy_out_response.go
│ │ │ ├── data_row.go
│ │ │ ├── describe.go
│ │ │ ├── doc.go
│ │ │ ├── empty_query_response.go
│ │ │ ├── error_response.go
│ │ │ ├── execute.go
│ │ │ ├── flush.go
│ │ │ ├── frontend.go
│ │ │ ├── function_call.go
│ │ │ ├── function_call_response.go
│ │ │ ├── gss_enc_request.go
│ │ │ ├── gss_response.go
│ │ │ ├── no_data.go
│ │ │ ├── notice_response.go
│ │ │ ├── notification_response.go
│ │ │ ├── parameter_description.go
│ │ │ ├── parameter_status.go
│ │ │ ├── parse.go
│ │ │ ├── parse_complete.go
│ │ │ ├── password_message.go
│ │ │ ├── pgproto3.go
│ │ │ ├── portal_suspended.go
│ │ │ ├── query.go
│ │ │ ├── ready_for_query.go
│ │ │ ├── row_description.go
│ │ │ ├── sasl_initial_response.go
│ │ │ ├── sasl_response.go
│ │ │ ├── ssl_request.go
│ │ │ ├── startup_message.go
│ │ │ ├── sync.go
│ │ │ ├── terminate.go
│ │ │ └── trace.go
│ │ │ ├── pgtype
│ │ │ ├── array.go
│ │ │ ├── array_codec.go
│ │ │ ├── bits.go
│ │ │ ├── bool.go
│ │ │ ├── box.go
│ │ │ ├── builtin_wrappers.go
│ │ │ ├── bytea.go
│ │ │ ├── circle.go
│ │ │ ├── composite.go
│ │ │ ├── convert.go
│ │ │ ├── date.go
│ │ │ ├── doc.go
│ │ │ ├── enum_codec.go
│ │ │ ├── float4.go
│ │ │ ├── float8.go
│ │ │ ├── hstore.go
│ │ │ ├── inet.go
│ │ │ ├── int.go
│ │ │ ├── int.go.erb
│ │ │ ├── int_test.go.erb
│ │ │ ├── integration_benchmark_test.go.erb
│ │ │ ├── integration_benchmark_test_gen.sh
│ │ │ ├── interval.go
│ │ │ ├── json.go
│ │ │ ├── jsonb.go
│ │ │ ├── line.go
│ │ │ ├── lseg.go
│ │ │ ├── ltree.go
│ │ │ ├── macaddr.go
│ │ │ ├── multirange.go
│ │ │ ├── numeric.go
│ │ │ ├── path.go
│ │ │ ├── pgtype.go
│ │ │ ├── pgtype_default.go
│ │ │ ├── point.go
│ │ │ ├── polygon.go
│ │ │ ├── qchar.go
│ │ │ ├── range.go
│ │ │ ├── range_codec.go
│ │ │ ├── record_codec.go
│ │ │ ├── register_default_pg_types.go
│ │ │ ├── register_default_pg_types_disabled.go
│ │ │ ├── text.go
│ │ │ ├── text_format_only_codec.go
│ │ │ ├── tid.go
│ │ │ ├── time.go
│ │ │ ├── timestamp.go
│ │ │ ├── timestamptz.go
│ │ │ ├── uint32.go
│ │ │ ├── uint64.go
│ │ │ ├── uuid.go
│ │ │ └── xml.go
│ │ │ ├── pgxpool
│ │ │ ├── batch_results.go
│ │ │ ├── conn.go
│ │ │ ├── doc.go
│ │ │ ├── pool.go
│ │ │ ├── rows.go
│ │ │ ├── stat.go
│ │ │ ├── tracer.go
│ │ │ └── tx.go
│ │ │ ├── rows.go
│ │ │ ├── tracer.go
│ │ │ ├── tx.go
│ │ │ └── values.go
│ └── puddle
│ │ └── v2
│ │ ├── CHANGELOG.md
│ │ ├── LICENSE
│ │ ├── README.md
│ │ ├── context.go
│ │ ├── doc.go
│ │ ├── internal
│ │ └── genstack
│ │ │ ├── gen_stack.go
│ │ │ └── stack.go
│ │ ├── log.go
│ │ ├── nanotime.go
│ │ ├── pool.go
│ │ └── resource_list.go
├── joho
│ └── godotenv
│ │ ├── .gitignore
│ │ ├── LICENCE
│ │ ├── README.md
│ │ ├── godotenv.go
│ │ └── parser.go
├── pmezard
│ └── go-difflib
│ │ ├── LICENSE
│ │ └── difflib
│ │ └── difflib.go
└── stretchr
│ ├── objx
│ ├── .codeclimate.yml
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── Taskfile.yml
│ ├── accessors.go
│ ├── conversions.go
│ ├── doc.go
│ ├── map.go
│ ├── mutations.go
│ ├── security.go
│ ├── tests.go
│ ├── type_specific.go
│ ├── type_specific_codegen.go
│ └── value.go
│ └── testify
│ ├── LICENSE
│ ├── assert
│ ├── assertion_compare.go
│ ├── assertion_format.go
│ ├── assertion_format.go.tmpl
│ ├── assertion_forward.go
│ ├── assertion_forward.go.tmpl
│ ├── assertion_order.go
│ ├── assertions.go
│ ├── doc.go
│ ├── errors.go
│ ├── forward_assertions.go
│ ├── http_assertions.go
│ └── yaml
│ │ ├── yaml_custom.go
│ │ ├── yaml_default.go
│ │ └── yaml_fail.go
│ ├── mock
│ ├── doc.go
│ └── mock.go
│ └── require
│ ├── doc.go
│ ├── forward_requirements.go
│ ├── require.go
│ ├── require.go.tmpl
│ ├── require_forward.go
│ ├── require_forward.go.tmpl
│ └── requirements.go
├── golang.org
└── x
│ ├── crypto
│ ├── LICENSE
│ ├── PATENTS
│ ├── bcrypt
│ │ ├── base64.go
│ │ └── bcrypt.go
│ ├── blowfish
│ │ ├── block.go
│ │ ├── cipher.go
│ │ └── const.go
│ └── pbkdf2
│ │ └── pbkdf2.go
│ ├── sync
│ ├── LICENSE
│ ├── PATENTS
│ └── semaphore
│ │ └── semaphore.go
│ └── text
│ ├── LICENSE
│ ├── PATENTS
│ ├── cases
│ ├── cases.go
│ ├── context.go
│ ├── fold.go
│ ├── icu.go
│ ├── info.go
│ ├── map.go
│ ├── tables10.0.0.go
│ ├── tables11.0.0.go
│ ├── tables12.0.0.go
│ ├── tables13.0.0.go
│ ├── tables15.0.0.go
│ ├── tables9.0.0.go
│ └── trieval.go
│ ├── internal
│ ├── internal.go
│ ├── language
│ │ ├── common.go
│ │ ├── compact.go
│ │ ├── compact
│ │ │ ├── compact.go
│ │ │ ├── language.go
│ │ │ ├── parents.go
│ │ │ ├── tables.go
│ │ │ └── tags.go
│ │ ├── compose.go
│ │ ├── coverage.go
│ │ ├── language.go
│ │ ├── lookup.go
│ │ ├── match.go
│ │ ├── parse.go
│ │ ├── tables.go
│ │ └── tags.go
│ ├── match.go
│ └── tag
│ │ └── tag.go
│ ├── language
│ ├── coverage.go
│ ├── doc.go
│ ├── language.go
│ ├── match.go
│ ├── parse.go
│ ├── tables.go
│ └── tags.go
│ ├── runes
│ ├── cond.go
│ └── runes.go
│ ├── secure
│ ├── bidirule
│ │ ├── bidirule.go
│ │ ├── bidirule10.0.0.go
│ │ └── bidirule9.0.0.go
│ └── precis
│ │ ├── class.go
│ │ ├── context.go
│ │ ├── doc.go
│ │ ├── nickname.go
│ │ ├── options.go
│ │ ├── profile.go
│ │ ├── profiles.go
│ │ ├── tables10.0.0.go
│ │ ├── tables11.0.0.go
│ │ ├── tables12.0.0.go
│ │ ├── tables13.0.0.go
│ │ ├── tables15.0.0.go
│ │ ├── tables9.0.0.go
│ │ ├── transformer.go
│ │ └── trieval.go
│ ├── transform
│ └── transform.go
│ ├── unicode
│ ├── bidi
│ │ ├── bidi.go
│ │ ├── bracket.go
│ │ ├── core.go
│ │ ├── prop.go
│ │ ├── tables10.0.0.go
│ │ ├── tables11.0.0.go
│ │ ├── tables12.0.0.go
│ │ ├── tables13.0.0.go
│ │ ├── tables15.0.0.go
│ │ ├── tables9.0.0.go
│ │ └── trieval.go
│ └── norm
│ │ ├── composition.go
│ │ ├── forminfo.go
│ │ ├── input.go
│ │ ├── iter.go
│ │ ├── normalize.go
│ │ ├── readwriter.go
│ │ ├── tables10.0.0.go
│ │ ├── tables11.0.0.go
│ │ ├── tables12.0.0.go
│ │ ├── tables13.0.0.go
│ │ ├── tables15.0.0.go
│ │ ├── tables9.0.0.go
│ │ ├── transform.go
│ │ └── trie.go
│ └── width
│ ├── kind_string.go
│ ├── tables10.0.0.go
│ ├── tables11.0.0.go
│ ├── tables12.0.0.go
│ ├── tables13.0.0.go
│ ├── tables15.0.0.go
│ ├── tables9.0.0.go
│ ├── transform.go
│ ├── trieval.go
│ └── width.go
├── gopkg.in
└── yaml.v3
│ ├── LICENSE
│ ├── NOTICE
│ ├── README.md
│ ├── apic.go
│ ├── decode.go
│ ├── emitterc.go
│ ├── encode.go
│ ├── parserc.go
│ ├── readerc.go
│ ├── resolve.go
│ ├── scannerc.go
│ ├── sorter.go
│ ├── writerc.go
│ ├── yaml.go
│ ├── yamlh.go
│ └── yamlprivateh.go
└── modules.txt
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/.github/workflows/dependency-review.yml:
--------------------------------------------------------------------------------
1 | # Dependency Review Action
2 | #
3 | # This Action will scan dependency manifest files that change as part of a Pull Request,
4 | # surfacing known-vulnerable versions of the packages declared or updated in the PR.
5 | # Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable
6 | # packages will be blocked from merging.
7 | #
8 | # Source repository: https://github.com/actions/dependency-review-action
9 | # Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement
10 | name: 'Dependency review'
11 | on:
12 | pull_request:
13 | branches: [ "main" ]
14 |
15 | # If using a dependency submission action in this workflow this permission will need to be set to:
16 | #
17 | # permissions:
18 | # contents: write
19 | #
20 | # https://docs.github.com/en/enterprise-cloud@latest/code-security/supply-chain-security/understanding-your-software-supply-chain/using-the-dependency-submission-api
21 | permissions:
22 | contents: read
23 | # Write permissions for pull-requests are required for using the `comment-summary-in-pr` option, comment out if you aren't using this option
24 | pull-requests: write
25 |
26 | jobs:
27 | dependency-review:
28 | runs-on: ubuntu-latest
29 | steps:
30 | - name: 'Checkout repository'
31 | uses: actions/checkout@v4
32 | - name: 'Dependency Review'
33 | uses: actions/dependency-review-action@v4
34 | # Commonly enabled options, see https://github.com/actions/dependency-review-action#configuration-options for all available options.
35 | with:
36 | comment-summary-in-pr: always
37 | # fail-on-severity: moderate
38 | # deny-licenses: GPL-1.0-or-later, LGPL-2.0-or-later
39 | # retry-on-snapshot-warnings: true
40 |
--------------------------------------------------------------------------------
/.github/workflows/go.yml:
--------------------------------------------------------------------------------
1 |
2 | name: Go
3 |
4 | on:
5 | push:
6 | branches: [ "main" ]
7 | pull_request:
8 | branches: [ "main" ]
9 |
10 | jobs:
11 |
12 | build:
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4.2.2
16 |
17 | - name: Set up Go
18 | uses: actions/setup-go@v5.1.0
19 | with:
20 | go-version: '1.23'
21 |
22 | - name: Build
23 | run: go build -v ./...
24 |
25 | - name: Test
26 | run: go test -v ./...
27 |
--------------------------------------------------------------------------------
/.github/workflows/qodana_code_quality.yml:
--------------------------------------------------------------------------------
1 | name: Qodana
2 | on:
3 | workflow_dispatch:
4 | pull_request:
5 | push:
6 | branches:
7 | - main
8 |
9 | jobs:
10 | qodana:
11 | runs-on: ubuntu-latest
12 | permissions:
13 | contents: write
14 | pull-requests: write
15 | checks: write
16 | steps:
17 | - uses: actions/checkout@v3
18 | with:
19 | ref: ${{ github.event.pull_request.head.sha }}
20 | fetch-depth: 0
21 | - name: 'Qodana Scan'
22 | uses: JetBrains/qodana-action@v2024.3
23 | env:
24 | QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Environment variables
2 | .env
3 |
4 | # Binaries for programs and plugins
5 | *.exe
6 | *.exe~
7 | *.dll
8 | *.so
9 | *.dylib
10 |
11 | # Test binary, built with `go test -c`
12 | *.test
13 |
14 | # Output of the go coverage tool, specifically when used with LiteIDE
15 | *.out
16 |
17 | # Dependency directories (remove the comment below to include it)
18 | # vendor/
19 |
20 | # Go workspace file
21 | go.work
22 |
23 | # Swagger codegen output
24 | /output/.swagger-codegen/
25 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 | # Datasource local storage ignored files
7 | /dataSources/
8 | /dataSources.local.xml
9 |
--------------------------------------------------------------------------------
/.idea/aws.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/bullet-cloud-api.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/api.js:
--------------------------------------------------------------------------------
1 | const API_URL = 'https://bullet-cloud-api.onrender.com'; //url do app, temporario
2 |
3 | export const productService = {
4 | async getProducts() {
5 | const response = await fetch(`${API_URL}/products`);
6 | return response.json();
7 | },
8 |
9 | async createProduct(product) {
10 | const response = await fetch(`${API_URL}/products`, {
11 | method: 'POST',
12 | headers: {
13 | 'Content-Type': 'application/json',
14 | },
15 | body: JSON.stringify(product),
16 | });
17 | return response.json();
18 | },
19 |
20 | async getProduct(id) {
21 | const response = await fetch(`${API_URL}/products/${id}`);
22 | return response.json();
23 | },
24 |
25 | async updateProduct(id, product) {
26 | const response = await fetch(`${API_URL}/products/${id}`, {
27 | method: 'PUT',
28 | headers: {
29 | 'Content-Type': 'application/json',
30 | },
31 | body: JSON.stringify(product),
32 | });
33 | return response.json();
34 | },
35 |
36 | async deleteProduct(id) {
37 | await fetch(`${API_URL}/products/${id}`, {
38 | method: 'DELETE',
39 | });
40 | },
41 | };
42 |
43 | // Exemplo de componente React so pra deixar de base
44 | import { useEffect, useState } from 'react';
45 |
46 | function ProductList() {
47 | const [products, setProducts] = useState([]);
48 |
49 | useEffect(() => {
50 | async function loadProducts() {
51 | const data = await productService.getProducts();
52 | setProducts(data);
53 | }
54 | loadProducts();
55 | }, []);
56 |
57 | return (
58 |
59 | {products.map(product => (
60 |
61 |
{product.name}
62 |
{product.description}
63 |
R$ {product.price}
64 |
65 | ))}
66 |
67 | );
68 | }
69 |
--------------------------------------------------------------------------------
/bullet.env:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "os"
5 | "strings"
6 | )
7 |
8 | type Config struct {
9 | Port string
10 | CorsOrigins []string
11 | DbURL string
12 | }
13 |
14 | func LoadConfig() Config {
15 | return Config{
16 | Port: os.Getenv("API_PORT"),
17 | CorsOrigins: strings.Split(os.Getenv("CORS_ORIGINS"), ","),
18 | DbURL: os.Getenv("DATABASE_URL"),
19 | }
20 | }
--------------------------------------------------------------------------------
/cmd/main_test.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import "testing"
4 |
5 | func Test_main(t *testing.T) {
6 | var tests []struct {
7 | name string
8 | }
9 | for _, tt := range tests {
10 | t.Run(tt.name, func(t *testing.T) {
11 | main()
12 | })
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/docker.yaml:
--------------------------------------------------------------------------------
1 |
2 | version: '3'
3 | services:
4 | api:
5 | build: .
6 | ports:
7 | - "4444:4444"
8 | environment:
9 | - API_PORT=4444
10 | - CORS_ORIGINS=
11 |
--------------------------------------------------------------------------------
/dockerfile:
--------------------------------------------------------------------------------
1 | FROM golang:1.24-rc-alpine3.21
2 |
3 | WORKDIR /app
4 | COPY . .
5 | RUN go mod download
6 | RUN go build -o main cmd/main.go
7 |
8 | EXPOSE 4444
9 | CMD ["./main"]
10 |
11 |
12 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module bullet-cloud-api
2 |
3 | go 1.23.0
4 |
5 | toolchain go1.24.1
6 |
7 | require github.com/gorilla/mux v1.8.1
8 |
9 | require (
10 | github.com/davecgh/go-spew v1.1.1 // indirect
11 | github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
12 | github.com/google/uuid v1.6.0 // indirect
13 | github.com/jackc/pgpassfile v1.0.0 // indirect
14 | github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
15 | github.com/jackc/pgx/v5 v5.7.4 // indirect
16 | github.com/jackc/puddle/v2 v2.2.2 // indirect
17 | github.com/joho/godotenv v1.5.1 // indirect
18 | github.com/pmezard/go-difflib v1.0.0 // indirect
19 | github.com/stretchr/objx v0.5.2 // indirect
20 | github.com/stretchr/testify v1.10.0 // indirect
21 | golang.org/x/crypto v0.37.0 // indirect
22 | golang.org/x/sync v0.13.0 // indirect
23 | golang.org/x/text v0.24.0 // indirect
24 | gopkg.in/yaml.v3 v3.0.1 // indirect
25 | )
26 |
--------------------------------------------------------------------------------
/internal/auth/jwt.go:
--------------------------------------------------------------------------------
1 | package auth
2 |
3 | import (
4 | "errors"
5 | "time"
6 |
7 | "github.com/golang-jwt/jwt/v5"
8 | "github.com/google/uuid"
9 | )
10 |
11 | var (
12 | ErrInvalidToken = errors.New("invalid or expired token")
13 | )
14 |
15 | // Claims defines the structure of the JWT claims.
16 | type Claims struct {
17 | UserID uuid.UUID `json:"user_id"`
18 | jwt.RegisteredClaims
19 | }
20 |
21 | // GenerateToken creates a new JWT for a given user ID and secret.
22 | func GenerateToken(userID uuid.UUID, jwtSecret string, expiryDuration time.Duration) (string, error) {
23 | // Define expiration time
24 | expirationTime := time.Now().Add(expiryDuration)
25 |
26 | // Create the claims
27 | claims := &Claims{
28 | UserID: userID,
29 | RegisteredClaims: jwt.RegisteredClaims{
30 | ExpiresAt: jwt.NewNumericDate(expirationTime),
31 | IssuedAt: jwt.NewNumericDate(time.Now()),
32 | Issuer: "bullet-cloud-api", // Optional: identify the issuer
33 | },
34 | }
35 |
36 | // Create the token using HS256 signing method and the claims
37 | token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
38 |
39 | // Sign the token with the secret
40 | tokenString, err := token.SignedString([]byte(jwtSecret))
41 | if err != nil {
42 | return "", err
43 | }
44 |
45 | return tokenString, nil
46 | }
47 |
48 | // ValidateToken parses and validates a JWT string, returning the claims if valid.
49 | func ValidateToken(tokenString string, jwtSecret string) (*Claims, error) {
50 | claims := &Claims{}
51 |
52 | token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) {
53 | // Check the signing method
54 | if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
55 | return nil, errors.New("unexpected signing method")
56 | }
57 | return []byte(jwtSecret), nil
58 | })
59 |
60 | if err != nil {
61 | if errors.Is(err, jwt.ErrTokenExpired) || errors.Is(err, jwt.ErrTokenNotValidYet) || errors.Is(err, jwt.ErrSignatureInvalid) {
62 | return nil, ErrInvalidToken
63 | }
64 | return nil, err // Other parsing errors
65 | }
66 |
67 | if !token.Valid {
68 | return nil, ErrInvalidToken
69 | }
70 |
71 | return claims, nil
72 | }
73 |
--------------------------------------------------------------------------------
/internal/auth/password.go:
--------------------------------------------------------------------------------
1 | package auth
2 |
3 | import (
4 | "golang.org/x/crypto/bcrypt"
5 | )
6 |
7 | // PasswordHasher defines the interface for hashing and verifying passwords.
8 | type PasswordHasher interface {
9 | HashPassword(password string) (string, error)
10 | CheckPassword(hashedPassword, password string) error
11 | }
12 |
13 | // BcryptPasswordHasher implements PasswordHasher using bcrypt.
14 | type BcryptPasswordHasher struct{}
15 |
16 | // NewBcryptPasswordHasher creates a new instance of BcryptPasswordHasher.
17 | func NewBcryptPasswordHasher() PasswordHasher {
18 | return &BcryptPasswordHasher{}
19 | }
20 |
21 | // HashPassword hashes the given password using bcrypt.
22 | func (h *BcryptPasswordHasher) HashPassword(password string) (string, error) {
23 | hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
24 | if err != nil {
25 | return "", err
26 | }
27 | return string(hashedPassword), nil
28 | }
29 |
30 | // CheckPassword compares a hashed password with a plaintext password.
31 | func (h *BcryptPasswordHasher) CheckPassword(hashedPassword, password string) error {
32 | return bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
33 | }
34 |
--------------------------------------------------------------------------------
/internal/config/config.go:
--------------------------------------------------------------------------------
1 | package config
2 |
3 | import (
4 | "log"
5 | "os"
6 |
7 | "github.com/joho/godotenv"
8 | )
9 |
10 | // Config holds application configuration.
11 | type Config struct {
12 | DatabaseURL string
13 | JWTSecret string
14 | }
15 |
16 | // Load loads configuration from environment variables.
17 | // It looks for a .env file first for local development.
18 | func Load() *Config {
19 | // Load .env file if it exists (useful for local development)
20 | err := godotenv.Load()
21 | if err != nil {
22 | // Don't fail if .env is not found, just log it
23 | log.Println("No .env file found, proceeding with environment variables")
24 | }
25 |
26 | dbURL := os.Getenv("DATABASE_URL")
27 | if dbURL == "" {
28 | // Fallback or default can be set here if needed, but for Supabase it's required
29 | log.Fatal("DATABASE_URL environment variable not set")
30 | }
31 |
32 | // Carregar o segredo JWT
33 | jwtSecret := os.Getenv("JWT_SECRET")
34 | if jwtSecret == "" {
35 | log.Fatal("JWT_SECRET environment variable not set")
36 | }
37 |
38 | return &Config{
39 | DatabaseURL: dbURL,
40 | JWTSecret: jwtSecret,
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/internal/database/db.go:
--------------------------------------------------------------------------------
1 | package database
2 |
3 | import (
4 | "context"
5 | "log"
6 | "time"
7 |
8 | "github.com/jackc/pgx/v5/pgxpool"
9 | )
10 |
11 | // NewConnection establishes a connection pool to the PostgreSQL database.
12 | func NewConnection(databaseURL string) (*pgxpool.Pool, error) {
13 | // Parse the connection string
14 | config, err := pgxpool.ParseConfig(databaseURL)
15 | if err != nil {
16 | log.Printf("Unable to parse database config: %v\n", err)
17 | return nil, err
18 | }
19 |
20 | // Apply connection pool limits to reduce memory usage (important for low-RAM environments like Render Free)
21 | config.MaxConns = 4 // Hard cap on max simultaneous DB connections
22 | config.MinConns = 1 // Keep 1 connection alive to reduce cold starts
23 | config.MaxConnLifetime = 30 * time.Minute // Recycle connections after 30min
24 | config.MaxConnIdleTime = 5 * time.Minute // Close idle connections after 5min
25 |
26 | // Create a new connection pool
27 | pool, err := pgxpool.NewWithConfig(context.Background(), config)
28 | if err != nil {
29 | log.Printf("Unable to create connection pool: %v\n", err)
30 | return nil, err
31 | }
32 |
33 | // Ping the database to verify the connection
34 | err = pool.Ping(context.Background())
35 | if err != nil {
36 | log.Printf("Unable to ping database: %v\n", err)
37 | pool.Close()
38 | return nil, err
39 | }
40 |
41 | log.Println("Successfully connected to the database!")
42 | return pool, nil
43 | }
44 |
--------------------------------------------------------------------------------
/internal/database/migrations/000001_create_users_table.down.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Down
2 | -- SQL in this section is executed when the migration is rolled back.
3 |
4 | -- Drop the trigger first if it exists
5 | DROP TRIGGER IF EXISTS update_users_updated_at ON users;
6 |
7 | -- Drop the function if it exists
8 | DROP FUNCTION IF EXISTS update_updated_at_column();
9 |
10 | -- Drop the index if it exists
11 | DROP INDEX IF EXISTS idx_users_email;
12 |
13 | -- Drop the table
14 | DROP TABLE IF EXISTS users;
15 |
16 | -- Optional: Drop the extension if it's no longer needed by other tables
17 | -- DROP EXTENSION IF EXISTS "uuid-ossp";
18 |
--------------------------------------------------------------------------------
/internal/database/migrations/000001_create_users_table.up.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Up
2 | -- SQL in this section is executed when the migration is applied.
3 |
4 | CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- Needed for uuid_generate_v4()
5 |
6 | CREATE TABLE IF NOT EXISTS users (
7 | id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
8 | name TEXT NOT NULL,
9 | email TEXT UNIQUE NOT NULL,
10 | password_hash TEXT NOT NULL,
11 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
12 | updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
13 | );
14 |
15 | -- Optional: Add an index on the email column for faster lookups
16 | CREATE INDEX IF NOT EXISTS idx_users_email ON users(email);
17 |
18 | -- Optional: Trigger to automatically update updated_at timestamp
19 | -- First, create the function
20 | CREATE OR REPLACE FUNCTION update_updated_at_column()
21 | RETURNS TRIGGER AS $$
22 | BEGIN
23 | NEW.updated_at = NOW();
24 | RETURN NEW;
25 | END;
26 | $$ language 'plpgsql';
27 |
28 | -- Then, create the trigger
29 | CREATE TRIGGER update_users_updated_at
30 | BEFORE UPDATE ON users
31 | FOR EACH ROW
32 | EXECUTE FUNCTION update_updated_at_column();
33 |
34 |
35 | -- +migrate Down
36 | -- SQL section moved to the .down.sql file
37 |
--------------------------------------------------------------------------------
/internal/database/migrations/000002_create_products_table.down.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Down
2 | -- SQL in this section is executed when the migration is rolled back.
3 |
4 | -- Drop the trigger first if it exists
5 | DROP TRIGGER IF EXISTS update_products_updated_at ON products;
6 |
7 | -- Drop indices if they exist
8 | DROP INDEX IF EXISTS idx_products_name;
9 | -- DROP INDEX IF EXISTS idx_products_category_id;
10 |
11 | -- Drop the table
12 | DROP TABLE IF EXISTS products;
13 |
--------------------------------------------------------------------------------
/internal/database/migrations/000002_create_products_table.up.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Up
2 | -- SQL in this section is executed when the migration is applied.
3 |
4 | CREATE TABLE IF NOT EXISTS products (
5 | id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
6 | name TEXT NOT NULL,
7 | description TEXT,
8 | -- Use NUMERIC for monetary values, e.g., NUMERIC(precision, scale)
9 | price NUMERIC(10, 2) NOT NULL CHECK (price >= 0),
10 | category_id UUID NULL, -- Initially nullable, FK constraint added later
11 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
12 | updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
13 | -- FOREIGN KEY (category_id) REFERENCES categories(id) ON DELETE SET NULL -- Add later when categories table exists
14 | );
15 |
16 | -- Optional: Add indices for frequently queried columns
17 | CREATE INDEX IF NOT EXISTS idx_products_name ON products(name);
18 | -- CREATE INDEX IF NOT EXISTS idx_products_category_id ON products(category_id); -- Add later
19 |
20 | -- Trigger to automatically update updated_at timestamp
21 | -- Assumes the function update_updated_at_column() was created in migration 000001
22 | CREATE TRIGGER update_products_updated_at
23 | BEFORE UPDATE ON products
24 | FOR EACH ROW
25 | EXECUTE FUNCTION update_updated_at_column();
26 |
27 |
28 | -- +migrate Down
29 | -- SQL section moved to the .down.sql file
30 |
--------------------------------------------------------------------------------
/internal/database/migrations/000003_create_categories_table.down.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Down
2 | -- SQL in this section is executed when the migration is rolled back.
3 |
4 | -- Drop the foreign key index on products first
5 | DROP INDEX IF EXISTS idx_products_category_id;
6 |
7 | -- Drop the foreign key constraint from the products table
8 | ALTER TABLE products
9 | DROP CONSTRAINT IF EXISTS fk_products_category;
10 |
11 | -- Drop the trigger on categories
12 | DROP TRIGGER IF EXISTS update_categories_updated_at ON categories;
13 |
14 | -- Drop the index on categories name
15 | DROP INDEX IF EXISTS idx_categories_name;
16 |
17 | -- Drop the categories table
18 | DROP TABLE IF EXISTS categories;
19 |
--------------------------------------------------------------------------------
/internal/database/migrations/000003_create_categories_table.up.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Up
2 | -- SQL in this section is executed when the migration is applied.
3 |
4 | -- Create the categories table
5 | CREATE TABLE IF NOT EXISTS categories (
6 | id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
7 | name TEXT UNIQUE NOT NULL,
8 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
9 | updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
10 | );
11 |
12 | -- Add index on name for faster lookups
13 | CREATE INDEX IF NOT EXISTS idx_categories_name ON categories(name);
14 |
15 | -- Trigger for updated_at on categories
16 | -- Assumes the function update_updated_at_column() exists from migration 000001
17 | CREATE TRIGGER update_categories_updated_at
18 | BEFORE UPDATE ON categories
19 | FOR EACH ROW
20 | EXECUTE FUNCTION update_updated_at_column();
21 |
22 | -- Add the foreign key constraint to the products table
23 | ALTER TABLE products
24 | ADD CONSTRAINT fk_products_category
25 | FOREIGN KEY (category_id) REFERENCES categories(id)
26 | ON DELETE SET NULL;
27 |
28 | -- Optional: Add an index on the foreign key column in products for performance
29 | CREATE INDEX IF NOT EXISTS idx_products_category_id ON products(category_id);
30 |
31 |
32 | -- +migrate Down
33 | -- SQL section moved to the .down.sql file
34 |
--------------------------------------------------------------------------------
/internal/database/migrations/000004_create_addresses_table.down.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Down
2 | -- SQL in this section is executed when the migration is rolled back.
3 |
4 | -- Drop the trigger first
5 | DROP TRIGGER IF EXISTS update_addresses_updated_at ON addresses;
6 |
7 | -- Drop the index on user_id
8 | DROP INDEX IF EXISTS idx_addresses_user_id;
9 |
10 | -- Drop the partial unique index if it was created
11 | -- DROP INDEX IF EXISTS idx_addresses_user_default;
12 |
13 | -- Drop the addresses table (FK constraint is dropped automatically with the table)
14 | DROP TABLE IF EXISTS addresses;
15 |
--------------------------------------------------------------------------------
/internal/database/migrations/000004_create_addresses_table.up.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Up
2 | -- SQL in this section is executed when the migration is applied.
3 |
4 | CREATE TABLE IF NOT EXISTS addresses (
5 | id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
6 | user_id UUID NOT NULL,
7 | street TEXT NOT NULL,
8 | city TEXT NOT NULL,
9 | state TEXT NOT NULL,
10 | postal_code TEXT NOT NULL,
11 | country TEXT NOT NULL,
12 | is_default BOOLEAN NOT NULL DEFAULT false,
13 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
14 | updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
15 |
16 | CONSTRAINT fk_addresses_user
17 | FOREIGN KEY(user_id) REFERENCES users(id)
18 | ON DELETE CASCADE -- Delete addresses if the user is deleted
19 | );
20 |
21 | -- Index on the foreign key for performance
22 | CREATE INDEX IF NOT EXISTS idx_addresses_user_id ON addresses(user_id);
23 |
24 | -- Optional: Ensure only one default address per user (more complex, might need a trigger or partial index)
25 | -- Example using a partial unique index (PostgreSQL specific):
26 | -- CREATE UNIQUE INDEX idx_addresses_user_default ON addresses(user_id) WHERE is_default;
27 |
28 | -- Trigger for updated_at on addresses
29 | -- Assumes the function update_updated_at_column() exists from migration 000001
30 | CREATE TRIGGER update_addresses_updated_at
31 | BEFORE UPDATE ON addresses
32 | FOR EACH ROW
33 | EXECUTE FUNCTION update_updated_at_column();
34 |
35 |
36 | -- +migrate Down
37 | -- SQL section moved to the .down.sql file
38 |
--------------------------------------------------------------------------------
/internal/database/migrations/000005_create_cart_tables.down.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Down
2 | -- SQL in this section is executed when the migration is rolled back.
3 |
4 | -- Drop trigger on cart_items
5 | DROP TRIGGER IF EXISTS update_cart_items_updated_at ON cart_items;
6 |
7 | -- Drop indices on cart_items
8 | DROP INDEX IF EXISTS idx_cart_items_product_id;
9 | DROP INDEX IF EXISTS idx_cart_items_cart_id;
10 |
11 | -- Drop the cart_items table (constraints/FKs are dropped with the table)
12 | DROP TABLE IF EXISTS cart_items;
13 |
14 | -- Drop trigger on carts
15 | DROP TRIGGER IF EXISTS update_carts_updated_at ON carts;
16 |
17 | -- Drop index on carts
18 | DROP INDEX IF EXISTS idx_carts_user_id;
19 |
20 | -- Drop the carts table
21 | DROP TABLE IF EXISTS carts;
22 |
--------------------------------------------------------------------------------
/internal/database/migrations/000006_create_order_tables.down.sql:
--------------------------------------------------------------------------------
1 | -- +migrate Down
2 | -- SQL in this section is executed when the migration is rolled back.
3 |
4 | -- Drop trigger on order_items
5 | DROP TRIGGER IF EXISTS update_order_items_updated_at ON order_items;
6 |
7 | -- Drop indices on order_items
8 | DROP INDEX IF EXISTS idx_order_items_product_id;
9 | DROP INDEX IF EXISTS idx_order_items_order_id;
10 |
11 | -- Drop the order_items table
12 | DROP TABLE IF EXISTS order_items;
13 |
14 | -- Drop trigger on orders
15 | DROP TRIGGER IF EXISTS update_orders_updated_at ON orders;
16 |
17 | -- Drop indices on orders
18 | DROP INDEX IF EXISTS idx_orders_status;
19 | DROP INDEX IF EXISTS idx_orders_user_id;
20 |
21 | -- Drop the orders table
22 | DROP TABLE IF EXISTS orders;
23 |
24 | -- Optional: Drop the ENUM type if it was created
25 | -- DROP TYPE IF EXISTS order_status;
26 |
--------------------------------------------------------------------------------
/internal/database/migrations/000007_add_rls_policies.down.sql:
--------------------------------------------------------------------------------
1 | -- Drop policies and disable RLS for 'categories'
2 | DROP POLICY IF EXISTS "Allow modification for authenticated users" ON categories;
3 | DROP POLICY IF EXISTS "Allow public select access" ON categories;
4 | ALTER TABLE categories DISABLE ROW LEVEL SECURITY;
5 |
6 | -- Drop policies and disable RLS for 'products'
7 | DROP POLICY IF EXISTS "Allow modification for authenticated users" ON products;
8 | DROP POLICY IF EXISTS "Allow public select access" ON products;
9 | ALTER TABLE products DISABLE ROW LEVEL SECURITY;
10 |
11 | -- Drop policies and disable RLS for 'order_items'
12 | DROP POLICY IF EXISTS "Allow select based on order owner" ON order_items;
13 | ALTER TABLE order_items DISABLE ROW LEVEL SECURITY;
14 |
15 | -- Drop policies and disable RLS for 'orders'
16 | DROP POLICY IF EXISTS "Allow insert for authenticated users" ON orders;
17 | DROP POLICY IF EXISTS "Allow select access to owner" ON orders;
18 | ALTER TABLE orders DISABLE ROW LEVEL SECURITY;
19 |
20 | -- Drop policies and disable RLS for 'cart_items'
21 | DROP POLICY IF EXISTS "Allow access based on cart owner" ON cart_items;
22 | ALTER TABLE cart_items DISABLE ROW LEVEL SECURITY;
23 |
24 | -- Drop policies and disable RLS for 'carts'
25 | DROP POLICY IF EXISTS "Allow full access to owner" ON carts;
26 | ALTER TABLE carts DISABLE ROW LEVEL SECURITY;
27 |
28 | -- Drop policies and disable RLS for 'addresses'
29 | DROP POLICY IF EXISTS "Allow full access to owner" ON addresses;
30 | ALTER TABLE addresses DISABLE ROW LEVEL SECURITY;
31 |
32 | -- Drop policies and disable RLS for 'users'
33 | DROP POLICY IF EXISTS "Allow individual update access" ON users;
34 | DROP POLICY IF EXISTS "Allow individual select access" ON users;
35 | ALTER TABLE users DISABLE ROW LEVEL SECURITY;
--------------------------------------------------------------------------------
/internal/handlers/health_handler.go:
--------------------------------------------------------------------------------
1 | package handlers
2 |
3 | import (
4 | "bullet-cloud-api/internal/webutils"
5 | "net/http"
6 | )
7 |
8 | // HealthCheck returns a simple status indicating the service is up.
9 | func HealthCheck(w http.ResponseWriter, r *http.Request) {
10 | // In the future, this could check DB connection, external services, etc.
11 | status := map[string]string{"status": "healthy"}
12 | webutils.WriteJSON(w, http.StatusOK, status)
13 | }
14 |
--------------------------------------------------------------------------------
/internal/models/address.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // Address represents a user's address.
10 | type Address struct {
11 | ID uuid.UUID `json:"id" db:"id"`
12 | UserID uuid.UUID `json:"user_id" db:"user_id"` // Foreign key to users table
13 | Street string `json:"street" db:"street"`
14 | City string `json:"city" db:"city"`
15 | State string `json:"state" db:"state"`
16 | PostalCode string `json:"postal_code" db:"postal_code"`
17 | Country string `json:"country" db:"country"`
18 | IsDefault bool `json:"is_default" db:"is_default"`
19 | CreatedAt time.Time `json:"created_at" db:"created_at"`
20 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
21 | }
22 |
--------------------------------------------------------------------------------
/internal/models/cart.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // Cart represents a user's shopping cart.
10 | type Cart struct {
11 | ID uuid.UUID `json:"id" db:"id"`
12 | UserID uuid.UUID `json:"user_id" db:"user_id"` // Foreign key to users table
13 | CreatedAt time.Time `json:"created_at" db:"created_at"`
14 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
15 | }
16 |
--------------------------------------------------------------------------------
/internal/models/cart_item.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // CartItem represents an item within a shopping cart.
10 | type CartItem struct {
11 | ID uuid.UUID `json:"id" db:"id"`
12 | CartID uuid.UUID `json:"cart_id" db:"cart_id"` // Foreign key to carts table
13 | ProductID uuid.UUID `json:"product_id" db:"product_id"` // Foreign key to products table
14 | Quantity int `json:"quantity" db:"quantity"` // Quantity of the product
15 | Price float64 `json:"price" db:"price"` // Price of the product at the time it was added
16 | CreatedAt time.Time `json:"created_at" db:"created_at"`
17 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
18 |
19 | // Optional: Include product details directly in the response (requires JOIN in repository)
20 | // ProductName string `json:"product_name,omitempty" db:"product_name"`
21 | // ProductDescription string `json:"product_description,omitempty" db:"product_description"`
22 | }
23 |
--------------------------------------------------------------------------------
/internal/models/category.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // Category represents a product category.
10 | type Category struct {
11 | ID uuid.UUID `json:"id" db:"id"`
12 | Name string `json:"name" db:"name"`
13 | CreatedAt time.Time `json:"created_at" db:"created_at"`
14 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
15 | }
16 |
--------------------------------------------------------------------------------
/internal/models/order.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // OrderStatus defines allowed statuses for an order.
10 | type OrderStatus string
11 |
12 | const (
13 | StatusPending OrderStatus = "pending" // Order received, awaiting processing/payment
14 | StatusProcessing OrderStatus = "processing" // Payment received, order being processed
15 | StatusShipped OrderStatus = "shipped" // Order shipped
16 | StatusDelivered OrderStatus = "delivered" // Order delivered
17 | StatusCancelled OrderStatus = "cancelled" // Order cancelled
18 | )
19 |
20 | // Order represents a customer order.
21 | type Order struct {
22 | ID uuid.UUID `json:"id" db:"id"`
23 | UserID uuid.UUID `json:"user_id" db:"user_id"` // FK to users
24 | ShippingAddressID uuid.UUID `json:"shipping_address_id" db:"shipping_address_id"` // FK to addresses
25 | Status OrderStatus `json:"status" db:"status"` // Current status of the order
26 | Total float64 `json:"total" db:"total"` // Total price of the order at creation
27 | TrackingNumber *string `json:"tracking_number,omitempty" db:"tracking_number"` // Optional tracking number
28 | CreatedAt time.Time `json:"created_at" db:"created_at"`
29 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
30 | }
31 |
--------------------------------------------------------------------------------
/internal/models/order_item.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // OrderItem represents an item within an order.
10 | type OrderItem struct {
11 | ID uuid.UUID `json:"id" db:"id"`
12 | OrderID uuid.UUID `json:"order_id" db:"order_id"` // Foreign key to orders table
13 | ProductID uuid.UUID `json:"product_id" db:"product_id"` // Foreign key to products table
14 | Quantity int `json:"quantity" db:"quantity"` // Quantity of the product ordered
15 | Price float64 `json:"price" db:"price"` // Price of the product at the time of order
16 | CreatedAt time.Time `json:"created_at" db:"created_at"`
17 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
18 |
19 | // Optional: Include product details in the response (requires JOIN)
20 | // ProductName string `json:"product_name,omitempty" db:"product_name"`
21 | }
22 |
--------------------------------------------------------------------------------
/internal/models/product.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // Product represents a product in the e-commerce system.
10 | type Product struct {
11 | ID uuid.UUID `json:"id" db:"id"`
12 | Name string `json:"name" db:"name"`
13 | Description string `json:"description" db:"description"`
14 | Price float64 `json:"price" db:"price"` // Use numeric/decimal type in DB for precision
15 | CategoryID *uuid.UUID `json:"category_id" db:"category_id"` // Pointer to allow null category initially
16 | CreatedAt time.Time `json:"created_at" db:"created_at"`
17 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
18 | }
19 |
--------------------------------------------------------------------------------
/internal/models/user.go:
--------------------------------------------------------------------------------
1 | package models
2 |
3 | import (
4 | "time"
5 |
6 | "github.com/google/uuid"
7 | )
8 |
9 | // User represents a user in the system.
10 | type User struct {
11 | ID uuid.UUID `json:"id" db:"id"`
12 | Name string `json:"name" db:"name"`
13 | Email string `json:"email" db:"email"`
14 | PasswordHash string `json:"-" db:"password_hash"` // Never expose password hash in JSON responses
15 | CreatedAt time.Time `json:"created_at" db:"created_at"`
16 | UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
17 | }
18 |
--------------------------------------------------------------------------------
/internal/webutils/json_helpers.go:
--------------------------------------------------------------------------------
1 | package webutils
2 |
3 | import (
4 | "encoding/json"
5 | "net/http"
6 | )
7 |
8 | // WriteJSON sends a JSON response with a specific status code.
9 | func WriteJSON(w http.ResponseWriter, status int, data interface{}) error {
10 | w.Header().Set("Content-Type", "application/json")
11 | w.WriteHeader(status)
12 | return json.NewEncoder(w).Encode(data)
13 | }
14 |
15 | // ReadJSON decodes JSON from a request body into a target struct.
16 | func ReadJSON(r *http.Request, target interface{}) error {
17 | // Limit request body size (e.g., 1MB) to prevent potential DoS
18 | // r.Body = http.MaxBytesReader(w, r.Body, 1048576)
19 | // Note: MaxBytesReader needs ResponseWriter, so maybe apply in middleware or handler
20 |
21 | defer r.Body.Close()
22 | return json.NewDecoder(r.Body).Decode(target)
23 | }
24 |
25 | // jsonError is used for standard JSON error responses.
26 | type jsonError struct {
27 | Error string `json:"error"`
28 | }
29 |
30 | // ErrorJSON sends a JSON error response.
31 | func ErrorJSON(w http.ResponseWriter, err error, status int) {
32 | WriteJSON(w, status, jsonError{Error: err.Error()})
33 | }
34 |
--------------------------------------------------------------------------------
/output/.swagger-codegen-ignore:
--------------------------------------------------------------------------------
1 | # Swagger Codegen Ignore
2 | # Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3 |
4 | # Use this file to prevent files from being overwritten by the generator.
5 | # The patterns follow closely to .gitignore or .dockerignore.
6 |
7 | # As an example, the C# client generator defines ApiClient.cs.
8 | # You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9 | #ApiClient.cs
10 |
11 | # You can match any string of characters against a directory, file or extension with a single asterisk (*):
12 | #foo/*/qux
13 | # The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14 |
15 | # You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16 | #foo/**/qux
17 | # This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18 |
19 | # You can also negate patterns with an exclamation (!).
20 | # For example, you can ignore all files in a docs folder with the file extension .md:
21 | #docs/*.md
22 | # Then explicitly reverse the ignore rule for a single file:
23 | #!docs/README.md
24 |
--------------------------------------------------------------------------------
/output/.swagger-codegen/VERSION:
--------------------------------------------------------------------------------
1 | 3.0.64
--------------------------------------------------------------------------------
/output/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bulletdev/bullet-cloud-api/85f6f497e0771a059ccafe56f6d2e749715726cd/output/README.md
--------------------------------------------------------------------------------
/public/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bulletdev/bullet-cloud-api/85f6f497e0771a059ccafe56f6d2e749715726cd/public/demo.png
--------------------------------------------------------------------------------
/public/demo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bulletdev/bullet-cloud-api/85f6f497e0771a059ccafe56f6d2e749715726cd/public/demo2.png
--------------------------------------------------------------------------------
/public/git-api.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bulletdev/bullet-cloud-api/85f6f497e0771a059ccafe56f6d2e749715726cd/public/git-api.png
--------------------------------------------------------------------------------
/public/readme.md:
--------------------------------------------------------------------------------
1 | utils & images
2 |
--------------------------------------------------------------------------------
/public/teste2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Bulletdev/bullet-cloud-api/85f6f497e0771a059ccafe56f6d2e749715726cd/public/teste2.jpeg
--------------------------------------------------------------------------------
/qodana.yaml:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------------------------------------#
2 | # Qodana analysis is configured by qodana.yaml file #
3 | # https://www.jetbrains.com/help/qodana/qodana-yaml.html #
4 | #-------------------------------------------------------------------------------#
5 | version: "1.0"
6 |
7 | #Specify inspection profile for code analysis
8 | profile:
9 | name: qodana.starter
10 |
11 | #Enable inspections
12 | #include:
13 | # - name:
14 |
15 | #Disable inspections
16 | #exclude:
17 | # - name:
18 | # paths:
19 | # -
20 |
21 | #Execute shell command before Qodana execution (Applied in CI/CD pipeline)
22 | #bootstrap: sh ./prepare-qodana.sh
23 |
24 | #Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
25 | #plugins:
26 | # - id: #(plugin id can be found at https://plugins.jetbrains.com)
27 |
28 | #Specify Qodana linter for analysis (Applied in CI/CD pipeline)
29 | linter: jetbrains/qodana-go:2024.3
30 |
--------------------------------------------------------------------------------
/render.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | - type: web
3 | name: bullet-cloud-api
4 | runtime: go
5 | repo: https://github.com/Bulletdev/bullet-cloud-api
6 | plan: free
7 | envVars:
8 | - key: DbURL
9 | sync: false
10 | - key: CorsOrigins
11 | sync: false
12 | - key: PORT
13 | value: "10000"
14 | - key: test
15 | sync: false
16 | region: ohio
17 | buildCommand: |
18 | go mod tidy
19 | go mod vendor
20 | startCommand: go run cmd/main.go
21 | autoDeploy: false
22 | version: "1"
23 |
--------------------------------------------------------------------------------
/vendor/github.com/davecgh/go-spew/LICENSE:
--------------------------------------------------------------------------------
1 | ISC License
2 |
3 | Copyright (c) 2012-2016 Dave Collins
4 |
5 | Permission to use, copy, modify, and/or distribute this software for any
6 | purpose with or without fee is hereby granted, provided that the above
7 | copyright notice and this permission notice appear in all copies.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 |
--------------------------------------------------------------------------------
/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2015-2016 Dave Collins
2 | //
3 | // Permission to use, copy, modify, and distribute this software for any
4 | // purpose with or without fee is hereby granted, provided that the above
5 | // copyright notice and this permission notice appear in all copies.
6 | //
7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 |
15 | // NOTE: Due to the following build constraints, this file will only be compiled
16 | // when the code is running on Google App Engine, compiled by GopherJS, or
17 | // "-tags safe" is added to the go build command line. The "disableunsafe"
18 | // tag is deprecated and thus should not be used.
19 | // +build js appengine safe disableunsafe !go1.4
20 |
21 | package spew
22 |
23 | import "reflect"
24 |
25 | const (
26 | // UnsafeDisabled is a build-time constant which specifies whether or
27 | // not access to the unsafe package is available.
28 | UnsafeDisabled = true
29 | )
30 |
31 | // unsafeReflectValue typically converts the passed reflect.Value into a one
32 | // that bypasses the typical safety restrictions preventing access to
33 | // unaddressable and unexported data. However, doing this relies on access to
34 | // the unsafe package. This is a stub version which simply returns the passed
35 | // reflect.Value when the unsafe package is not available.
36 | func unsafeReflectValue(v reflect.Value) reflect.Value {
37 | return v
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | bin
3 | .idea/
4 |
5 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2012 Dave Grijalva
2 | Copyright (c) 2021 golang-jwt maintainers
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 |
10 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | ## Supported Versions
4 |
5 | As of November 2024 (and until this document is updated), the latest version `v5` is supported. In critical cases, we might supply back-ported patches for `v4`.
6 |
7 | ## Reporting a Vulnerability
8 |
9 | If you think you found a vulnerability, and even if you are not sure, please report it a [GitHub Security Advisory](https://github.com/golang-jwt/jwt/security/advisories/new). Please try be explicit, describe steps to reproduce the security issue with code example(s).
10 |
11 | You will receive a response within a timely manner. If the issue is confirmed, we will do our best to release a patch as soon as possible given the complexity of the problem.
12 |
13 | ## Public Discussions
14 |
15 | Please avoid publicly discussing a potential security vulnerability.
16 |
17 | Let's take this offline and find a solution first, this limits the potential impact as much as possible.
18 |
19 | We appreciate your help!
20 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/claims.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | // Claims represent any form of a JWT Claims Set according to
4 | // https://datatracker.ietf.org/doc/html/rfc7519#section-4. In order to have a
5 | // common basis for validation, it is required that an implementation is able to
6 | // supply at least the claim names provided in
7 | // https://datatracker.ietf.org/doc/html/rfc7519#section-4.1 namely `exp`,
8 | // `iat`, `nbf`, `iss`, `sub` and `aud`.
9 | type Claims interface {
10 | GetExpirationTime() (*NumericDate, error)
11 | GetIssuedAt() (*NumericDate, error)
12 | GetNotBefore() (*NumericDate, error)
13 | GetIssuer() (string, error)
14 | GetSubject() (string, error)
15 | GetAudience() (ClaimStrings, error)
16 | }
17 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/doc.go:
--------------------------------------------------------------------------------
1 | // Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html
2 | //
3 | // See README.md for more info.
4 | package jwt
5 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/ecdsa_utils.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "crypto/ecdsa"
5 | "crypto/x509"
6 | "encoding/pem"
7 | "errors"
8 | )
9 |
10 | var (
11 | ErrNotECPublicKey = errors.New("key is not a valid ECDSA public key")
12 | ErrNotECPrivateKey = errors.New("key is not a valid ECDSA private key")
13 | )
14 |
15 | // ParseECPrivateKeyFromPEM parses a PEM encoded Elliptic Curve Private Key Structure
16 | func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) {
17 | var err error
18 |
19 | // Parse PEM block
20 | var block *pem.Block
21 | if block, _ = pem.Decode(key); block == nil {
22 | return nil, ErrKeyMustBePEMEncoded
23 | }
24 |
25 | // Parse the key
26 | var parsedKey interface{}
27 | if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil {
28 | if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
29 | return nil, err
30 | }
31 | }
32 |
33 | var pkey *ecdsa.PrivateKey
34 | var ok bool
35 | if pkey, ok = parsedKey.(*ecdsa.PrivateKey); !ok {
36 | return nil, ErrNotECPrivateKey
37 | }
38 |
39 | return pkey, nil
40 | }
41 |
42 | // ParseECPublicKeyFromPEM parses a PEM encoded PKCS1 or PKCS8 public key
43 | func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) {
44 | var err error
45 |
46 | // Parse PEM block
47 | var block *pem.Block
48 | if block, _ = pem.Decode(key); block == nil {
49 | return nil, ErrKeyMustBePEMEncoded
50 | }
51 |
52 | // Parse the key
53 | var parsedKey interface{}
54 | if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
55 | if cert, err := x509.ParseCertificate(block.Bytes); err == nil {
56 | parsedKey = cert.PublicKey
57 | } else {
58 | return nil, err
59 | }
60 | }
61 |
62 | var pkey *ecdsa.PublicKey
63 | var ok bool
64 | if pkey, ok = parsedKey.(*ecdsa.PublicKey); !ok {
65 | return nil, ErrNotECPublicKey
66 | }
67 |
68 | return pkey, nil
69 | }
70 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/ed25519_utils.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "crypto"
5 | "crypto/ed25519"
6 | "crypto/x509"
7 | "encoding/pem"
8 | "errors"
9 | )
10 |
11 | var (
12 | ErrNotEdPrivateKey = errors.New("key is not a valid Ed25519 private key")
13 | ErrNotEdPublicKey = errors.New("key is not a valid Ed25519 public key")
14 | )
15 |
16 | // ParseEdPrivateKeyFromPEM parses a PEM-encoded Edwards curve private key
17 | func ParseEdPrivateKeyFromPEM(key []byte) (crypto.PrivateKey, error) {
18 | var err error
19 |
20 | // Parse PEM block
21 | var block *pem.Block
22 | if block, _ = pem.Decode(key); block == nil {
23 | return nil, ErrKeyMustBePEMEncoded
24 | }
25 |
26 | // Parse the key
27 | var parsedKey interface{}
28 | if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil {
29 | return nil, err
30 | }
31 |
32 | var pkey ed25519.PrivateKey
33 | var ok bool
34 | if pkey, ok = parsedKey.(ed25519.PrivateKey); !ok {
35 | return nil, ErrNotEdPrivateKey
36 | }
37 |
38 | return pkey, nil
39 | }
40 |
41 | // ParseEdPublicKeyFromPEM parses a PEM-encoded Edwards curve public key
42 | func ParseEdPublicKeyFromPEM(key []byte) (crypto.PublicKey, error) {
43 | var err error
44 |
45 | // Parse PEM block
46 | var block *pem.Block
47 | if block, _ = pem.Decode(key); block == nil {
48 | return nil, ErrKeyMustBePEMEncoded
49 | }
50 |
51 | // Parse the key
52 | var parsedKey interface{}
53 | if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil {
54 | return nil, err
55 | }
56 |
57 | var pkey ed25519.PublicKey
58 | var ok bool
59 | if pkey, ok = parsedKey.(ed25519.PublicKey); !ok {
60 | return nil, ErrNotEdPublicKey
61 | }
62 |
63 | return pkey, nil
64 | }
65 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/errors.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "errors"
5 | "strings"
6 | )
7 |
8 | var (
9 | ErrInvalidKey = errors.New("key is invalid")
10 | ErrInvalidKeyType = errors.New("key is of invalid type")
11 | ErrHashUnavailable = errors.New("the requested hash function is unavailable")
12 | ErrTokenMalformed = errors.New("token is malformed")
13 | ErrTokenUnverifiable = errors.New("token is unverifiable")
14 | ErrTokenSignatureInvalid = errors.New("token signature is invalid")
15 | ErrTokenRequiredClaimMissing = errors.New("token is missing required claim")
16 | ErrTokenInvalidAudience = errors.New("token has invalid audience")
17 | ErrTokenExpired = errors.New("token is expired")
18 | ErrTokenUsedBeforeIssued = errors.New("token used before issued")
19 | ErrTokenInvalidIssuer = errors.New("token has invalid issuer")
20 | ErrTokenInvalidSubject = errors.New("token has invalid subject")
21 | ErrTokenNotValidYet = errors.New("token is not valid yet")
22 | ErrTokenInvalidId = errors.New("token has invalid id")
23 | ErrTokenInvalidClaims = errors.New("token has invalid claims")
24 | ErrInvalidType = errors.New("invalid type for claim")
25 | )
26 |
27 | // joinedError is an error type that works similar to what [errors.Join]
28 | // produces, with the exception that it has a nice error string; mainly its
29 | // error messages are concatenated using a comma, rather than a newline.
30 | type joinedError struct {
31 | errs []error
32 | }
33 |
34 | func (je joinedError) Error() string {
35 | msg := []string{}
36 | for _, err := range je.errs {
37 | msg = append(msg, err.Error())
38 | }
39 |
40 | return strings.Join(msg, ", ")
41 | }
42 |
43 | // joinErrors joins together multiple errors. Useful for scenarios where
44 | // multiple errors next to each other occur, e.g., in claims validation.
45 | func joinErrors(errs ...error) error {
46 | return &joinedError{
47 | errs: errs,
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/errors_go1_20.go:
--------------------------------------------------------------------------------
1 | //go:build go1.20
2 | // +build go1.20
3 |
4 | package jwt
5 |
6 | import (
7 | "fmt"
8 | )
9 |
10 | // Unwrap implements the multiple error unwrapping for this error type, which is
11 | // possible in Go 1.20.
12 | func (je joinedError) Unwrap() []error {
13 | return je.errs
14 | }
15 |
16 | // newError creates a new error message with a detailed error message. The
17 | // message will be prefixed with the contents of the supplied error type.
18 | // Additionally, more errors, that provide more context can be supplied which
19 | // will be appended to the message. This makes use of Go 1.20's possibility to
20 | // include more than one %w formatting directive in [fmt.Errorf].
21 | //
22 | // For example,
23 | //
24 | // newError("no keyfunc was provided", ErrTokenUnverifiable)
25 | //
26 | // will produce the error string
27 | //
28 | // "token is unverifiable: no keyfunc was provided"
29 | func newError(message string, err error, more ...error) error {
30 | var format string
31 | var args []any
32 | if message != "" {
33 | format = "%w: %s"
34 | args = []any{err, message}
35 | } else {
36 | format = "%w"
37 | args = []any{err}
38 | }
39 |
40 | for _, e := range more {
41 | format += ": %w"
42 | args = append(args, e)
43 | }
44 |
45 | err = fmt.Errorf(format, args...)
46 | return err
47 | }
48 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/none.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | // SigningMethodNone implements the none signing method. This is required by the spec
4 | // but you probably should never use it.
5 | var SigningMethodNone *signingMethodNone
6 |
7 | const UnsafeAllowNoneSignatureType unsafeNoneMagicConstant = "none signing method allowed"
8 |
9 | var NoneSignatureTypeDisallowedError error
10 |
11 | type signingMethodNone struct{}
12 | type unsafeNoneMagicConstant string
13 |
14 | func init() {
15 | SigningMethodNone = &signingMethodNone{}
16 | NoneSignatureTypeDisallowedError = newError("'none' signature type is not allowed", ErrTokenUnverifiable)
17 |
18 | RegisterSigningMethod(SigningMethodNone.Alg(), func() SigningMethod {
19 | return SigningMethodNone
20 | })
21 | }
22 |
23 | func (m *signingMethodNone) Alg() string {
24 | return "none"
25 | }
26 |
27 | // Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key
28 | func (m *signingMethodNone) Verify(signingString string, sig []byte, key interface{}) (err error) {
29 | // Key must be UnsafeAllowNoneSignatureType to prevent accidentally
30 | // accepting 'none' signing method
31 | if _, ok := key.(unsafeNoneMagicConstant); !ok {
32 | return NoneSignatureTypeDisallowedError
33 | }
34 | // If signing method is none, signature must be an empty string
35 | if len(sig) != 0 {
36 | return newError("'none' signing method with non-empty signature", ErrTokenUnverifiable)
37 | }
38 |
39 | // Accept 'none' signing method.
40 | return nil
41 | }
42 |
43 | // Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key
44 | func (m *signingMethodNone) Sign(signingString string, key interface{}) ([]byte, error) {
45 | if _, ok := key.(unsafeNoneMagicConstant); ok {
46 | return []byte{}, nil
47 | }
48 |
49 | return nil, NoneSignatureTypeDisallowedError
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/signing_method.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | import (
4 | "sync"
5 | )
6 |
7 | var signingMethods = map[string]func() SigningMethod{}
8 | var signingMethodLock = new(sync.RWMutex)
9 |
10 | // SigningMethod can be used add new methods for signing or verifying tokens. It
11 | // takes a decoded signature as an input in the Verify function and produces a
12 | // signature in Sign. The signature is then usually base64 encoded as part of a
13 | // JWT.
14 | type SigningMethod interface {
15 | Verify(signingString string, sig []byte, key interface{}) error // Returns nil if signature is valid
16 | Sign(signingString string, key interface{}) ([]byte, error) // Returns signature or error
17 | Alg() string // returns the alg identifier for this method (example: 'HS256')
18 | }
19 |
20 | // RegisterSigningMethod registers the "alg" name and a factory function for signing method.
21 | // This is typically done during init() in the method's implementation
22 | func RegisterSigningMethod(alg string, f func() SigningMethod) {
23 | signingMethodLock.Lock()
24 | defer signingMethodLock.Unlock()
25 |
26 | signingMethods[alg] = f
27 | }
28 |
29 | // GetSigningMethod retrieves a signing method from an "alg" string
30 | func GetSigningMethod(alg string) (method SigningMethod) {
31 | signingMethodLock.RLock()
32 | defer signingMethodLock.RUnlock()
33 |
34 | if methodF, ok := signingMethods[alg]; ok {
35 | method = methodF()
36 | }
37 | return
38 | }
39 |
40 | // GetAlgorithms returns a list of registered "alg" names
41 | func GetAlgorithms() (algs []string) {
42 | signingMethodLock.RLock()
43 | defer signingMethodLock.RUnlock()
44 |
45 | for alg := range signingMethods {
46 | algs = append(algs, alg)
47 | }
48 | return
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/staticcheck.conf:
--------------------------------------------------------------------------------
1 | checks = ["all", "-ST1000", "-ST1003", "-ST1016", "-ST1023"]
2 |
--------------------------------------------------------------------------------
/vendor/github.com/golang-jwt/jwt/v5/token_option.go:
--------------------------------------------------------------------------------
1 | package jwt
2 |
3 | // TokenOption is a reserved type, which provides some forward compatibility,
4 | // if we ever want to introduce token creation-related options.
5 | type TokenOption func(*Token)
6 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## [1.6.0](https://github.com/google/uuid/compare/v1.5.0...v1.6.0) (2024-01-16)
4 |
5 |
6 | ### Features
7 |
8 | * add Max UUID constant ([#149](https://github.com/google/uuid/issues/149)) ([c58770e](https://github.com/google/uuid/commit/c58770eb495f55fe2ced6284f93c5158a62e53e3))
9 |
10 |
11 | ### Bug Fixes
12 |
13 | * fix typo in version 7 uuid documentation ([#153](https://github.com/google/uuid/issues/153)) ([016b199](https://github.com/google/uuid/commit/016b199544692f745ffc8867b914129ecb47ef06))
14 | * Monotonicity in UUIDv7 ([#150](https://github.com/google/uuid/issues/150)) ([a2b2b32](https://github.com/google/uuid/commit/a2b2b32373ff0b1a312b7fdf6d38a977099698a6))
15 |
16 | ## [1.5.0](https://github.com/google/uuid/compare/v1.4.0...v1.5.0) (2023-12-12)
17 |
18 |
19 | ### Features
20 |
21 | * Validate UUID without creating new UUID ([#141](https://github.com/google/uuid/issues/141)) ([9ee7366](https://github.com/google/uuid/commit/9ee7366e66c9ad96bab89139418a713dc584ae29))
22 |
23 | ## [1.4.0](https://github.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26)
24 |
25 |
26 | ### Features
27 |
28 | * UUIDs slice type with Strings() convenience method ([#133](https://github.com/google/uuid/issues/133)) ([cd5fbbd](https://github.com/google/uuid/commit/cd5fbbdd02f3e3467ac18940e07e062be1f864b4))
29 |
30 | ### Fixes
31 |
32 | * Clarify that Parse's job is to parse but not necessarily validate strings. (Documents current behavior)
33 |
34 | ## [1.3.1](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) (2023-08-18)
35 |
36 |
37 | ### Bug Fixes
38 |
39 | * Use .EqualFold() to parse urn prefixed UUIDs ([#118](https://github.com/google/uuid/issues/118)) ([574e687](https://github.com/google/uuid/commit/574e6874943741fb99d41764c705173ada5293f0))
40 |
41 | ## Changelog
42 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | We definitely welcome patches and contribution to this project!
4 |
5 | ### Tips
6 |
7 | Commits must be formatted according to the [Conventional Commits Specification](https://www.conventionalcommits.org).
8 |
9 | Always try to include a test case! If it is not possible or not necessary,
10 | please explain why in the pull request description.
11 |
12 | ### Releasing
13 |
14 | Commits that would precipitate a SemVer change, as described in the Conventional
15 | Commits Specification, will trigger [`release-please`](https://github.com/google-github-actions/release-please-action)
16 | to create a release candidate pull request. Once submitted, `release-please`
17 | will create a release.
18 |
19 | For tips on how to work with `release-please`, see its documentation.
20 |
21 | ### Legal requirements
22 |
23 | In order to protect both you and ourselves, you will need to sign the
24 | [Contributor License Agreement](https://cla.developers.google.com/clas).
25 |
26 | You may have already signed it for other Google projects.
27 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/CONTRIBUTORS:
--------------------------------------------------------------------------------
1 | Paul Borman
2 | bmatsuo
3 | shawnps
4 | theory
5 | jboverfelt
6 | dsymonds
7 | cd1
8 | wallclockbuilder
9 | dansouza
10 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2009,2014 Google Inc. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google Inc. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/README.md:
--------------------------------------------------------------------------------
1 | # uuid
2 | The uuid package generates and inspects UUIDs based on
3 | [RFC 4122](https://datatracker.ietf.org/doc/html/rfc4122)
4 | and DCE 1.1: Authentication and Security Services.
5 |
6 | This package is based on the github.com/pborman/uuid package (previously named
7 | code.google.com/p/go-uuid). It differs from these earlier packages in that
8 | a UUID is a 16 byte array rather than a byte slice. One loss due to this
9 | change is the ability to represent an invalid UUID (vs a NIL UUID).
10 |
11 | ###### Install
12 | ```sh
13 | go get github.com/google/uuid
14 | ```
15 |
16 | ###### Documentation
17 | [](https://pkg.go.dev/github.com/google/uuid)
18 |
19 | Full `go doc` style documentation for the package can be viewed online without
20 | installing this package by using the GoDoc site here:
21 | http://pkg.go.dev/github.com/google/uuid
22 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Google Inc. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package uuid generates and inspects UUIDs.
6 | //
7 | // UUIDs are based on RFC 4122 and DCE 1.1: Authentication and Security
8 | // Services.
9 | //
10 | // A UUID is a 16 byte (128 bit) array. UUIDs may be used as keys to
11 | // maps or compared directly.
12 | package uuid
13 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/marshal.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Google Inc. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package uuid
6 |
7 | import "fmt"
8 |
9 | // MarshalText implements encoding.TextMarshaler.
10 | func (uuid UUID) MarshalText() ([]byte, error) {
11 | var js [36]byte
12 | encodeHex(js[:], uuid)
13 | return js[:], nil
14 | }
15 |
16 | // UnmarshalText implements encoding.TextUnmarshaler.
17 | func (uuid *UUID) UnmarshalText(data []byte) error {
18 | id, err := ParseBytes(data)
19 | if err != nil {
20 | return err
21 | }
22 | *uuid = id
23 | return nil
24 | }
25 |
26 | // MarshalBinary implements encoding.BinaryMarshaler.
27 | func (uuid UUID) MarshalBinary() ([]byte, error) {
28 | return uuid[:], nil
29 | }
30 |
31 | // UnmarshalBinary implements encoding.BinaryUnmarshaler.
32 | func (uuid *UUID) UnmarshalBinary(data []byte) error {
33 | if len(data) != 16 {
34 | return fmt.Errorf("invalid UUID (got %d bytes)", len(data))
35 | }
36 | copy(uuid[:], data)
37 | return nil
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/node_js.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Google Inc. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build js
6 |
7 | package uuid
8 |
9 | // getHardwareInterface returns nil values for the JS version of the code.
10 | // This removes the "net" dependency, because it is not used in the browser.
11 | // Using the "net" library inflates the size of the transpiled JS code by 673k bytes.
12 | func getHardwareInterface(name string) (string, []byte) { return "", nil }
13 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/node_net.go:
--------------------------------------------------------------------------------
1 | // Copyright 2017 Google Inc. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // +build !js
6 |
7 | package uuid
8 |
9 | import "net"
10 |
11 | var interfaces []net.Interface // cached list of interfaces
12 |
13 | // getHardwareInterface returns the name and hardware address of interface name.
14 | // If name is "" then the name and hardware address of one of the system's
15 | // interfaces is returned. If no interfaces are found (name does not exist or
16 | // there are no interfaces) then "", nil is returned.
17 | //
18 | // Only addresses of at least 6 bytes are returned.
19 | func getHardwareInterface(name string) (string, []byte) {
20 | if interfaces == nil {
21 | var err error
22 | interfaces, err = net.Interfaces()
23 | if err != nil {
24 | return "", nil
25 | }
26 | }
27 | for _, ifs := range interfaces {
28 | if len(ifs.HardwareAddr) >= 6 && (name == "" || name == ifs.Name) {
29 | return ifs.Name, ifs.HardwareAddr
30 | }
31 | }
32 | return "", nil
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/sql.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Google Inc. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package uuid
6 |
7 | import (
8 | "database/sql/driver"
9 | "fmt"
10 | )
11 |
12 | // Scan implements sql.Scanner so UUIDs can be read from databases transparently.
13 | // Currently, database types that map to string and []byte are supported. Please
14 | // consult database-specific driver documentation for matching types.
15 | func (uuid *UUID) Scan(src interface{}) error {
16 | switch src := src.(type) {
17 | case nil:
18 | return nil
19 |
20 | case string:
21 | // if an empty UUID comes from a table, we return a null UUID
22 | if src == "" {
23 | return nil
24 | }
25 |
26 | // see Parse for required string format
27 | u, err := Parse(src)
28 | if err != nil {
29 | return fmt.Errorf("Scan: %v", err)
30 | }
31 |
32 | *uuid = u
33 |
34 | case []byte:
35 | // if an empty UUID comes from a table, we return a null UUID
36 | if len(src) == 0 {
37 | return nil
38 | }
39 |
40 | // assumes a simple slice of bytes if 16 bytes
41 | // otherwise attempts to parse
42 | if len(src) != 16 {
43 | return uuid.Scan(string(src))
44 | }
45 | copy((*uuid)[:], src)
46 |
47 | default:
48 | return fmt.Errorf("Scan: unable to scan type %T into UUID", src)
49 | }
50 |
51 | return nil
52 | }
53 |
54 | // Value implements sql.Valuer so that UUIDs can be written to databases
55 | // transparently. Currently, UUIDs map to strings. Please consult
56 | // database-specific driver documentation for matching types.
57 | func (uuid UUID) Value() (driver.Value, error) {
58 | return uuid.String(), nil
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/util.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Google Inc. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package uuid
6 |
7 | import (
8 | "io"
9 | )
10 |
11 | // randomBits completely fills slice b with random data.
12 | func randomBits(b []byte) {
13 | if _, err := io.ReadFull(rander, b); err != nil {
14 | panic(err.Error()) // rand should never fail
15 | }
16 | }
17 |
18 | // xvalues returns the value of a byte as a hexadecimal digit or 255.
19 | var xvalues = [256]byte{
20 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
21 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
22 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
23 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 255, 255, 255, 255, 255, 255,
24 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
25 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
26 | 255, 10, 11, 12, 13, 14, 15, 255, 255, 255, 255, 255, 255, 255, 255, 255,
27 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
28 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
29 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
30 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
31 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
32 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
33 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
34 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
35 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
36 | }
37 |
38 | // xtob converts hex characters x1 and x2 into a byte.
39 | func xtob(x1, x2 byte) (byte, bool) {
40 | b1 := xvalues[x1]
41 | b2 := xvalues[x2]
42 | return (b1 << 4) | b2, b1 != 255 && b2 != 255
43 | }
44 |
--------------------------------------------------------------------------------
/vendor/github.com/google/uuid/version1.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 Google Inc. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package uuid
6 |
7 | import (
8 | "encoding/binary"
9 | )
10 |
11 | // NewUUID returns a Version 1 UUID based on the current NodeID and clock
12 | // sequence, and the current time. If the NodeID has not been set by SetNodeID
13 | // or SetNodeInterface then it will be set automatically. If the NodeID cannot
14 | // be set NewUUID returns nil. If clock sequence has not been set by
15 | // SetClockSequence then it will be set automatically. If GetTime fails to
16 | // return the current NewUUID returns nil and an error.
17 | //
18 | // In most cases, New should be used.
19 | func NewUUID() (UUID, error) {
20 | var uuid UUID
21 | now, seq, err := GetTime()
22 | if err != nil {
23 | return uuid, err
24 | }
25 |
26 | timeLow := uint32(now & 0xffffffff)
27 | timeMid := uint16((now >> 32) & 0xffff)
28 | timeHi := uint16((now >> 48) & 0x0fff)
29 | timeHi |= 0x1000 // Version 1
30 |
31 | binary.BigEndian.PutUint32(uuid[0:], timeLow)
32 | binary.BigEndian.PutUint16(uuid[4:], timeMid)
33 | binary.BigEndian.PutUint16(uuid[6:], timeHi)
34 | binary.BigEndian.PutUint16(uuid[8:], seq)
35 |
36 | nodeMu.Lock()
37 | if nodeID == zeroID {
38 | setNodeInterface("")
39 | }
40 | copy(uuid[10:], nodeID[:])
41 | nodeMu.Unlock()
42 |
43 | return uuid, nil
44 | }
45 |
--------------------------------------------------------------------------------
/vendor/github.com/gorilla/mux/.editorconfig:
--------------------------------------------------------------------------------
1 | ; https://editorconfig.org/
2 |
3 | root = true
4 |
5 | [*]
6 | insert_final_newline = true
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | indent_style = space
10 | indent_size = 2
11 |
12 | [{Makefile,go.mod,go.sum,*.go,.gitmodules}]
13 | indent_style = tab
14 | indent_size = 4
15 |
16 | [*.md]
17 | indent_size = 4
18 | trim_trailing_whitespace = false
19 |
20 | eclint_indent_style = unset
--------------------------------------------------------------------------------
/vendor/github.com/gorilla/mux/.gitignore:
--------------------------------------------------------------------------------
1 | coverage.coverprofile
2 |
--------------------------------------------------------------------------------
/vendor/github.com/gorilla/mux/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2023 The Gorilla Authors. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google Inc. nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/github.com/gorilla/mux/Makefile:
--------------------------------------------------------------------------------
1 | GO_LINT=$(shell which golangci-lint 2> /dev/null || echo '')
2 | GO_LINT_URI=github.com/golangci/golangci-lint/cmd/golangci-lint@latest
3 |
4 | GO_SEC=$(shell which gosec 2> /dev/null || echo '')
5 | GO_SEC_URI=github.com/securego/gosec/v2/cmd/gosec@latest
6 |
7 | GO_VULNCHECK=$(shell which govulncheck 2> /dev/null || echo '')
8 | GO_VULNCHECK_URI=golang.org/x/vuln/cmd/govulncheck@latest
9 |
10 | .PHONY: golangci-lint
11 | golangci-lint:
12 | $(if $(GO_LINT), ,go install $(GO_LINT_URI))
13 | @echo "##### Running golangci-lint"
14 | golangci-lint run -v
15 |
16 | .PHONY: gosec
17 | gosec:
18 | $(if $(GO_SEC), ,go install $(GO_SEC_URI))
19 | @echo "##### Running gosec"
20 | gosec ./...
21 |
22 | .PHONY: govulncheck
23 | govulncheck:
24 | $(if $(GO_VULNCHECK), ,go install $(GO_VULNCHECK_URI))
25 | @echo "##### Running govulncheck"
26 | govulncheck ./...
27 |
28 | .PHONY: verify
29 | verify: golangci-lint gosec govulncheck
30 |
31 | .PHONY: test
32 | test:
33 | @echo "##### Running tests"
34 | go test -race -cover -coverprofile=coverage.coverprofile -covermode=atomic -v ./...
--------------------------------------------------------------------------------
/vendor/github.com/gorilla/mux/test_helpers.go:
--------------------------------------------------------------------------------
1 | // Copyright 2012 The Gorilla Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package mux
6 |
7 | import "net/http"
8 |
9 | // SetURLVars sets the URL variables for the given request, to be accessed via
10 | // mux.Vars for testing route behaviour. Arguments are not modified, a shallow
11 | // copy is returned.
12 | //
13 | // This API should only be used for testing purposes; it provides a way to
14 | // inject variables into the request context. Alternatively, URL variables
15 | // can be set by making a route that captures the required variables,
16 | // starting a server and sending the request to that server.
17 | func SetURLVars(r *http.Request, val map[string]string) *http.Request {
18 | return requestWithVars(r, val)
19 | }
20 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgpassfile/.travis.yml:
--------------------------------------------------------------------------------
1 | language: go
2 |
3 | go:
4 | - 1.x
5 | - tip
6 |
7 | matrix:
8 | allow_failures:
9 | - go: tip
10 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgpassfile/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2019 Jack Christensen
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgpassfile/README.md:
--------------------------------------------------------------------------------
1 | [](https://godoc.org/github.com/jackc/pgpassfile)
2 | [](https://travis-ci.org/jackc/pgpassfile)
3 |
4 | # pgpassfile
5 |
6 | Package pgpassfile is a parser PostgreSQL .pgpass files.
7 |
8 | Extracted and rewritten from original implementation in https://github.com/jackc/pgx.
9 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgservicefile/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2020 Jack Christensen
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgservicefile/README.md:
--------------------------------------------------------------------------------
1 | [](https://pkg.go.dev/github.com/jackc/pgservicefile)
2 | [](https://github.com/jackc/pgservicefile/actions/workflows/ci.yml)
3 |
4 |
5 | # pgservicefile
6 |
7 | Package pgservicefile is a parser for PostgreSQL service files (e.g. `.pg_service.conf`).
8 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled Object files, Static and Dynamic libs (Shared Objects)
2 | *.o
3 | *.a
4 | *.so
5 |
6 | # Folders
7 | _obj
8 | _test
9 |
10 | # Architecture specific extensions/prefixes
11 | *.[568vq]
12 | [568vq].out
13 |
14 | *.cgo1.go
15 | *.cgo2.c
16 | _cgo_defun.c
17 | _cgo_gotypes.go
18 | _cgo_export.*
19 |
20 | _testmain.go
21 |
22 | *.exe
23 |
24 | .envrc
25 | /.testdb
26 |
27 | .DS_Store
28 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013-2021 Jack Christensen
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/Rakefile:
--------------------------------------------------------------------------------
1 | require "erb"
2 |
3 | rule '.go' => '.go.erb' do |task|
4 | erb = ERB.new(File.read(task.source))
5 | File.write(task.name, "// Code generated from #{task.source}. DO NOT EDIT.\n\n" + erb.result(binding))
6 | sh "goimports", "-w", task.name
7 | end
8 |
9 | generated_code_files = [
10 | "pgtype/int.go",
11 | "pgtype/int_test.go",
12 | "pgtype/integration_benchmark_test.go",
13 | "pgtype/zeronull/int.go",
14 | "pgtype/zeronull/int_test.go"
15 | ]
16 |
17 | desc "Generate code"
18 | task generate: generated_code_files
19 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/internal/iobufpool/iobufpool.go:
--------------------------------------------------------------------------------
1 | // Package iobufpool implements a global segregated-fit pool of buffers for IO.
2 | //
3 | // It uses *[]byte instead of []byte to avoid the sync.Pool allocation with Put. Unfortunately, using a pointer to avoid
4 | // an allocation is purposely not documented. https://github.com/golang/go/issues/16323
5 | package iobufpool
6 |
7 | import "sync"
8 |
9 | const minPoolExpOf2 = 8
10 |
11 | var pools [18]*sync.Pool
12 |
13 | func init() {
14 | for i := range pools {
15 | bufLen := 1 << (minPoolExpOf2 + i)
16 | pools[i] = &sync.Pool{
17 | New: func() any {
18 | buf := make([]byte, bufLen)
19 | return &buf
20 | },
21 | }
22 | }
23 | }
24 |
25 | // Get gets a []byte of len size with cap <= size*2.
26 | func Get(size int) *[]byte {
27 | i := getPoolIdx(size)
28 | if i >= len(pools) {
29 | buf := make([]byte, size)
30 | return &buf
31 | }
32 |
33 | ptrBuf := (pools[i].Get().(*[]byte))
34 | *ptrBuf = (*ptrBuf)[:size]
35 |
36 | return ptrBuf
37 | }
38 |
39 | func getPoolIdx(size int) int {
40 | size--
41 | size >>= minPoolExpOf2
42 | i := 0
43 | for size > 0 {
44 | size >>= 1
45 | i++
46 | }
47 |
48 | return i
49 | }
50 |
51 | // Put returns buf to the pool.
52 | func Put(buf *[]byte) {
53 | i := putPoolIdx(cap(*buf))
54 | if i < 0 {
55 | return
56 | }
57 |
58 | pools[i].Put(buf)
59 | }
60 |
61 | func putPoolIdx(size int) int {
62 | minPoolSize := 1 << minPoolExpOf2
63 | for i := range pools {
64 | if size == minPoolSize< ... "
23 | exit 1
24 | fi
25 |
26 | commits=("$@")
27 | benchmarks_dir=benchmarks
28 |
29 | if ! mkdir -p "${benchmarks_dir}"; then
30 | echo "Unable to create dir for benchmarks data"
31 | exit 1
32 | fi
33 |
34 | # Benchmark results
35 | bench_files=()
36 |
37 | # Run benchmark for each listed commit
38 | for i in "${!commits[@]}"; do
39 | commit="${commits[i]}"
40 | git checkout "$commit" || {
41 | echo "Failed to checkout $commit"
42 | exit 1
43 | }
44 |
45 | # Sanitized commmit message
46 | commit_message=$(git log -1 --pretty=format:"%s" | tr -c '[:alnum:]-_' '_')
47 |
48 | # Benchmark data will go there
49 | bench_file="${benchmarks_dir}/${i}_${commit_message}.bench"
50 |
51 | if ! go test -bench=. -count=10 >"$bench_file"; then
52 | echo "Benchmarking failed for commit $commit"
53 | exit 1
54 | fi
55 |
56 | bench_files+=("$bench_file")
57 | done
58 |
59 | # go install golang.org/x/perf/cmd/benchstat[@latest]
60 | benchstat "${bench_files[@]}"
61 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/internal/stmtcache/stmtcache.go:
--------------------------------------------------------------------------------
1 | // Package stmtcache is a cache for statement descriptions.
2 | package stmtcache
3 |
4 | import (
5 | "crypto/sha256"
6 | "encoding/hex"
7 |
8 | "github.com/jackc/pgx/v5/pgconn"
9 | )
10 |
11 | // StatementName returns a statement name that will be stable for sql across multiple connections and program
12 | // executions.
13 | func StatementName(sql string) string {
14 | digest := sha256.Sum256([]byte(sql))
15 | return "stmtcache_" + hex.EncodeToString(digest[0:24])
16 | }
17 |
18 | // Cache caches statement descriptions.
19 | type Cache interface {
20 | // Get returns the statement description for sql. Returns nil if not found.
21 | Get(sql string) *pgconn.StatementDescription
22 |
23 | // Put stores sd in the cache. Put panics if sd.SQL is "". Put does nothing if sd.SQL already exists in the cache.
24 | Put(sd *pgconn.StatementDescription)
25 |
26 | // Invalidate invalidates statement description identified by sql. Does nothing if not found.
27 | Invalidate(sql string)
28 |
29 | // InvalidateAll invalidates all statement descriptions.
30 | InvalidateAll()
31 |
32 | // GetInvalidated returns a slice of all statement descriptions invalidated since the last call to RemoveInvalidated.
33 | GetInvalidated() []*pgconn.StatementDescription
34 |
35 | // RemoveInvalidated removes all invalidated statement descriptions. No other calls to Cache must be made between a
36 | // call to GetInvalidated and RemoveInvalidated or RemoveInvalidated may remove statement descriptions that were
37 | // never seen by the call to GetInvalidated.
38 | RemoveInvalidated()
39 |
40 | // Len returns the number of cached prepared statement descriptions.
41 | Len() int
42 |
43 | // Cap returns the maximum number of cached prepared statement descriptions.
44 | Cap() int
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgconn/README.md:
--------------------------------------------------------------------------------
1 | # pgconn
2 |
3 | Package pgconn is a low-level PostgreSQL database driver. It operates at nearly the same level as the C library libpq.
4 | It is primarily intended to serve as the foundation for higher level libraries such as https://github.com/jackc/pgx.
5 | Applications should handle normal queries with a higher level library and only use pgconn directly when required for
6 | low-level access to PostgreSQL functionality.
7 |
8 | ## Example Usage
9 |
10 | ```go
11 | pgConn, err := pgconn.Connect(context.Background(), os.Getenv("DATABASE_URL"))
12 | if err != nil {
13 | log.Fatalln("pgconn failed to connect:", err)
14 | }
15 | defer pgConn.Close(context.Background())
16 |
17 | result := pgConn.ExecParams(context.Background(), "SELECT email FROM users WHERE id=$1", [][]byte{[]byte("123")}, nil, nil, nil)
18 | for result.NextRow() {
19 | fmt.Println("User 123 has email:", string(result.Values()[0]))
20 | }
21 | _, err = result.Close()
22 | if err != nil {
23 | log.Fatalln("failed reading result:", err)
24 | }
25 | ```
26 |
27 | ## Testing
28 |
29 | See CONTRIBUTING.md for setup instructions.
30 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgconn/defaults.go:
--------------------------------------------------------------------------------
1 | //go:build !windows
2 | // +build !windows
3 |
4 | package pgconn
5 |
6 | import (
7 | "os"
8 | "os/user"
9 | "path/filepath"
10 | )
11 |
12 | func defaultSettings() map[string]string {
13 | settings := make(map[string]string)
14 |
15 | settings["host"] = defaultHost()
16 | settings["port"] = "5432"
17 |
18 | // Default to the OS user name. Purposely ignoring err getting user name from
19 | // OS. The client application will simply have to specify the user in that
20 | // case (which they typically will be doing anyway).
21 | user, err := user.Current()
22 | if err == nil {
23 | settings["user"] = user.Username
24 | settings["passfile"] = filepath.Join(user.HomeDir, ".pgpass")
25 | settings["servicefile"] = filepath.Join(user.HomeDir, ".pg_service.conf")
26 | sslcert := filepath.Join(user.HomeDir, ".postgresql", "postgresql.crt")
27 | sslkey := filepath.Join(user.HomeDir, ".postgresql", "postgresql.key")
28 | if _, err := os.Stat(sslcert); err == nil {
29 | if _, err := os.Stat(sslkey); err == nil {
30 | // Both the cert and key must be present to use them, or do not use either
31 | settings["sslcert"] = sslcert
32 | settings["sslkey"] = sslkey
33 | }
34 | }
35 | sslrootcert := filepath.Join(user.HomeDir, ".postgresql", "root.crt")
36 | if _, err := os.Stat(sslrootcert); err == nil {
37 | settings["sslrootcert"] = sslrootcert
38 | }
39 | }
40 |
41 | settings["target_session_attrs"] = "any"
42 |
43 | return settings
44 | }
45 |
46 | // defaultHost attempts to mimic libpq's default host. libpq uses the default unix socket location on *nix and localhost
47 | // on Windows. The default socket location is compiled into libpq. Since pgx does not have access to that default it
48 | // checks the existence of common locations.
49 | func defaultHost() string {
50 | candidatePaths := []string{
51 | "/var/run/postgresql", // Debian
52 | "/private/tmp", // OSX - homebrew
53 | "/tmp", // standard PostgreSQL
54 | }
55 |
56 | for _, path := range candidatePaths {
57 | if _, err := os.Stat(path); err == nil {
58 | return path
59 | }
60 | }
61 |
62 | return "localhost"
63 | }
64 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgconn/doc.go:
--------------------------------------------------------------------------------
1 | // Package pgconn is a low-level PostgreSQL database driver.
2 | /*
3 | pgconn provides lower level access to a PostgreSQL connection than a database/sql or pgx connection. It operates at
4 | nearly the same level is the C library libpq.
5 |
6 | Establishing a Connection
7 |
8 | Use Connect to establish a connection. It accepts a connection string in URL or keyword/value format and will read the
9 | environment for libpq style environment variables.
10 |
11 | Executing a Query
12 |
13 | ExecParams and ExecPrepared execute a single query. They return readers that iterate over each row. The Read method
14 | reads all rows into memory.
15 |
16 | Executing Multiple Queries in a Single Round Trip
17 |
18 | Exec and ExecBatch can execute multiple queries in a single round trip. They return readers that iterate over each query
19 | result. The ReadAll method reads all query results into memory.
20 |
21 | Pipeline Mode
22 |
23 | Pipeline mode allows sending queries without having read the results of previously sent queries. It allows control of
24 | exactly how many and when network round trips occur.
25 |
26 | Context Support
27 |
28 | All potentially blocking operations take a context.Context. The default behavior when a context is canceled is for the
29 | method to immediately return. In most circumstances, this will also close the underlying connection. This behavior can
30 | be customized by using BuildContextWatcherHandler on the Config to create a ctxwatch.Handler with different behavior.
31 | This can be especially useful when queries that are frequently canceled and the overhead of creating new connections is
32 | a problem. DeadlineContextWatcherHandler and CancelRequestContextWatcherHandler can be used to introduce a delay before
33 | interrupting the query in such a way as to close the connection.
34 |
35 | The CancelRequest method may be used to request the PostgreSQL server cancel an in-progress query without forcing the
36 | client to abort.
37 | */
38 | package pgconn
39 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/README.md:
--------------------------------------------------------------------------------
1 | # pgproto3
2 |
3 | Package pgproto3 is an encoder and decoder of the PostgreSQL wire protocol version 3.
4 |
5 | pgproto3 can be used as a foundation for PostgreSQL drivers, proxies, mock servers, load balancers and more.
6 |
7 | See example/pgfortune for a playful example of a fake PostgreSQL server.
8 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/authentication_cleartext_password.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 | "errors"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | // AuthenticationCleartextPassword is a message sent from the backend indicating that a clear-text password is required.
12 | type AuthenticationCleartextPassword struct {
13 | }
14 |
15 | // Backend identifies this message as sendable by the PostgreSQL backend.
16 | func (*AuthenticationCleartextPassword) Backend() {}
17 |
18 | // Backend identifies this message as an authentication response.
19 | func (*AuthenticationCleartextPassword) AuthenticationResponse() {}
20 |
21 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
22 | // type identifier and 4 byte message length.
23 | func (dst *AuthenticationCleartextPassword) Decode(src []byte) error {
24 | if len(src) != 4 {
25 | return errors.New("bad authentication message size")
26 | }
27 |
28 | authType := binary.BigEndian.Uint32(src)
29 |
30 | if authType != AuthTypeCleartextPassword {
31 | return errors.New("bad auth type")
32 | }
33 |
34 | return nil
35 | }
36 |
37 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
38 | func (src *AuthenticationCleartextPassword) Encode(dst []byte) ([]byte, error) {
39 | dst, sp := beginMessage(dst, 'R')
40 | dst = pgio.AppendUint32(dst, AuthTypeCleartextPassword)
41 | return finishMessage(dst, sp)
42 | }
43 |
44 | // MarshalJSON implements encoding/json.Marshaler.
45 | func (src AuthenticationCleartextPassword) MarshalJSON() ([]byte, error) {
46 | return json.Marshal(struct {
47 | Type string
48 | }{
49 | Type: "AuthenticationCleartextPassword",
50 | })
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/authentication_gss.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 | "errors"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | type AuthenticationGSS struct{}
12 |
13 | func (a *AuthenticationGSS) Backend() {}
14 |
15 | func (a *AuthenticationGSS) AuthenticationResponse() {}
16 |
17 | func (a *AuthenticationGSS) Decode(src []byte) error {
18 | if len(src) < 4 {
19 | return errors.New("authentication message too short")
20 | }
21 |
22 | authType := binary.BigEndian.Uint32(src)
23 |
24 | if authType != AuthTypeGSS {
25 | return errors.New("bad auth type")
26 | }
27 | return nil
28 | }
29 |
30 | func (a *AuthenticationGSS) Encode(dst []byte) ([]byte, error) {
31 | dst, sp := beginMessage(dst, 'R')
32 | dst = pgio.AppendUint32(dst, AuthTypeGSS)
33 | return finishMessage(dst, sp)
34 | }
35 |
36 | func (a *AuthenticationGSS) MarshalJSON() ([]byte, error) {
37 | return json.Marshal(struct {
38 | Type string
39 | Data []byte
40 | }{
41 | Type: "AuthenticationGSS",
42 | })
43 | }
44 |
45 | func (a *AuthenticationGSS) UnmarshalJSON(data []byte) error {
46 | // Ignore null, like in the main JSON package.
47 | if string(data) == "null" {
48 | return nil
49 | }
50 |
51 | var msg struct {
52 | Type string
53 | }
54 | if err := json.Unmarshal(data, &msg); err != nil {
55 | return err
56 | }
57 | return nil
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/authentication_gss_continue.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 | "errors"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | type AuthenticationGSSContinue struct {
12 | Data []byte
13 | }
14 |
15 | func (a *AuthenticationGSSContinue) Backend() {}
16 |
17 | func (a *AuthenticationGSSContinue) AuthenticationResponse() {}
18 |
19 | func (a *AuthenticationGSSContinue) Decode(src []byte) error {
20 | if len(src) < 4 {
21 | return errors.New("authentication message too short")
22 | }
23 |
24 | authType := binary.BigEndian.Uint32(src)
25 |
26 | if authType != AuthTypeGSSCont {
27 | return errors.New("bad auth type")
28 | }
29 |
30 | a.Data = src[4:]
31 | return nil
32 | }
33 |
34 | func (a *AuthenticationGSSContinue) Encode(dst []byte) ([]byte, error) {
35 | dst, sp := beginMessage(dst, 'R')
36 | dst = pgio.AppendUint32(dst, AuthTypeGSSCont)
37 | dst = append(dst, a.Data...)
38 | return finishMessage(dst, sp)
39 | }
40 |
41 | func (a *AuthenticationGSSContinue) MarshalJSON() ([]byte, error) {
42 | return json.Marshal(struct {
43 | Type string
44 | Data []byte
45 | }{
46 | Type: "AuthenticationGSSContinue",
47 | Data: a.Data,
48 | })
49 | }
50 |
51 | func (a *AuthenticationGSSContinue) UnmarshalJSON(data []byte) error {
52 | // Ignore null, like in the main JSON package.
53 | if string(data) == "null" {
54 | return nil
55 | }
56 |
57 | var msg struct {
58 | Type string
59 | Data []byte
60 | }
61 | if err := json.Unmarshal(data, &msg); err != nil {
62 | return err
63 | }
64 |
65 | a.Data = msg.Data
66 | return nil
67 | }
68 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/authentication_ok.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 | "errors"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | // AuthenticationOk is a message sent from the backend indicating that authentication was successful.
12 | type AuthenticationOk struct {
13 | }
14 |
15 | // Backend identifies this message as sendable by the PostgreSQL backend.
16 | func (*AuthenticationOk) Backend() {}
17 |
18 | // Backend identifies this message as an authentication response.
19 | func (*AuthenticationOk) AuthenticationResponse() {}
20 |
21 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
22 | // type identifier and 4 byte message length.
23 | func (dst *AuthenticationOk) Decode(src []byte) error {
24 | if len(src) != 4 {
25 | return errors.New("bad authentication message size")
26 | }
27 |
28 | authType := binary.BigEndian.Uint32(src)
29 |
30 | if authType != AuthTypeOk {
31 | return errors.New("bad auth type")
32 | }
33 |
34 | return nil
35 | }
36 |
37 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
38 | func (src *AuthenticationOk) Encode(dst []byte) ([]byte, error) {
39 | dst, sp := beginMessage(dst, 'R')
40 | dst = pgio.AppendUint32(dst, AuthTypeOk)
41 | return finishMessage(dst, sp)
42 | }
43 |
44 | // MarshalJSON implements encoding/json.Marshaler.
45 | func (src AuthenticationOk) MarshalJSON() ([]byte, error) {
46 | return json.Marshal(struct {
47 | Type string
48 | }{
49 | Type: "AuthenticationOK",
50 | })
51 | }
52 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/backend_key_data.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 |
7 | "github.com/jackc/pgx/v5/internal/pgio"
8 | )
9 |
10 | type BackendKeyData struct {
11 | ProcessID uint32
12 | SecretKey uint32
13 | }
14 |
15 | // Backend identifies this message as sendable by the PostgreSQL backend.
16 | func (*BackendKeyData) Backend() {}
17 |
18 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
19 | // type identifier and 4 byte message length.
20 | func (dst *BackendKeyData) Decode(src []byte) error {
21 | if len(src) != 8 {
22 | return &invalidMessageLenErr{messageType: "BackendKeyData", expectedLen: 8, actualLen: len(src)}
23 | }
24 |
25 | dst.ProcessID = binary.BigEndian.Uint32(src[:4])
26 | dst.SecretKey = binary.BigEndian.Uint32(src[4:])
27 |
28 | return nil
29 | }
30 |
31 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
32 | func (src *BackendKeyData) Encode(dst []byte) ([]byte, error) {
33 | dst, sp := beginMessage(dst, 'K')
34 | dst = pgio.AppendUint32(dst, src.ProcessID)
35 | dst = pgio.AppendUint32(dst, src.SecretKey)
36 | return finishMessage(dst, sp)
37 | }
38 |
39 | // MarshalJSON implements encoding/json.Marshaler.
40 | func (src BackendKeyData) MarshalJSON() ([]byte, error) {
41 | return json.Marshal(struct {
42 | Type string
43 | ProcessID uint32
44 | SecretKey uint32
45 | }{
46 | Type: "BackendKeyData",
47 | ProcessID: src.ProcessID,
48 | SecretKey: src.SecretKey,
49 | })
50 | }
51 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/big_endian.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | )
6 |
7 | type BigEndianBuf [8]byte
8 |
9 | func (b BigEndianBuf) Int16(n int16) []byte {
10 | buf := b[0:2]
11 | binary.BigEndian.PutUint16(buf, uint16(n))
12 | return buf
13 | }
14 |
15 | func (b BigEndianBuf) Uint16(n uint16) []byte {
16 | buf := b[0:2]
17 | binary.BigEndian.PutUint16(buf, n)
18 | return buf
19 | }
20 |
21 | func (b BigEndianBuf) Int32(n int32) []byte {
22 | buf := b[0:4]
23 | binary.BigEndian.PutUint32(buf, uint32(n))
24 | return buf
25 | }
26 |
27 | func (b BigEndianBuf) Uint32(n uint32) []byte {
28 | buf := b[0:4]
29 | binary.BigEndian.PutUint32(buf, n)
30 | return buf
31 | }
32 |
33 | func (b BigEndianBuf) Int64(n int64) []byte {
34 | buf := b[0:8]
35 | binary.BigEndian.PutUint64(buf, uint64(n))
36 | return buf
37 | }
38 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/bind_complete.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type BindComplete struct{}
8 |
9 | // Backend identifies this message as sendable by the PostgreSQL backend.
10 | func (*BindComplete) Backend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *BindComplete) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "BindComplete", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *BindComplete) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, '2', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src BindComplete) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "BindComplete",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/cancel_request.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 | "errors"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | const cancelRequestCode = 80877102
12 |
13 | type CancelRequest struct {
14 | ProcessID uint32
15 | SecretKey uint32
16 | }
17 |
18 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
19 | func (*CancelRequest) Frontend() {}
20 |
21 | func (dst *CancelRequest) Decode(src []byte) error {
22 | if len(src) != 12 {
23 | return errors.New("bad cancel request size")
24 | }
25 |
26 | requestCode := binary.BigEndian.Uint32(src)
27 |
28 | if requestCode != cancelRequestCode {
29 | return errors.New("bad cancel request code")
30 | }
31 |
32 | dst.ProcessID = binary.BigEndian.Uint32(src[4:])
33 | dst.SecretKey = binary.BigEndian.Uint32(src[8:])
34 |
35 | return nil
36 | }
37 |
38 | // Encode encodes src into dst. dst will include the 4 byte message length.
39 | func (src *CancelRequest) Encode(dst []byte) ([]byte, error) {
40 | dst = pgio.AppendInt32(dst, 16)
41 | dst = pgio.AppendInt32(dst, cancelRequestCode)
42 | dst = pgio.AppendUint32(dst, src.ProcessID)
43 | dst = pgio.AppendUint32(dst, src.SecretKey)
44 | return dst, nil
45 | }
46 |
47 | // MarshalJSON implements encoding/json.Marshaler.
48 | func (src CancelRequest) MarshalJSON() ([]byte, error) {
49 | return json.Marshal(struct {
50 | Type string
51 | ProcessID uint32
52 | SecretKey uint32
53 | }{
54 | Type: "CancelRequest",
55 | ProcessID: src.ProcessID,
56 | SecretKey: src.SecretKey,
57 | })
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/close_complete.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type CloseComplete struct{}
8 |
9 | // Backend identifies this message as sendable by the PostgreSQL backend.
10 | func (*CloseComplete) Backend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *CloseComplete) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "CloseComplete", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *CloseComplete) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, '3', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src CloseComplete) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "CloseComplete",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/command_complete.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | )
7 |
8 | type CommandComplete struct {
9 | CommandTag []byte
10 | }
11 |
12 | // Backend identifies this message as sendable by the PostgreSQL backend.
13 | func (*CommandComplete) Backend() {}
14 |
15 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
16 | // type identifier and 4 byte message length.
17 | func (dst *CommandComplete) Decode(src []byte) error {
18 | idx := bytes.IndexByte(src, 0)
19 | if idx == -1 {
20 | return &invalidMessageFormatErr{messageType: "CommandComplete", details: "unterminated string"}
21 | }
22 | if idx != len(src)-1 {
23 | return &invalidMessageFormatErr{messageType: "CommandComplete", details: "string terminated too early"}
24 | }
25 |
26 | dst.CommandTag = src[:idx]
27 |
28 | return nil
29 | }
30 |
31 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
32 | func (src *CommandComplete) Encode(dst []byte) ([]byte, error) {
33 | dst, sp := beginMessage(dst, 'C')
34 | dst = append(dst, src.CommandTag...)
35 | dst = append(dst, 0)
36 | return finishMessage(dst, sp)
37 | }
38 |
39 | // MarshalJSON implements encoding/json.Marshaler.
40 | func (src CommandComplete) MarshalJSON() ([]byte, error) {
41 | return json.Marshal(struct {
42 | Type string
43 | CommandTag string
44 | }{
45 | Type: "CommandComplete",
46 | CommandTag: string(src.CommandTag),
47 | })
48 | }
49 |
50 | // UnmarshalJSON implements encoding/json.Unmarshaler.
51 | func (dst *CommandComplete) UnmarshalJSON(data []byte) error {
52 | // Ignore null, like in the main JSON package.
53 | if string(data) == "null" {
54 | return nil
55 | }
56 |
57 | var msg struct {
58 | CommandTag string
59 | }
60 | if err := json.Unmarshal(data, &msg); err != nil {
61 | return err
62 | }
63 |
64 | dst.CommandTag = []byte(msg.CommandTag)
65 | return nil
66 | }
67 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/copy_data.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/hex"
5 | "encoding/json"
6 | )
7 |
8 | type CopyData struct {
9 | Data []byte
10 | }
11 |
12 | // Backend identifies this message as sendable by the PostgreSQL backend.
13 | func (*CopyData) Backend() {}
14 |
15 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
16 | func (*CopyData) Frontend() {}
17 |
18 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
19 | // type identifier and 4 byte message length.
20 | func (dst *CopyData) Decode(src []byte) error {
21 | dst.Data = src
22 | return nil
23 | }
24 |
25 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
26 | func (src *CopyData) Encode(dst []byte) ([]byte, error) {
27 | dst, sp := beginMessage(dst, 'd')
28 | dst = append(dst, src.Data...)
29 | return finishMessage(dst, sp)
30 | }
31 |
32 | // MarshalJSON implements encoding/json.Marshaler.
33 | func (src CopyData) MarshalJSON() ([]byte, error) {
34 | return json.Marshal(struct {
35 | Type string
36 | Data string
37 | }{
38 | Type: "CopyData",
39 | Data: hex.EncodeToString(src.Data),
40 | })
41 | }
42 |
43 | // UnmarshalJSON implements encoding/json.Unmarshaler.
44 | func (dst *CopyData) UnmarshalJSON(data []byte) error {
45 | // Ignore null, like in the main JSON package.
46 | if string(data) == "null" {
47 | return nil
48 | }
49 |
50 | var msg struct {
51 | Data string
52 | }
53 | if err := json.Unmarshal(data, &msg); err != nil {
54 | return err
55 | }
56 |
57 | dst.Data = []byte(msg.Data)
58 | return nil
59 | }
60 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/copy_done.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type CopyDone struct {
8 | }
9 |
10 | // Backend identifies this message as sendable by the PostgreSQL backend.
11 | func (*CopyDone) Backend() {}
12 |
13 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
14 | func (*CopyDone) Frontend() {}
15 |
16 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
17 | // type identifier and 4 byte message length.
18 | func (dst *CopyDone) Decode(src []byte) error {
19 | if len(src) != 0 {
20 | return &invalidMessageLenErr{messageType: "CopyDone", expectedLen: 0, actualLen: len(src)}
21 | }
22 |
23 | return nil
24 | }
25 |
26 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
27 | func (src *CopyDone) Encode(dst []byte) ([]byte, error) {
28 | return append(dst, 'c', 0, 0, 0, 4), nil
29 | }
30 |
31 | // MarshalJSON implements encoding/json.Marshaler.
32 | func (src CopyDone) MarshalJSON() ([]byte, error) {
33 | return json.Marshal(struct {
34 | Type string
35 | }{
36 | Type: "CopyDone",
37 | })
38 | }
39 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/copy_fail.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | )
7 |
8 | type CopyFail struct {
9 | Message string
10 | }
11 |
12 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
13 | func (*CopyFail) Frontend() {}
14 |
15 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
16 | // type identifier and 4 byte message length.
17 | func (dst *CopyFail) Decode(src []byte) error {
18 | idx := bytes.IndexByte(src, 0)
19 | if idx != len(src)-1 {
20 | return &invalidMessageFormatErr{messageType: "CopyFail"}
21 | }
22 |
23 | dst.Message = string(src[:idx])
24 |
25 | return nil
26 | }
27 |
28 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
29 | func (src *CopyFail) Encode(dst []byte) ([]byte, error) {
30 | dst, sp := beginMessage(dst, 'f')
31 | dst = append(dst, src.Message...)
32 | dst = append(dst, 0)
33 | return finishMessage(dst, sp)
34 | }
35 |
36 | // MarshalJSON implements encoding/json.Marshaler.
37 | func (src CopyFail) MarshalJSON() ([]byte, error) {
38 | return json.Marshal(struct {
39 | Type string
40 | Message string
41 | }{
42 | Type: "CopyFail",
43 | Message: src.Message,
44 | })
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/doc.go:
--------------------------------------------------------------------------------
1 | // Package pgproto3 is an encoder and decoder of the PostgreSQL wire protocol version 3.
2 | //
3 | // The primary interfaces are Frontend and Backend. They correspond to a client and server respectively. Messages are
4 | // sent with Send (or a specialized Send variant). Messages are automatically buffered to minimize small writes. Call
5 | // Flush to ensure a message has actually been sent.
6 | //
7 | // The Trace method of Frontend and Backend can be used to examine the wire-level message traffic. It outputs in a
8 | // similar format to the PQtrace function in libpq.
9 | //
10 | // See https://www.postgresql.org/docs/current/protocol-message-formats.html for meanings of the different messages.
11 | package pgproto3
12 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/empty_query_response.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type EmptyQueryResponse struct{}
8 |
9 | // Backend identifies this message as sendable by the PostgreSQL backend.
10 | func (*EmptyQueryResponse) Backend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *EmptyQueryResponse) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "EmptyQueryResponse", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *EmptyQueryResponse) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, 'I', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src EmptyQueryResponse) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "EmptyQueryResponse",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/execute.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/binary"
6 | "encoding/json"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | type Execute struct {
12 | Portal string
13 | MaxRows uint32
14 | }
15 |
16 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
17 | func (*Execute) Frontend() {}
18 |
19 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
20 | // type identifier and 4 byte message length.
21 | func (dst *Execute) Decode(src []byte) error {
22 | buf := bytes.NewBuffer(src)
23 |
24 | b, err := buf.ReadBytes(0)
25 | if err != nil {
26 | return err
27 | }
28 | dst.Portal = string(b[:len(b)-1])
29 |
30 | if buf.Len() < 4 {
31 | return &invalidMessageFormatErr{messageType: "Execute"}
32 | }
33 | dst.MaxRows = binary.BigEndian.Uint32(buf.Next(4))
34 |
35 | return nil
36 | }
37 |
38 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
39 | func (src *Execute) Encode(dst []byte) ([]byte, error) {
40 | dst, sp := beginMessage(dst, 'E')
41 | dst = append(dst, src.Portal...)
42 | dst = append(dst, 0)
43 | dst = pgio.AppendUint32(dst, src.MaxRows)
44 | return finishMessage(dst, sp)
45 | }
46 |
47 | // MarshalJSON implements encoding/json.Marshaler.
48 | func (src Execute) MarshalJSON() ([]byte, error) {
49 | return json.Marshal(struct {
50 | Type string
51 | Portal string
52 | MaxRows uint32
53 | }{
54 | Type: "Execute",
55 | Portal: src.Portal,
56 | MaxRows: src.MaxRows,
57 | })
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/flush.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type Flush struct{}
8 |
9 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
10 | func (*Flush) Frontend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *Flush) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "Flush", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *Flush) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, 'H', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src Flush) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "Flush",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/gss_enc_request.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 | "errors"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | const gssEncReqNumber = 80877104
12 |
13 | type GSSEncRequest struct {
14 | }
15 |
16 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
17 | func (*GSSEncRequest) Frontend() {}
18 |
19 | func (dst *GSSEncRequest) Decode(src []byte) error {
20 | if len(src) < 4 {
21 | return errors.New("gss encoding request too short")
22 | }
23 |
24 | requestCode := binary.BigEndian.Uint32(src)
25 |
26 | if requestCode != gssEncReqNumber {
27 | return errors.New("bad gss encoding request code")
28 | }
29 |
30 | return nil
31 | }
32 |
33 | // Encode encodes src into dst. dst will include the 4 byte message length.
34 | func (src *GSSEncRequest) Encode(dst []byte) ([]byte, error) {
35 | dst = pgio.AppendInt32(dst, 8)
36 | dst = pgio.AppendInt32(dst, gssEncReqNumber)
37 | return dst, nil
38 | }
39 |
40 | // MarshalJSON implements encoding/json.Marshaler.
41 | func (src GSSEncRequest) MarshalJSON() ([]byte, error) {
42 | return json.Marshal(struct {
43 | Type string
44 | ProtocolVersion uint32
45 | Parameters map[string]string
46 | }{
47 | Type: "GSSEncRequest",
48 | })
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/gss_response.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type GSSResponse struct {
8 | Data []byte
9 | }
10 |
11 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
12 | func (g *GSSResponse) Frontend() {}
13 |
14 | func (g *GSSResponse) Decode(data []byte) error {
15 | g.Data = data
16 | return nil
17 | }
18 |
19 | func (g *GSSResponse) Encode(dst []byte) ([]byte, error) {
20 | dst, sp := beginMessage(dst, 'p')
21 | dst = append(dst, g.Data...)
22 | return finishMessage(dst, sp)
23 | }
24 |
25 | // MarshalJSON implements encoding/json.Marshaler.
26 | func (g *GSSResponse) MarshalJSON() ([]byte, error) {
27 | return json.Marshal(struct {
28 | Type string
29 | Data []byte
30 | }{
31 | Type: "GSSResponse",
32 | Data: g.Data,
33 | })
34 | }
35 |
36 | // UnmarshalJSON implements encoding/json.Unmarshaler.
37 | func (g *GSSResponse) UnmarshalJSON(data []byte) error {
38 | var msg struct {
39 | Data []byte
40 | }
41 | if err := json.Unmarshal(data, &msg); err != nil {
42 | return err
43 | }
44 | g.Data = msg.Data
45 | return nil
46 | }
47 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/no_data.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type NoData struct{}
8 |
9 | // Backend identifies this message as sendable by the PostgreSQL backend.
10 | func (*NoData) Backend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *NoData) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "NoData", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *NoData) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, 'n', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src NoData) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "NoData",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/notice_response.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | type NoticeResponse ErrorResponse
4 |
5 | // Backend identifies this message as sendable by the PostgreSQL backend.
6 | func (*NoticeResponse) Backend() {}
7 |
8 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
9 | // type identifier and 4 byte message length.
10 | func (dst *NoticeResponse) Decode(src []byte) error {
11 | return (*ErrorResponse)(dst).Decode(src)
12 | }
13 |
14 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
15 | func (src *NoticeResponse) Encode(dst []byte) ([]byte, error) {
16 | dst, sp := beginMessage(dst, 'N')
17 | dst = (*ErrorResponse)(src).appendFields(dst)
18 | return finishMessage(dst, sp)
19 | }
20 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/notification_response.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/binary"
6 | "encoding/json"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | type NotificationResponse struct {
12 | PID uint32
13 | Channel string
14 | Payload string
15 | }
16 |
17 | // Backend identifies this message as sendable by the PostgreSQL backend.
18 | func (*NotificationResponse) Backend() {}
19 |
20 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
21 | // type identifier and 4 byte message length.
22 | func (dst *NotificationResponse) Decode(src []byte) error {
23 | buf := bytes.NewBuffer(src)
24 |
25 | if buf.Len() < 4 {
26 | return &invalidMessageFormatErr{messageType: "NotificationResponse", details: "too short"}
27 | }
28 |
29 | pid := binary.BigEndian.Uint32(buf.Next(4))
30 |
31 | b, err := buf.ReadBytes(0)
32 | if err != nil {
33 | return err
34 | }
35 | channel := string(b[:len(b)-1])
36 |
37 | b, err = buf.ReadBytes(0)
38 | if err != nil {
39 | return err
40 | }
41 | payload := string(b[:len(b)-1])
42 |
43 | *dst = NotificationResponse{PID: pid, Channel: channel, Payload: payload}
44 | return nil
45 | }
46 |
47 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
48 | func (src *NotificationResponse) Encode(dst []byte) ([]byte, error) {
49 | dst, sp := beginMessage(dst, 'A')
50 | dst = pgio.AppendUint32(dst, src.PID)
51 | dst = append(dst, src.Channel...)
52 | dst = append(dst, 0)
53 | dst = append(dst, src.Payload...)
54 | dst = append(dst, 0)
55 | return finishMessage(dst, sp)
56 | }
57 |
58 | // MarshalJSON implements encoding/json.Marshaler.
59 | func (src NotificationResponse) MarshalJSON() ([]byte, error) {
60 | return json.Marshal(struct {
61 | Type string
62 | PID uint32
63 | Channel string
64 | Payload string
65 | }{
66 | Type: "NotificationResponse",
67 | PID: src.PID,
68 | Channel: src.Channel,
69 | Payload: src.Payload,
70 | })
71 | }
72 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/parameter_description.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/binary"
6 | "encoding/json"
7 | "errors"
8 | "math"
9 |
10 | "github.com/jackc/pgx/v5/internal/pgio"
11 | )
12 |
13 | type ParameterDescription struct {
14 | ParameterOIDs []uint32
15 | }
16 |
17 | // Backend identifies this message as sendable by the PostgreSQL backend.
18 | func (*ParameterDescription) Backend() {}
19 |
20 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
21 | // type identifier and 4 byte message length.
22 | func (dst *ParameterDescription) Decode(src []byte) error {
23 | buf := bytes.NewBuffer(src)
24 |
25 | if buf.Len() < 2 {
26 | return &invalidMessageFormatErr{messageType: "ParameterDescription"}
27 | }
28 |
29 | // Reported parameter count will be incorrect when number of args is greater than uint16
30 | buf.Next(2)
31 | // Instead infer parameter count by remaining size of message
32 | parameterCount := buf.Len() / 4
33 |
34 | *dst = ParameterDescription{ParameterOIDs: make([]uint32, parameterCount)}
35 |
36 | for i := 0; i < parameterCount; i++ {
37 | dst.ParameterOIDs[i] = binary.BigEndian.Uint32(buf.Next(4))
38 | }
39 |
40 | return nil
41 | }
42 |
43 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
44 | func (src *ParameterDescription) Encode(dst []byte) ([]byte, error) {
45 | dst, sp := beginMessage(dst, 't')
46 |
47 | if len(src.ParameterOIDs) > math.MaxUint16 {
48 | return nil, errors.New("too many parameter oids")
49 | }
50 | dst = pgio.AppendUint16(dst, uint16(len(src.ParameterOIDs)))
51 | for _, oid := range src.ParameterOIDs {
52 | dst = pgio.AppendUint32(dst, oid)
53 | }
54 |
55 | return finishMessage(dst, sp)
56 | }
57 |
58 | // MarshalJSON implements encoding/json.Marshaler.
59 | func (src ParameterDescription) MarshalJSON() ([]byte, error) {
60 | return json.Marshal(struct {
61 | Type string
62 | ParameterOIDs []uint32
63 | }{
64 | Type: "ParameterDescription",
65 | ParameterOIDs: src.ParameterOIDs,
66 | })
67 | }
68 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/parameter_status.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | )
7 |
8 | type ParameterStatus struct {
9 | Name string
10 | Value string
11 | }
12 |
13 | // Backend identifies this message as sendable by the PostgreSQL backend.
14 | func (*ParameterStatus) Backend() {}
15 |
16 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
17 | // type identifier and 4 byte message length.
18 | func (dst *ParameterStatus) Decode(src []byte) error {
19 | buf := bytes.NewBuffer(src)
20 |
21 | b, err := buf.ReadBytes(0)
22 | if err != nil {
23 | return err
24 | }
25 | name := string(b[:len(b)-1])
26 |
27 | b, err = buf.ReadBytes(0)
28 | if err != nil {
29 | return err
30 | }
31 | value := string(b[:len(b)-1])
32 |
33 | *dst = ParameterStatus{Name: name, Value: value}
34 | return nil
35 | }
36 |
37 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
38 | func (src *ParameterStatus) Encode(dst []byte) ([]byte, error) {
39 | dst, sp := beginMessage(dst, 'S')
40 | dst = append(dst, src.Name...)
41 | dst = append(dst, 0)
42 | dst = append(dst, src.Value...)
43 | dst = append(dst, 0)
44 | return finishMessage(dst, sp)
45 | }
46 |
47 | // MarshalJSON implements encoding/json.Marshaler.
48 | func (ps ParameterStatus) MarshalJSON() ([]byte, error) {
49 | return json.Marshal(struct {
50 | Type string
51 | Name string
52 | Value string
53 | }{
54 | Type: "ParameterStatus",
55 | Name: ps.Name,
56 | Value: ps.Value,
57 | })
58 | }
59 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/parse_complete.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type ParseComplete struct{}
8 |
9 | // Backend identifies this message as sendable by the PostgreSQL backend.
10 | func (*ParseComplete) Backend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *ParseComplete) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "ParseComplete", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *ParseComplete) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, '1', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src ParseComplete) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "ParseComplete",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/password_message.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | )
7 |
8 | type PasswordMessage struct {
9 | Password string
10 | }
11 |
12 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
13 | func (*PasswordMessage) Frontend() {}
14 |
15 | // InitialResponse identifies this message as an authentication response.
16 | func (*PasswordMessage) InitialResponse() {}
17 |
18 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
19 | // type identifier and 4 byte message length.
20 | func (dst *PasswordMessage) Decode(src []byte) error {
21 | buf := bytes.NewBuffer(src)
22 |
23 | b, err := buf.ReadBytes(0)
24 | if err != nil {
25 | return err
26 | }
27 | dst.Password = string(b[:len(b)-1])
28 |
29 | return nil
30 | }
31 |
32 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
33 | func (src *PasswordMessage) Encode(dst []byte) ([]byte, error) {
34 | dst, sp := beginMessage(dst, 'p')
35 | dst = append(dst, src.Password...)
36 | dst = append(dst, 0)
37 | return finishMessage(dst, sp)
38 | }
39 |
40 | // MarshalJSON implements encoding/json.Marshaler.
41 | func (src PasswordMessage) MarshalJSON() ([]byte, error) {
42 | return json.Marshal(struct {
43 | Type string
44 | Password string
45 | }{
46 | Type: "PasswordMessage",
47 | Password: src.Password,
48 | })
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/portal_suspended.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type PortalSuspended struct{}
8 |
9 | // Backend identifies this message as sendable by the PostgreSQL backend.
10 | func (*PortalSuspended) Backend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *PortalSuspended) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "PortalSuspended", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *PortalSuspended) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, 's', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src PortalSuspended) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "PortalSuspended",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/query.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "bytes"
5 | "encoding/json"
6 | )
7 |
8 | type Query struct {
9 | String string
10 | }
11 |
12 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
13 | func (*Query) Frontend() {}
14 |
15 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
16 | // type identifier and 4 byte message length.
17 | func (dst *Query) Decode(src []byte) error {
18 | i := bytes.IndexByte(src, 0)
19 | if i != len(src)-1 {
20 | return &invalidMessageFormatErr{messageType: "Query"}
21 | }
22 |
23 | dst.String = string(src[:i])
24 |
25 | return nil
26 | }
27 |
28 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
29 | func (src *Query) Encode(dst []byte) ([]byte, error) {
30 | dst, sp := beginMessage(dst, 'Q')
31 | dst = append(dst, src.String...)
32 | dst = append(dst, 0)
33 | return finishMessage(dst, sp)
34 | }
35 |
36 | // MarshalJSON implements encoding/json.Marshaler.
37 | func (src Query) MarshalJSON() ([]byte, error) {
38 | return json.Marshal(struct {
39 | Type string
40 | String string
41 | }{
42 | Type: "Query",
43 | String: src.String,
44 | })
45 | }
46 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/ready_for_query.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | "errors"
6 | )
7 |
8 | type ReadyForQuery struct {
9 | TxStatus byte
10 | }
11 |
12 | // Backend identifies this message as sendable by the PostgreSQL backend.
13 | func (*ReadyForQuery) Backend() {}
14 |
15 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
16 | // type identifier and 4 byte message length.
17 | func (dst *ReadyForQuery) Decode(src []byte) error {
18 | if len(src) != 1 {
19 | return &invalidMessageLenErr{messageType: "ReadyForQuery", expectedLen: 1, actualLen: len(src)}
20 | }
21 |
22 | dst.TxStatus = src[0]
23 |
24 | return nil
25 | }
26 |
27 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
28 | func (src *ReadyForQuery) Encode(dst []byte) ([]byte, error) {
29 | return append(dst, 'Z', 0, 0, 0, 5, src.TxStatus), nil
30 | }
31 |
32 | // MarshalJSON implements encoding/json.Marshaler.
33 | func (src ReadyForQuery) MarshalJSON() ([]byte, error) {
34 | return json.Marshal(struct {
35 | Type string
36 | TxStatus string
37 | }{
38 | Type: "ReadyForQuery",
39 | TxStatus: string(src.TxStatus),
40 | })
41 | }
42 |
43 | // UnmarshalJSON implements encoding/json.Unmarshaler.
44 | func (dst *ReadyForQuery) UnmarshalJSON(data []byte) error {
45 | // Ignore null, like in the main JSON package.
46 | if string(data) == "null" {
47 | return nil
48 | }
49 |
50 | var msg struct {
51 | TxStatus string
52 | }
53 | if err := json.Unmarshal(data, &msg); err != nil {
54 | return err
55 | }
56 | if len(msg.TxStatus) != 1 {
57 | return errors.New("invalid length for ReadyForQuery.TxStatus")
58 | }
59 | dst.TxStatus = msg.TxStatus[0]
60 | return nil
61 | }
62 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/sasl_response.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/hex"
5 | "encoding/json"
6 | )
7 |
8 | type SASLResponse struct {
9 | Data []byte
10 | }
11 |
12 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
13 | func (*SASLResponse) Frontend() {}
14 |
15 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
16 | // type identifier and 4 byte message length.
17 | func (dst *SASLResponse) Decode(src []byte) error {
18 | *dst = SASLResponse{Data: src}
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *SASLResponse) Encode(dst []byte) ([]byte, error) {
24 | dst, sp := beginMessage(dst, 'p')
25 | dst = append(dst, src.Data...)
26 | return finishMessage(dst, sp)
27 | }
28 |
29 | // MarshalJSON implements encoding/json.Marshaler.
30 | func (src SASLResponse) MarshalJSON() ([]byte, error) {
31 | return json.Marshal(struct {
32 | Type string
33 | Data string
34 | }{
35 | Type: "SASLResponse",
36 | Data: string(src.Data),
37 | })
38 | }
39 |
40 | // UnmarshalJSON implements encoding/json.Unmarshaler.
41 | func (dst *SASLResponse) UnmarshalJSON(data []byte) error {
42 | var msg struct {
43 | Data string
44 | }
45 | if err := json.Unmarshal(data, &msg); err != nil {
46 | return err
47 | }
48 | if msg.Data != "" {
49 | decoded, err := hex.DecodeString(msg.Data)
50 | if err != nil {
51 | return err
52 | }
53 | dst.Data = decoded
54 | }
55 | return nil
56 | }
57 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/ssl_request.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/binary"
5 | "encoding/json"
6 | "errors"
7 |
8 | "github.com/jackc/pgx/v5/internal/pgio"
9 | )
10 |
11 | const sslRequestNumber = 80877103
12 |
13 | type SSLRequest struct {
14 | }
15 |
16 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
17 | func (*SSLRequest) Frontend() {}
18 |
19 | func (dst *SSLRequest) Decode(src []byte) error {
20 | if len(src) < 4 {
21 | return errors.New("ssl request too short")
22 | }
23 |
24 | requestCode := binary.BigEndian.Uint32(src)
25 |
26 | if requestCode != sslRequestNumber {
27 | return errors.New("bad ssl request code")
28 | }
29 |
30 | return nil
31 | }
32 |
33 | // Encode encodes src into dst. dst will include the 4 byte message length.
34 | func (src *SSLRequest) Encode(dst []byte) ([]byte, error) {
35 | dst = pgio.AppendInt32(dst, 8)
36 | dst = pgio.AppendInt32(dst, sslRequestNumber)
37 | return dst, nil
38 | }
39 |
40 | // MarshalJSON implements encoding/json.Marshaler.
41 | func (src SSLRequest) MarshalJSON() ([]byte, error) {
42 | return json.Marshal(struct {
43 | Type string
44 | ProtocolVersion uint32
45 | Parameters map[string]string
46 | }{
47 | Type: "SSLRequest",
48 | })
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/sync.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type Sync struct{}
8 |
9 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
10 | func (*Sync) Frontend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *Sync) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "Sync", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *Sync) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, 'S', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src Sync) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "Sync",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgproto3/terminate.go:
--------------------------------------------------------------------------------
1 | package pgproto3
2 |
3 | import (
4 | "encoding/json"
5 | )
6 |
7 | type Terminate struct{}
8 |
9 | // Frontend identifies this message as sendable by a PostgreSQL frontend.
10 | func (*Terminate) Frontend() {}
11 |
12 | // Decode decodes src into dst. src must contain the complete message with the exception of the initial 1 byte message
13 | // type identifier and 4 byte message length.
14 | func (dst *Terminate) Decode(src []byte) error {
15 | if len(src) != 0 {
16 | return &invalidMessageLenErr{messageType: "Terminate", expectedLen: 0, actualLen: len(src)}
17 | }
18 |
19 | return nil
20 | }
21 |
22 | // Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.
23 | func (src *Terminate) Encode(dst []byte) ([]byte, error) {
24 | return append(dst, 'X', 0, 0, 0, 4), nil
25 | }
26 |
27 | // MarshalJSON implements encoding/json.Marshaler.
28 | func (src Terminate) MarshalJSON() ([]byte, error) {
29 | return json.Marshal(struct {
30 | Type string
31 | }{
32 | Type: "Terminate",
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgtype/integration_benchmark_test_gen.sh:
--------------------------------------------------------------------------------
1 | erb integration_benchmark_test.go.erb > integration_benchmark_test.go
2 | goimports -w integration_benchmark_test.go
3 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgtype/register_default_pg_types.go:
--------------------------------------------------------------------------------
1 | //go:build !nopgxregisterdefaulttypes
2 |
3 | package pgtype
4 |
5 | func registerDefaultPgTypeVariants[T any](m *Map, name string) {
6 | arrayName := "_" + name
7 |
8 | var value T
9 | m.RegisterDefaultPgType(value, name) // T
10 | m.RegisterDefaultPgType(&value, name) // *T
11 |
12 | var sliceT []T
13 | m.RegisterDefaultPgType(sliceT, arrayName) // []T
14 | m.RegisterDefaultPgType(&sliceT, arrayName) // *[]T
15 |
16 | var slicePtrT []*T
17 | m.RegisterDefaultPgType(slicePtrT, arrayName) // []*T
18 | m.RegisterDefaultPgType(&slicePtrT, arrayName) // *[]*T
19 |
20 | var arrayOfT Array[T]
21 | m.RegisterDefaultPgType(arrayOfT, arrayName) // Array[T]
22 | m.RegisterDefaultPgType(&arrayOfT, arrayName) // *Array[T]
23 |
24 | var arrayOfPtrT Array[*T]
25 | m.RegisterDefaultPgType(arrayOfPtrT, arrayName) // Array[*T]
26 | m.RegisterDefaultPgType(&arrayOfPtrT, arrayName) // *Array[*T]
27 |
28 | var flatArrayOfT FlatArray[T]
29 | m.RegisterDefaultPgType(flatArrayOfT, arrayName) // FlatArray[T]
30 | m.RegisterDefaultPgType(&flatArrayOfT, arrayName) // *FlatArray[T]
31 |
32 | var flatArrayOfPtrT FlatArray[*T]
33 | m.RegisterDefaultPgType(flatArrayOfPtrT, arrayName) // FlatArray[*T]
34 | m.RegisterDefaultPgType(&flatArrayOfPtrT, arrayName) // *FlatArray[*T]
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgtype/register_default_pg_types_disabled.go:
--------------------------------------------------------------------------------
1 | //go:build nopgxregisterdefaulttypes
2 |
3 | package pgtype
4 |
5 | func registerDefaultPgTypeVariants[T any](m *Map, name string) {
6 | }
7 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgtype/text_format_only_codec.go:
--------------------------------------------------------------------------------
1 | package pgtype
2 |
3 | type TextFormatOnlyCodec struct {
4 | Codec
5 | }
6 |
7 | func (c *TextFormatOnlyCodec) FormatSupported(format int16) bool {
8 | return format == TextFormatCode && c.Codec.FormatSupported(format)
9 | }
10 |
11 | func (TextFormatOnlyCodec) PreferredFormat() int16 {
12 | return TextFormatCode
13 | }
14 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgxpool/batch_results.go:
--------------------------------------------------------------------------------
1 | package pgxpool
2 |
3 | import (
4 | "github.com/jackc/pgx/v5"
5 | "github.com/jackc/pgx/v5/pgconn"
6 | )
7 |
8 | type errBatchResults struct {
9 | err error
10 | }
11 |
12 | func (br errBatchResults) Exec() (pgconn.CommandTag, error) {
13 | return pgconn.CommandTag{}, br.err
14 | }
15 |
16 | func (br errBatchResults) Query() (pgx.Rows, error) {
17 | return errRows{err: br.err}, br.err
18 | }
19 |
20 | func (br errBatchResults) QueryRow() pgx.Row {
21 | return errRow{err: br.err}
22 | }
23 |
24 | func (br errBatchResults) Close() error {
25 | return br.err
26 | }
27 |
28 | type poolBatchResults struct {
29 | br pgx.BatchResults
30 | c *Conn
31 | }
32 |
33 | func (br *poolBatchResults) Exec() (pgconn.CommandTag, error) {
34 | return br.br.Exec()
35 | }
36 |
37 | func (br *poolBatchResults) Query() (pgx.Rows, error) {
38 | return br.br.Query()
39 | }
40 |
41 | func (br *poolBatchResults) QueryRow() pgx.Row {
42 | return br.br.QueryRow()
43 | }
44 |
45 | func (br *poolBatchResults) Close() error {
46 | err := br.br.Close()
47 | if br.c != nil {
48 | br.c.Release()
49 | br.c = nil
50 | }
51 | return err
52 | }
53 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgxpool/doc.go:
--------------------------------------------------------------------------------
1 | // Package pgxpool is a concurrency-safe connection pool for pgx.
2 | /*
3 | pgxpool implements a nearly identical interface to pgx connections.
4 |
5 | Creating a Pool
6 |
7 | The primary way of creating a pool is with [pgxpool.New]:
8 |
9 | pool, err := pgxpool.New(context.Background(), os.Getenv("DATABASE_URL"))
10 |
11 | The database connection string can be in URL or keyword/value format. PostgreSQL settings, pgx settings, and pool settings can be
12 | specified here. In addition, a config struct can be created by [ParseConfig].
13 |
14 | config, err := pgxpool.ParseConfig(os.Getenv("DATABASE_URL"))
15 | if err != nil {
16 | // ...
17 | }
18 | config.AfterConnect = func(ctx context.Context, conn *pgx.Conn) error {
19 | // do something with every new connection
20 | }
21 |
22 | pool, err := pgxpool.NewWithConfig(context.Background(), config)
23 |
24 | A pool returns without waiting for any connections to be established. Acquire a connection immediately after creating
25 | the pool to check if a connection can successfully be established.
26 | */
27 | package pgxpool
28 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/pgxpool/tracer.go:
--------------------------------------------------------------------------------
1 | package pgxpool
2 |
3 | import (
4 | "context"
5 |
6 | "github.com/jackc/pgx/v5"
7 | )
8 |
9 | // AcquireTracer traces Acquire.
10 | type AcquireTracer interface {
11 | // TraceAcquireStart is called at the beginning of Acquire.
12 | // The returned context is used for the rest of the call and will be passed to the TraceAcquireEnd.
13 | TraceAcquireStart(ctx context.Context, pool *Pool, data TraceAcquireStartData) context.Context
14 | // TraceAcquireEnd is called when a connection has been acquired.
15 | TraceAcquireEnd(ctx context.Context, pool *Pool, data TraceAcquireEndData)
16 | }
17 |
18 | type TraceAcquireStartData struct{}
19 |
20 | type TraceAcquireEndData struct {
21 | Conn *pgx.Conn
22 | Err error
23 | }
24 |
25 | // ReleaseTracer traces Release.
26 | type ReleaseTracer interface {
27 | // TraceRelease is called at the beginning of Release.
28 | TraceRelease(pool *Pool, data TraceReleaseData)
29 | }
30 |
31 | type TraceReleaseData struct {
32 | Conn *pgx.Conn
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/pgx/v5/values.go:
--------------------------------------------------------------------------------
1 | package pgx
2 |
3 | import (
4 | "errors"
5 |
6 | "github.com/jackc/pgx/v5/internal/pgio"
7 | "github.com/jackc/pgx/v5/pgtype"
8 | )
9 |
10 | // PostgreSQL format codes
11 | const (
12 | TextFormatCode = 0
13 | BinaryFormatCode = 1
14 | )
15 |
16 | func convertSimpleArgument(m *pgtype.Map, arg any) (any, error) {
17 | buf, err := m.Encode(0, TextFormatCode, arg, []byte{})
18 | if err != nil {
19 | return nil, err
20 | }
21 | if buf == nil {
22 | return nil, nil
23 | }
24 | return string(buf), nil
25 | }
26 |
27 | func encodeCopyValue(m *pgtype.Map, buf []byte, oid uint32, arg any) ([]byte, error) {
28 | sp := len(buf)
29 | buf = pgio.AppendInt32(buf, -1)
30 | argBuf, err := m.Encode(oid, BinaryFormatCode, arg, buf)
31 | if err != nil {
32 | if argBuf2, err2 := tryScanStringCopyValueThenEncode(m, buf, oid, arg); err2 == nil {
33 | argBuf = argBuf2
34 | } else {
35 | return nil, err
36 | }
37 | }
38 |
39 | if argBuf != nil {
40 | buf = argBuf
41 | pgio.SetInt32(buf[sp:], int32(len(buf[sp:])-4))
42 | }
43 | return buf, nil
44 | }
45 |
46 | func tryScanStringCopyValueThenEncode(m *pgtype.Map, buf []byte, oid uint32, arg any) ([]byte, error) {
47 | s, ok := arg.(string)
48 | if !ok {
49 | textBuf, err := m.Encode(oid, TextFormatCode, arg, nil)
50 | if err != nil {
51 | return nil, errors.New("not a string and cannot be encoded as text")
52 | }
53 | s = string(textBuf)
54 | }
55 |
56 | var v any
57 | err := m.Scan(oid, TextFormatCode, []byte(s), &v)
58 | if err != nil {
59 | return nil, err
60 | }
61 |
62 | return m.Encode(oid, BinaryFormatCode, v, buf)
63 | }
64 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/puddle/v2/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2018 Jack Christensen
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/puddle/v2/context.go:
--------------------------------------------------------------------------------
1 | package puddle
2 |
3 | import (
4 | "context"
5 | "time"
6 | )
7 |
8 | // valueCancelCtx combines two contexts into one. One context is used for values and the other is used for cancellation.
9 | type valueCancelCtx struct {
10 | valueCtx context.Context
11 | cancelCtx context.Context
12 | }
13 |
14 | func (ctx *valueCancelCtx) Deadline() (time.Time, bool) { return ctx.cancelCtx.Deadline() }
15 | func (ctx *valueCancelCtx) Done() <-chan struct{} { return ctx.cancelCtx.Done() }
16 | func (ctx *valueCancelCtx) Err() error { return ctx.cancelCtx.Err() }
17 | func (ctx *valueCancelCtx) Value(key any) any { return ctx.valueCtx.Value(key) }
18 |
19 | func newValueCancelCtx(valueCtx, cancelContext context.Context) context.Context {
20 | return &valueCancelCtx{
21 | valueCtx: valueCtx,
22 | cancelCtx: cancelContext,
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/puddle/v2/doc.go:
--------------------------------------------------------------------------------
1 | // Package puddle is a generic resource pool with type-parametrized api.
2 | /*
3 |
4 | Puddle is a tiny generic resource pool library for Go that uses the standard
5 | context library to signal cancellation of acquires. It is designed to contain
6 | the minimum functionality a resource pool needs that cannot be implemented
7 | without concurrency concerns. For example, a database connection pool may use
8 | puddle internally and implement health checks and keep-alive behavior without
9 | needing to implement any concurrent code of its own.
10 | */
11 | package puddle
12 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/puddle/v2/internal/genstack/stack.go:
--------------------------------------------------------------------------------
1 | package genstack
2 |
3 | // stack is a wrapper around an array implementing a stack.
4 | //
5 | // We cannot use slice to represent the stack because append might change the
6 | // pointer value of the slice. That would be an issue in GenStack
7 | // implementation.
8 | type stack[T any] struct {
9 | arr []T
10 | }
11 |
12 | // push pushes a new element at the top of a stack.
13 | func (s *stack[T]) push(vs ...T) { s.arr = append(s.arr, vs...) }
14 |
15 | // pop pops the stack top-most element.
16 | //
17 | // If stack length is zero, this method panics.
18 | func (s *stack[T]) pop() T {
19 | idx := s.len() - 1
20 | val := s.arr[idx]
21 |
22 | // Avoid memory leak
23 | var zero T
24 | s.arr[idx] = zero
25 |
26 | s.arr = s.arr[:idx]
27 | return val
28 | }
29 |
30 | // takeAll returns all elements in the stack in order as they are stored - i.e.
31 | // the top-most stack element is the last one.
32 | func (s *stack[T]) takeAll() []T {
33 | arr := s.arr
34 | s.arr = nil
35 | return arr
36 | }
37 |
38 | // len returns number of elements in the stack.
39 | func (s *stack[T]) len() int { return len(s.arr) }
40 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/puddle/v2/log.go:
--------------------------------------------------------------------------------
1 | package puddle
2 |
3 | import "unsafe"
4 |
5 | type ints interface {
6 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64
7 | }
8 |
9 | // log2Int returns log2 of an integer. This function panics if val < 0. For val
10 | // == 0, returns 0.
11 | func log2Int[T ints](val T) uint8 {
12 | if val <= 0 {
13 | panic("log2 of non-positive number does not exist")
14 | }
15 |
16 | return log2IntRange(val, 0, uint8(8*unsafe.Sizeof(val)))
17 | }
18 |
19 | func log2IntRange[T ints](val T, begin, end uint8) uint8 {
20 | length := end - begin
21 | if length == 1 {
22 | return begin
23 | }
24 |
25 | delim := begin + length/2
26 | mask := T(1) << delim
27 | if mask > val {
28 | return log2IntRange(val, begin, delim)
29 | } else {
30 | return log2IntRange(val, delim, end)
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/puddle/v2/nanotime.go:
--------------------------------------------------------------------------------
1 | package puddle
2 |
3 | import "time"
4 |
5 | // nanotime returns the time in nanoseconds since process start.
6 | //
7 | // This approach, described at
8 | // https://github.com/golang/go/issues/61765#issuecomment-1672090302,
9 | // is fast, monotonic, and portable, and avoids the previous
10 | // dependence on runtime.nanotime using the (unsafe) linkname hack.
11 | // In particular, time.Since does less work than time.Now.
12 | func nanotime() int64 {
13 | return time.Since(globalStart).Nanoseconds()
14 | }
15 |
16 | var globalStart = time.Now()
17 |
--------------------------------------------------------------------------------
/vendor/github.com/jackc/puddle/v2/resource_list.go:
--------------------------------------------------------------------------------
1 | package puddle
2 |
3 | type resList[T any] []*Resource[T]
4 |
5 | func (l *resList[T]) append(val *Resource[T]) { *l = append(*l, val) }
6 |
7 | func (l *resList[T]) popBack() *Resource[T] {
8 | idx := len(*l) - 1
9 | val := (*l)[idx]
10 | (*l)[idx] = nil // Avoid memory leak
11 | *l = (*l)[:idx]
12 |
13 | return val
14 | }
15 |
16 | func (l *resList[T]) remove(val *Resource[T]) {
17 | for i, elem := range *l {
18 | if elem == val {
19 | lastIdx := len(*l) - 1
20 | (*l)[i] = (*l)[lastIdx]
21 | (*l)[lastIdx] = nil // Avoid memory leak
22 | (*l) = (*l)[:lastIdx]
23 | return
24 | }
25 | }
26 |
27 | panic("BUG: removeResource could not find res in slice")
28 | }
29 |
--------------------------------------------------------------------------------
/vendor/github.com/joho/godotenv/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
--------------------------------------------------------------------------------
/vendor/github.com/joho/godotenv/LICENCE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013 John Barton
2 |
3 | MIT License
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
24 |
--------------------------------------------------------------------------------
/vendor/github.com/pmezard/go-difflib/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2013, Patrick Mezard
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without
5 | modification, are permitted provided that the following conditions are
6 | met:
7 |
8 | Redistributions of source code must retain the above copyright
9 | notice, this list of conditions and the following disclaimer.
10 | Redistributions in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in the
12 | documentation and/or other materials provided with the distribution.
13 | The names of its contributors may not be used to endorse or promote
14 | products derived from this software without specific prior written
15 | permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | engines:
2 | gofmt:
3 | enabled: true
4 | golint:
5 | enabled: true
6 | govet:
7 | enabled: true
8 |
9 | exclude_patterns:
10 | - ".github/"
11 | - "vendor/"
12 | - "codegen/"
13 | - "*.yml"
14 | - ".*.yml"
15 | - "*.md"
16 | - "Gopkg.*"
17 | - "doc.go"
18 | - "type_specific_codegen_test.go"
19 | - "type_specific_codegen.go"
20 | - ".gitignore"
21 | - "LICENSE"
22 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.dll
4 | *.so
5 | *.dylib
6 |
7 | # Test binary, build with `go test -c`
8 | *.test
9 |
10 | # Output of the go coverage tool, specifically when used with LiteIDE
11 | *.out
12 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2014 Stretchr, Inc.
4 | Copyright (c) 2017-2018 objx contributors
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/Taskfile.yml:
--------------------------------------------------------------------------------
1 | version: '3'
2 |
3 | tasks:
4 | default:
5 | deps: [test]
6 |
7 | lint:
8 | desc: Checks code style
9 | cmds:
10 | - gofmt -d -s *.go
11 | - go vet ./...
12 | silent: true
13 |
14 | lint-fix:
15 | desc: Fixes code style
16 | cmds:
17 | - gofmt -w -s *.go
18 |
19 | test:
20 | desc: Runs go tests
21 | cmds:
22 | - go test -race ./...
23 |
24 | test-coverage:
25 | desc: Runs go tests and calculates test coverage
26 | cmds:
27 | - go test -race -coverprofile=c.out ./...
28 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/security.go:
--------------------------------------------------------------------------------
1 | package objx
2 |
3 | import (
4 | "crypto/sha1"
5 | "encoding/hex"
6 | )
7 |
8 | // HashWithKey hashes the specified string using the security key
9 | func HashWithKey(data, key string) string {
10 | d := sha1.Sum([]byte(data + ":" + key))
11 | return hex.EncodeToString(d[:])
12 | }
13 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/objx/tests.go:
--------------------------------------------------------------------------------
1 | package objx
2 |
3 | // Has gets whether there is something at the specified selector
4 | // or not.
5 | //
6 | // If m is nil, Has will always return false.
7 | func (m Map) Has(selector string) bool {
8 | if m == nil {
9 | return false
10 | }
11 | return !m.Get(selector).IsNil()
12 | }
13 |
14 | // IsNil gets whether the data is nil or not.
15 | func (v *Value) IsNil() bool {
16 | return v == nil || v.data == nil
17 | }
18 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and contributors.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.CommentFormat}}
2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool {
3 | if h, ok := t.(tHelper); ok { h.Helper() }
4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}})
5 | }
6 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.CommentWithoutT "a"}}
2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool {
3 | if h, ok := a.t.(tHelper); ok { h.Helper() }
4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
5 | }
6 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/doc.go:
--------------------------------------------------------------------------------
1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system.
2 | //
3 | // # Example Usage
4 | //
5 | // The following is a complete example using assert in a standard test function:
6 | //
7 | // import (
8 | // "testing"
9 | // "github.com/stretchr/testify/assert"
10 | // )
11 | //
12 | // func TestSomething(t *testing.T) {
13 | //
14 | // var a string = "Hello"
15 | // var b string = "Hello"
16 | //
17 | // assert.Equal(t, a, b, "The two words should be the same.")
18 | //
19 | // }
20 | //
21 | // if you assert many times, use the format below:
22 | //
23 | // import (
24 | // "testing"
25 | // "github.com/stretchr/testify/assert"
26 | // )
27 | //
28 | // func TestSomething(t *testing.T) {
29 | // assert := assert.New(t)
30 | //
31 | // var a string = "Hello"
32 | // var b string = "Hello"
33 | //
34 | // assert.Equal(a, b, "The two words should be the same.")
35 | // }
36 | //
37 | // # Assertions
38 | //
39 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package.
40 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the
41 | // testing framework. This allows the assertion funcs to write the failings and other details to
42 | // the correct place.
43 | //
44 | // Every assertion function also takes an optional string message as the final argument,
45 | // allowing custom error messages to be appended to the message the assertion method outputs.
46 | package assert
47 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/errors.go:
--------------------------------------------------------------------------------
1 | package assert
2 |
3 | import (
4 | "errors"
5 | )
6 |
7 | // AnError is an error instance useful for testing. If the code does not care
8 | // about error specifics, and only needs to return the error for example, this
9 | // error should be used to make the test code more readable.
10 | var AnError = errors.New("assert.AnError general error for testing")
11 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/forward_assertions.go:
--------------------------------------------------------------------------------
1 | package assert
2 |
3 | // Assertions provides assertion methods around the
4 | // TestingT interface.
5 | type Assertions struct {
6 | t TestingT
7 | }
8 |
9 | // New makes a new Assertions object for the specified TestingT.
10 | func New(t TestingT) *Assertions {
11 | return &Assertions{
12 | t: t,
13 | }
14 | }
15 |
16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs"
17 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/yaml/yaml_custom.go:
--------------------------------------------------------------------------------
1 | //go:build testify_yaml_custom && !testify_yaml_fail && !testify_yaml_default
2 | // +build testify_yaml_custom,!testify_yaml_fail,!testify_yaml_default
3 |
4 | // Package yaml is an implementation of YAML functions that calls a pluggable implementation.
5 | //
6 | // This implementation is selected with the testify_yaml_custom build tag.
7 | //
8 | // go test -tags testify_yaml_custom
9 | //
10 | // This implementation can be used at build time to replace the default implementation
11 | // to avoid linking with [gopkg.in/yaml.v3].
12 | //
13 | // In your test package:
14 | //
15 | // import assertYaml "github.com/stretchr/testify/assert/yaml"
16 | //
17 | // func init() {
18 | // assertYaml.Unmarshal = func (in []byte, out interface{}) error {
19 | // // ...
20 | // return nil
21 | // }
22 | // }
23 | package yaml
24 |
25 | var Unmarshal func(in []byte, out interface{}) error
26 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/yaml/yaml_default.go:
--------------------------------------------------------------------------------
1 | //go:build !testify_yaml_fail && !testify_yaml_custom
2 | // +build !testify_yaml_fail,!testify_yaml_custom
3 |
4 | // Package yaml is just an indirection to handle YAML deserialization.
5 | //
6 | // This package is just an indirection that allows the builder to override the
7 | // indirection with an alternative implementation of this package that uses
8 | // another implementation of YAML deserialization. This allows to not either not
9 | // use YAML deserialization at all, or to use another implementation than
10 | // [gopkg.in/yaml.v3] (for example for license compatibility reasons, see [PR #1120]).
11 | //
12 | // Alternative implementations are selected using build tags:
13 | //
14 | // - testify_yaml_fail: [Unmarshal] always fails with an error
15 | // - testify_yaml_custom: [Unmarshal] is a variable. Caller must initialize it
16 | // before calling any of [github.com/stretchr/testify/assert.YAMLEq] or
17 | // [github.com/stretchr/testify/assert.YAMLEqf].
18 | //
19 | // Usage:
20 | //
21 | // go test -tags testify_yaml_fail
22 | //
23 | // You can check with "go list" which implementation is linked:
24 | //
25 | // go list -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
26 | // go list -tags testify_yaml_fail -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
27 | // go list -tags testify_yaml_custom -f '{{.Imports}}' github.com/stretchr/testify/assert/yaml
28 | //
29 | // [PR #1120]: https://github.com/stretchr/testify/pull/1120
30 | package yaml
31 |
32 | import goyaml "gopkg.in/yaml.v3"
33 |
34 | // Unmarshal is just a wrapper of [gopkg.in/yaml.v3.Unmarshal].
35 | func Unmarshal(in []byte, out interface{}) error {
36 | return goyaml.Unmarshal(in, out)
37 | }
38 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/assert/yaml/yaml_fail.go:
--------------------------------------------------------------------------------
1 | //go:build testify_yaml_fail && !testify_yaml_custom && !testify_yaml_default
2 | // +build testify_yaml_fail,!testify_yaml_custom,!testify_yaml_default
3 |
4 | // Package yaml is an implementation of YAML functions that always fail.
5 | //
6 | // This implementation can be used at build time to replace the default implementation
7 | // to avoid linking with [gopkg.in/yaml.v3]:
8 | //
9 | // go test -tags testify_yaml_fail
10 | package yaml
11 |
12 | import "errors"
13 |
14 | var errNotImplemented = errors.New("YAML functions are not available (see https://pkg.go.dev/github.com/stretchr/testify/assert/yaml)")
15 |
16 | func Unmarshal([]byte, interface{}) error {
17 | return errNotImplemented
18 | }
19 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/mock/doc.go:
--------------------------------------------------------------------------------
1 | // Package mock provides a system by which it is possible to mock your objects
2 | // and verify calls are happening as expected.
3 | //
4 | // # Example Usage
5 | //
6 | // The mock package provides an object, Mock, that tracks activity on another object. It is usually
7 | // embedded into a test object as shown below:
8 | //
9 | // type MyTestObject struct {
10 | // // add a Mock object instance
11 | // mock.Mock
12 | //
13 | // // other fields go here as normal
14 | // }
15 | //
16 | // When implementing the methods of an interface, you wire your functions up
17 | // to call the Mock.Called(args...) method, and return the appropriate values.
18 | //
19 | // For example, to mock a method that saves the name and age of a person and returns
20 | // the year of their birth or an error, you might write this:
21 | //
22 | // func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) {
23 | // args := o.Called(firstname, lastname, age)
24 | // return args.Int(0), args.Error(1)
25 | // }
26 | //
27 | // The Int, Error and Bool methods are examples of strongly typed getters that take the argument
28 | // index position. Given this argument list:
29 | //
30 | // (12, true, "Something")
31 | //
32 | // You could read them out strongly typed like this:
33 | //
34 | // args.Int(0)
35 | // args.Bool(1)
36 | // args.String(2)
37 | //
38 | // For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion:
39 | //
40 | // return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine)
41 | //
42 | // This may cause a panic if the object you are getting is nil (the type assertion will fail), in those
43 | // cases you should check for nil first.
44 | package mock
45 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/doc.go:
--------------------------------------------------------------------------------
1 | // Package require implements the same assertions as the `assert` package but
2 | // stops test execution when a test fails.
3 | //
4 | // # Example Usage
5 | //
6 | // The following is a complete example using require in a standard test function:
7 | //
8 | // import (
9 | // "testing"
10 | // "github.com/stretchr/testify/require"
11 | // )
12 | //
13 | // func TestSomething(t *testing.T) {
14 | //
15 | // var a string = "Hello"
16 | // var b string = "Hello"
17 | //
18 | // require.Equal(t, a, b, "The two words should be the same.")
19 | //
20 | // }
21 | //
22 | // # Assertions
23 | //
24 | // The `require` package have same global functions as in the `assert` package,
25 | // but instead of returning a boolean result they call `t.FailNow()`.
26 | //
27 | // Every assertion function also takes an optional string message as the final argument,
28 | // allowing custom error messages to be appended to the message the assertion method outputs.
29 | package require
30 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/forward_requirements.go:
--------------------------------------------------------------------------------
1 | package require
2 |
3 | // Assertions provides assertion methods around the
4 | // TestingT interface.
5 | type Assertions struct {
6 | t TestingT
7 | }
8 |
9 | // New makes a new Assertions object for the specified TestingT.
10 | func New(t TestingT) *Assertions {
11 | return &Assertions{
12 | t: t,
13 | }
14 | }
15 |
16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require_forward.go.tmpl -include-format-funcs"
17 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/require.go.tmpl:
--------------------------------------------------------------------------------
1 | {{ replace .Comment "assert." "require."}}
2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) {
3 | if h, ok := t.(tHelper); ok { h.Helper() }
4 | if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return }
5 | t.FailNow()
6 | }
7 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl:
--------------------------------------------------------------------------------
1 | {{.CommentWithoutT "a"}}
2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) {
3 | if h, ok := a.t.(tHelper); ok { h.Helper() }
4 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}})
5 | }
6 |
--------------------------------------------------------------------------------
/vendor/github.com/stretchr/testify/require/requirements.go:
--------------------------------------------------------------------------------
1 | package require
2 |
3 | // TestingT is an interface wrapper around *testing.T
4 | type TestingT interface {
5 | Errorf(format string, args ...interface{})
6 | FailNow()
7 | }
8 |
9 | type tHelper = interface {
10 | Helper()
11 | }
12 |
13 | // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful
14 | // for table driven tests.
15 | type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{})
16 |
17 | // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful
18 | // for table driven tests.
19 | type ValueAssertionFunc func(TestingT, interface{}, ...interface{})
20 |
21 | // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful
22 | // for table driven tests.
23 | type BoolAssertionFunc func(TestingT, bool, ...interface{})
24 |
25 | // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful
26 | // for table driven tests.
27 | type ErrorAssertionFunc func(TestingT, error, ...interface{})
28 |
29 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs"
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/crypto/bcrypt/base64.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package bcrypt
6 |
7 | import "encoding/base64"
8 |
9 | const alphabet = "./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
10 |
11 | var bcEncoding = base64.NewEncoding(alphabet)
12 |
13 | func base64Encode(src []byte) []byte {
14 | n := bcEncoding.EncodedLen(len(src))
15 | dst := make([]byte, n)
16 | bcEncoding.Encode(dst, src)
17 | for dst[n-1] == '=' {
18 | n--
19 | }
20 | return dst[:n]
21 | }
22 |
23 | func base64Decode(src []byte) ([]byte, error) {
24 | numOfEquals := 4 - (len(src) % 4)
25 | for i := 0; i < numOfEquals; i++ {
26 | src = append(src, '=')
27 | }
28 |
29 | dst := make([]byte, bcEncoding.DecodedLen(len(src)))
30 | n, err := bcEncoding.Decode(dst, src)
31 | if err != nil {
32 | return nil, err
33 | }
34 | return dst[:n], nil
35 | }
36 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sync/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/sync/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright 2009 The Go Authors.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions are
5 | met:
6 |
7 | * Redistributions of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above
10 | copyright notice, this list of conditions and the following disclaimer
11 | in the documentation and/or other materials provided with the
12 | distribution.
13 | * Neither the name of Google LLC nor the names of its
14 | contributors may be used to endorse or promote products derived from
15 | this software without specific prior written permission.
16 |
17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/PATENTS:
--------------------------------------------------------------------------------
1 | Additional IP Rights Grant (Patents)
2 |
3 | "This implementation" means the copyrightable works distributed by
4 | Google as part of the Go project.
5 |
6 | Google hereby grants to You a perpetual, worldwide, non-exclusive,
7 | no-charge, royalty-free, irrevocable (except as stated in this section)
8 | patent license to make, have made, use, offer to sell, sell, import,
9 | transfer and otherwise run, modify and propagate the contents of this
10 | implementation of Go, where such license applies only to those patent
11 | claims, both currently owned or controlled by Google and acquired in
12 | the future, licensable by Google that are necessarily infringed by this
13 | implementation of Go. This grant does not include claims that would be
14 | infringed only as a consequence of further modification of this
15 | implementation. If you or your agent or exclusive licensee institute or
16 | order or agree to the institution of patent litigation against any
17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging
18 | that this implementation of Go or any code incorporated within this
19 | implementation of Go constitutes direct or contributory patent
20 | infringement, or inducement of patent infringement, then any patent
21 | rights granted to you under this License for this implementation of Go
22 | shall terminate as of the date such litigation is filed.
23 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/cases/fold.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package cases
6 |
7 | import "golang.org/x/text/transform"
8 |
9 | type caseFolder struct{ transform.NopResetter }
10 |
11 | // caseFolder implements the Transformer interface for doing case folding.
12 | func (t *caseFolder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
13 | c := context{dst: dst, src: src, atEOF: atEOF}
14 | for c.next() {
15 | foldFull(&c)
16 | c.checkpoint()
17 | }
18 | return c.ret()
19 | }
20 |
21 | func (t *caseFolder) Span(src []byte, atEOF bool) (n int, err error) {
22 | c := context{src: src, atEOF: atEOF}
23 | for c.next() && isFoldFull(&c) {
24 | c.checkpoint()
25 | }
26 | return c.retSpan()
27 | }
28 |
29 | func makeFold(o options) transform.SpanningTransformer {
30 | // TODO: Special case folding, through option Language, Special/Turkic, or
31 | // both.
32 | // TODO: Implement Compact options.
33 | return &caseFolder{}
34 | }
35 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/cases/icu.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build icu
6 |
7 | package cases
8 |
9 | // Ideally these functions would be defined in a test file, but go test doesn't
10 | // allow CGO in tests. The build tag should ensure either way that these
11 | // functions will not end up in the package.
12 |
13 | // TODO: Ensure that the correct ICU version is set.
14 |
15 | /*
16 | #cgo LDFLAGS: -licui18n.57 -licuuc.57
17 | #include
18 | #include
19 | #include
20 | #include
21 | #include
22 | */
23 | import "C"
24 |
25 | import "unsafe"
26 |
27 | func doICU(tag, caser, input string) string {
28 | err := C.UErrorCode(0)
29 | loc := C.CString(tag)
30 | cm := C.ucasemap_open(loc, C.uint32_t(0), &err)
31 |
32 | buf := make([]byte, len(input)*4)
33 | dst := (*C.char)(unsafe.Pointer(&buf[0]))
34 | src := C.CString(input)
35 |
36 | cn := C.int32_t(0)
37 |
38 | switch caser {
39 | case "fold":
40 | cn = C.ucasemap_utf8FoldCase(cm,
41 | dst, C.int32_t(len(buf)),
42 | src, C.int32_t(len(input)),
43 | &err)
44 | case "lower":
45 | cn = C.ucasemap_utf8ToLower(cm,
46 | dst, C.int32_t(len(buf)),
47 | src, C.int32_t(len(input)),
48 | &err)
49 | case "upper":
50 | cn = C.ucasemap_utf8ToUpper(cm,
51 | dst, C.int32_t(len(buf)),
52 | src, C.int32_t(len(input)),
53 | &err)
54 | case "title":
55 | cn = C.ucasemap_utf8ToTitle(cm,
56 | dst, C.int32_t(len(buf)),
57 | src, C.int32_t(len(input)),
58 | &err)
59 | }
60 | return string(buf[:cn])
61 | }
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/internal/internal.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package internal contains non-exported functionality that are used by
6 | // packages in the text repository.
7 | package internal // import "golang.org/x/text/internal"
8 |
9 | import (
10 | "sort"
11 |
12 | "golang.org/x/text/language"
13 | )
14 |
15 | // SortTags sorts tags in place.
16 | func SortTags(tags []language.Tag) {
17 | sort.Sort(sorter(tags))
18 | }
19 |
20 | type sorter []language.Tag
21 |
22 | func (s sorter) Len() int {
23 | return len(s)
24 | }
25 |
26 | func (s sorter) Swap(i, j int) {
27 | s[i], s[j] = s[j], s[i]
28 | }
29 |
30 | func (s sorter) Less(i, j int) bool {
31 | return s[i].String() < s[j].String()
32 | }
33 |
34 | // UniqueTags sorts and filters duplicate tags in place and returns a slice with
35 | // only unique tags.
36 | func UniqueTags(tags []language.Tag) []language.Tag {
37 | if len(tags) <= 1 {
38 | return tags
39 | }
40 | SortTags(tags)
41 | k := 0
42 | for i := 1; i < len(tags); i++ {
43 | if tags[k].String() < tags[i].String() {
44 | k++
45 | tags[k] = tags[i]
46 | }
47 | }
48 | return tags[:k+1]
49 | }
50 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/internal/language/common.go:
--------------------------------------------------------------------------------
1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
2 |
3 | package language
4 |
5 | // This file contains code common to the maketables.go and the package code.
6 |
7 | // AliasType is the type of an alias in AliasMap.
8 | type AliasType int8
9 |
10 | const (
11 | Deprecated AliasType = iota
12 | Macro
13 | Legacy
14 |
15 | AliasTypeUnknown AliasType = -1
16 | )
17 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/internal/language/compact.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package language
6 |
7 | // CompactCoreInfo is a compact integer with the three core tags encoded.
8 | type CompactCoreInfo uint32
9 |
10 | // GetCompactCore generates a uint32 value that is guaranteed to be unique for
11 | // different language, region, and script values.
12 | func GetCompactCore(t Tag) (cci CompactCoreInfo, ok bool) {
13 | if t.LangID > langNoIndexOffset {
14 | return 0, false
15 | }
16 | cci |= CompactCoreInfo(t.LangID) << (8 + 12)
17 | cci |= CompactCoreInfo(t.ScriptID) << 12
18 | cci |= CompactCoreInfo(t.RegionID)
19 | return cci, true
20 | }
21 |
22 | // Tag generates a tag from c.
23 | func (c CompactCoreInfo) Tag() Tag {
24 | return Tag{
25 | LangID: Language(c >> 20),
26 | RegionID: Region(c & 0x3ff),
27 | ScriptID: Script(c>>12) & 0xff,
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/internal/language/compact/compact.go:
--------------------------------------------------------------------------------
1 | // Copyright 2018 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package compact defines a compact representation of language tags.
6 | //
7 | // Common language tags (at least all for which locale information is defined
8 | // in CLDR) are assigned a unique index. Each Tag is associated with such an
9 | // ID for selecting language-related resources (such as translations) as well
10 | // as one for selecting regional defaults (currency, number formatting, etc.)
11 | //
12 | // It may want to export this functionality at some point, but at this point
13 | // this is only available for use within x/text.
14 | package compact // import "golang.org/x/text/internal/language/compact"
15 |
16 | import (
17 | "sort"
18 | "strings"
19 |
20 | "golang.org/x/text/internal/language"
21 | )
22 |
23 | // ID is an integer identifying a single tag.
24 | type ID uint16
25 |
26 | func getCoreIndex(t language.Tag) (id ID, ok bool) {
27 | cci, ok := language.GetCompactCore(t)
28 | if !ok {
29 | return 0, false
30 | }
31 | i := sort.Search(len(coreTags), func(i int) bool {
32 | return cci <= coreTags[i]
33 | })
34 | if i == len(coreTags) || coreTags[i] != cci {
35 | return 0, false
36 | }
37 | return ID(i), true
38 | }
39 |
40 | // Parent returns the ID of the parent or the root ID if id is already the root.
41 | func (id ID) Parent() ID {
42 | return parents[id]
43 | }
44 |
45 | // Tag converts id to an internal language Tag.
46 | func (id ID) Tag() language.Tag {
47 | if int(id) >= len(coreTags) {
48 | return specialTags[int(id)-len(coreTags)]
49 | }
50 | return coreTags[id].Tag()
51 | }
52 |
53 | var specialTags []language.Tag
54 |
55 | func init() {
56 | tags := strings.Split(specialTagsStr, " ")
57 | specialTags = make([]language.Tag, len(tags))
58 | for i, t := range tags {
59 | specialTags[i] = language.MustParse(t)
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/internal/language/coverage.go:
--------------------------------------------------------------------------------
1 | // Copyright 2014 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package language
6 |
7 | // BaseLanguages returns the list of all supported base languages. It generates
8 | // the list by traversing the internal structures.
9 | func BaseLanguages() []Language {
10 | base := make([]Language, 0, NumLanguages)
11 | for i := 0; i < langNoIndexOffset; i++ {
12 | // We included "und" already for the value 0.
13 | if i != nonCanonicalUnd {
14 | base = append(base, Language(i))
15 | }
16 | }
17 | i := langNoIndexOffset
18 | for _, v := range langNoIndex {
19 | for k := 0; k < 8; k++ {
20 | if v&1 == 1 {
21 | base = append(base, Language(i))
22 | }
23 | v >>= 1
24 | i++
25 | }
26 | }
27 | return base
28 | }
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/internal/language/tags.go:
--------------------------------------------------------------------------------
1 | // Copyright 2013 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package language
6 |
7 | // MustParse is like Parse, but panics if the given BCP 47 tag cannot be parsed.
8 | // It simplifies safe initialization of Tag values.
9 | func MustParse(s string) Tag {
10 | t, err := Parse(s)
11 | if err != nil {
12 | panic(err)
13 | }
14 | return t
15 | }
16 |
17 | // MustParseBase is like ParseBase, but panics if the given base cannot be parsed.
18 | // It simplifies safe initialization of Base values.
19 | func MustParseBase(s string) Language {
20 | b, err := ParseBase(s)
21 | if err != nil {
22 | panic(err)
23 | }
24 | return b
25 | }
26 |
27 | // MustParseScript is like ParseScript, but panics if the given script cannot be
28 | // parsed. It simplifies safe initialization of Script values.
29 | func MustParseScript(s string) Script {
30 | scr, err := ParseScript(s)
31 | if err != nil {
32 | panic(err)
33 | }
34 | return scr
35 | }
36 |
37 | // MustParseRegion is like ParseRegion, but panics if the given region cannot be
38 | // parsed. It simplifies safe initialization of Region values.
39 | func MustParseRegion(s string) Region {
40 | r, err := ParseRegion(s)
41 | if err != nil {
42 | panic(err)
43 | }
44 | return r
45 | }
46 |
47 | // Und is the root language.
48 | var Und Tag
49 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build go1.10
6 |
7 | package bidirule
8 |
9 | func (t *Transformer) isFinal() bool {
10 | return t.state == ruleLTRFinal || t.state == ruleRTLFinal || t.state == ruleInitial
11 | }
12 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go:
--------------------------------------------------------------------------------
1 | // Copyright 2016 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | //go:build !go1.10
6 |
7 | package bidirule
8 |
9 | func (t *Transformer) isFinal() bool {
10 | if !t.isRTL() {
11 | return true
12 | }
13 | return t.state == ruleLTRFinal || t.state == ruleRTLFinal || t.state == ruleInitial
14 | }
15 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/secure/precis/class.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package precis
6 |
7 | import (
8 | "unicode/utf8"
9 | )
10 |
11 | // TODO: Add contextual character rules from Appendix A of RFC5892.
12 |
13 | // A class is a set of characters that match certain derived properties. The
14 | // PRECIS framework defines two classes: The Freeform class and the Identifier
15 | // class. The freeform class should be used for profiles where expressiveness is
16 | // prioritized over safety such as nicknames or passwords. The identifier class
17 | // should be used for profiles where safety is the first priority such as
18 | // addressable network labels and usernames.
19 | type class struct {
20 | validFrom property
21 | }
22 |
23 | // Contains satisfies the runes.Set interface and returns whether the given rune
24 | // is a member of the class.
25 | func (c class) Contains(r rune) bool {
26 | b := make([]byte, 4)
27 | n := utf8.EncodeRune(b, r)
28 |
29 | trieval, _ := dpTrie.lookup(b[:n])
30 | return c.validFrom <= property(trieval)
31 | }
32 |
33 | var (
34 | identifier = &class{validFrom: pValid}
35 | freeform = &class{validFrom: idDisOrFreePVal}
36 | )
37 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/secure/precis/doc.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | // Package precis contains types and functions for the preparation,
6 | // enforcement, and comparison of internationalized strings ("PRECIS") as
7 | // defined in RFC 8264. It also contains several pre-defined profiles for
8 | // passwords, nicknames, and usernames as defined in RFC 8265 and RFC 8266.
9 | //
10 | // BE ADVISED: This package is under construction and the API may change in
11 | // backwards incompatible ways and without notice.
12 | package precis // import "golang.org/x/text/secure/precis"
13 |
14 | //go:generate go run gen.go gen_trieval.go
15 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/secure/precis/profiles.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package precis
6 |
7 | import (
8 | "unicode"
9 |
10 | "golang.org/x/text/runes"
11 | "golang.org/x/text/transform"
12 | "golang.org/x/text/unicode/norm"
13 | )
14 |
15 | var (
16 | // Implements the Nickname profile specified in RFC 8266.
17 | Nickname *Profile = nickname
18 |
19 | // Implements the UsernameCaseMapped profile specified in RFC 8265.
20 | UsernameCaseMapped *Profile = usernameCaseMap
21 |
22 | // Implements the UsernameCasePreserved profile specified in RFC 8265.
23 | UsernameCasePreserved *Profile = usernameNoCaseMap
24 |
25 | // Implements the OpaqueString profile defined in RFC 8265 for passwords and
26 | // other secure labels.
27 | OpaqueString *Profile = opaquestring
28 | )
29 |
30 | var (
31 | nickname = &Profile{
32 | options: getOpts(
33 | AdditionalMapping(func() transform.Transformer {
34 | return &nickAdditionalMapping{}
35 | }),
36 | IgnoreCase,
37 | Norm(norm.NFKC),
38 | DisallowEmpty,
39 | repeat,
40 | ),
41 | class: freeform,
42 | }
43 | usernameCaseMap = &Profile{
44 | options: getOpts(
45 | FoldWidth,
46 | LowerCase(),
47 | Norm(norm.NFC),
48 | BidiRule,
49 | ),
50 | class: identifier,
51 | }
52 | usernameNoCaseMap = &Profile{
53 | options: getOpts(
54 | FoldWidth,
55 | Norm(norm.NFC),
56 | BidiRule,
57 | ),
58 | class: identifier,
59 | }
60 | opaquestring = &Profile{
61 | options: getOpts(
62 | AdditionalMapping(func() transform.Transformer {
63 | return mapSpaces
64 | }),
65 | Norm(norm.NFC),
66 | DisallowEmpty,
67 | ),
68 | class: freeform,
69 | }
70 | )
71 |
72 | // mapSpaces is a shared value of a runes.Map transformer.
73 | var mapSpaces transform.Transformer = runes.Map(func(r rune) rune {
74 | if unicode.Is(unicode.Zs, r) {
75 | return ' '
76 | }
77 | return r
78 | })
79 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/secure/precis/transformer.go:
--------------------------------------------------------------------------------
1 | // Copyright 2015 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package precis
6 |
7 | import "golang.org/x/text/transform"
8 |
9 | // Transformer implements the transform.Transformer interface.
10 | type Transformer struct {
11 | t transform.Transformer
12 | }
13 |
14 | // Reset implements the transform.Transformer interface.
15 | func (t Transformer) Reset() { t.t.Reset() }
16 |
17 | // Transform implements the transform.Transformer interface.
18 | func (t Transformer) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) {
19 | return t.t.Transform(dst, src, atEOF)
20 | }
21 |
22 | // Bytes returns a new byte slice with the result of applying t to b.
23 | func (t Transformer) Bytes(b []byte) []byte {
24 | b, _, _ = transform.Bytes(t, b)
25 | return b
26 | }
27 |
28 | // String returns a string with the result of applying t to s.
29 | func (t Transformer) String(s string) string {
30 | s, _, _ = transform.String(t, s)
31 | return s
32 | }
33 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/secure/precis/trieval.go:
--------------------------------------------------------------------------------
1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
2 |
3 | package precis
4 |
5 | // entry is the entry of a trie table
6 | // 7..6 property (unassigned, disallowed, maybe, valid)
7 | // 5..0 category
8 | type entry uint8
9 |
10 | const (
11 | propShift = 6
12 | propMask = 0xc0
13 | catMask = 0x3f
14 | )
15 |
16 | func (e entry) property() property { return property(e & propMask) }
17 | func (e entry) category() category { return category(e & catMask) }
18 |
19 | type property uint8
20 |
21 | // The order of these constants matter. A Profile may consider runes to be
22 | // allowed either from pValid or idDisOrFreePVal.
23 | const (
24 | unassigned property = iota << propShift
25 | disallowed
26 | idDisOrFreePVal // disallowed for Identifier, pValid for FreeForm
27 | pValid
28 | )
29 |
30 | // compute permutations of all properties and specialCategories.
31 | type category uint8
32 |
33 | const (
34 | other category = iota
35 |
36 | // Special rune types
37 | joiningL
38 | joiningD
39 | joiningT
40 | joiningR
41 | viramaModifier
42 | viramaJoinT // Virama + JoiningT
43 | latinSmallL // U+006c
44 | greek
45 | greekJoinT // Greek + JoiningT
46 | hebrew
47 | hebrewJoinT // Hebrew + JoiningT
48 | japanese // hirigana, katakana, han
49 |
50 | // Special rune types associated with contextual rules defined in
51 | // https://tools.ietf.org/html/rfc5892#appendix-A.
52 | // ContextO
53 | zeroWidthNonJoiner // rule 1
54 | zeroWidthJoiner // rule 2
55 | // ContextJ
56 | middleDot // rule 3
57 | greekLowerNumeralSign // rule 4
58 | hebrewPreceding // rule 5 and 6
59 | katakanaMiddleDot // rule 7
60 | arabicIndicDigit // rule 8
61 | extendedArabicIndicDigit // rule 9
62 |
63 | numCategories
64 | )
65 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/unicode/bidi/trieval.go:
--------------------------------------------------------------------------------
1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
2 |
3 | package bidi
4 |
5 | // Class is the Unicode BiDi class. Each rune has a single class.
6 | type Class uint
7 |
8 | const (
9 | L Class = iota // LeftToRight
10 | R // RightToLeft
11 | EN // EuropeanNumber
12 | ES // EuropeanSeparator
13 | ET // EuropeanTerminator
14 | AN // ArabicNumber
15 | CS // CommonSeparator
16 | B // ParagraphSeparator
17 | S // SegmentSeparator
18 | WS // WhiteSpace
19 | ON // OtherNeutral
20 | BN // BoundaryNeutral
21 | NSM // NonspacingMark
22 | AL // ArabicLetter
23 | Control // Control LRO - PDI
24 |
25 | numClass
26 |
27 | LRO // LeftToRightOverride
28 | RLO // RightToLeftOverride
29 | LRE // LeftToRightEmbedding
30 | RLE // RightToLeftEmbedding
31 | PDF // PopDirectionalFormat
32 | LRI // LeftToRightIsolate
33 | RLI // RightToLeftIsolate
34 | FSI // FirstStrongIsolate
35 | PDI // PopDirectionalIsolate
36 |
37 | unknownClass = ^Class(0)
38 | )
39 |
40 | // A trie entry has the following bits:
41 | // 7..5 XOR mask for brackets
42 | // 4 1: Bracket open, 0: Bracket close
43 | // 3..0 Class type
44 |
45 | const (
46 | openMask = 0x10
47 | xorMaskShift = 5
48 | )
49 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/unicode/norm/trie.go:
--------------------------------------------------------------------------------
1 | // Copyright 2011 The Go Authors. All rights reserved.
2 | // Use of this source code is governed by a BSD-style
3 | // license that can be found in the LICENSE file.
4 |
5 | package norm
6 |
7 | type valueRange struct {
8 | value uint16 // header: value:stride
9 | lo, hi byte // header: lo:n
10 | }
11 |
12 | type sparseBlocks struct {
13 | values []valueRange
14 | offset []uint16
15 | }
16 |
17 | var nfcSparse = sparseBlocks{
18 | values: nfcSparseValues[:],
19 | offset: nfcSparseOffset[:],
20 | }
21 |
22 | var nfkcSparse = sparseBlocks{
23 | values: nfkcSparseValues[:],
24 | offset: nfkcSparseOffset[:],
25 | }
26 |
27 | var (
28 | nfcData = newNfcTrie(0)
29 | nfkcData = newNfkcTrie(0)
30 | )
31 |
32 | // lookup determines the type of block n and looks up the value for b.
33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block
34 | // is a list of ranges with an accompanying value. Given a matching range r,
35 | // the value for b is by r.value + (b - r.lo) * stride.
36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 {
37 | offset := t.offset[n]
38 | header := t.values[offset]
39 | lo := offset + 1
40 | hi := lo + uint16(header.lo)
41 | for lo < hi {
42 | m := lo + (hi-lo)/2
43 | r := t.values[m]
44 | if r.lo <= b && b <= r.hi {
45 | return r.value + uint16(b-r.lo)*header.value
46 | }
47 | if b < r.lo {
48 | hi = m
49 | } else {
50 | lo = m + 1
51 | }
52 | }
53 | return 0
54 | }
55 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/width/kind_string.go:
--------------------------------------------------------------------------------
1 | // Code generated by "stringer -type=Kind"; DO NOT EDIT.
2 |
3 | package width
4 |
5 | import "strconv"
6 |
7 | func _() {
8 | // An "invalid array index" compiler error signifies that the constant values have changed.
9 | // Re-run the stringer command to generate them again.
10 | var x [1]struct{}
11 | _ = x[Neutral-0]
12 | _ = x[EastAsianAmbiguous-1]
13 | _ = x[EastAsianWide-2]
14 | _ = x[EastAsianNarrow-3]
15 | _ = x[EastAsianFullwidth-4]
16 | _ = x[EastAsianHalfwidth-5]
17 | }
18 |
19 | const _Kind_name = "NeutralEastAsianAmbiguousEastAsianWideEastAsianNarrowEastAsianFullwidthEastAsianHalfwidth"
20 |
21 | var _Kind_index = [...]uint8{0, 7, 25, 38, 53, 71, 89}
22 |
23 | func (i Kind) String() string {
24 | if i < 0 || i >= Kind(len(_Kind_index)-1) {
25 | return "Kind(" + strconv.FormatInt(int64(i), 10) + ")"
26 | }
27 | return _Kind_name[_Kind_index[i]:_Kind_index[i+1]]
28 | }
29 |
--------------------------------------------------------------------------------
/vendor/golang.org/x/text/width/trieval.go:
--------------------------------------------------------------------------------
1 | // Code generated by running "go generate" in golang.org/x/text. DO NOT EDIT.
2 |
3 | package width
4 |
5 | // elem is an entry of the width trie. The high byte is used to encode the type
6 | // of the rune. The low byte is used to store the index to a mapping entry in
7 | // the inverseData array.
8 | type elem uint16
9 |
10 | const (
11 | tagNeutral elem = iota << typeShift
12 | tagAmbiguous
13 | tagWide
14 | tagNarrow
15 | tagFullwidth
16 | tagHalfwidth
17 | )
18 |
19 | const (
20 | numTypeBits = 3
21 | typeShift = 16 - numTypeBits
22 |
23 | // tagNeedsFold is true for all fullwidth and halfwidth runes except for
24 | // the Won sign U+20A9.
25 | tagNeedsFold = 0x1000
26 |
27 | // The Korean Won sign is halfwidth, but SHOULD NOT be mapped to a wide
28 | // variant.
29 | wonSign rune = 0x20A9
30 | )
31 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v3/NOTICE:
--------------------------------------------------------------------------------
1 | Copyright 2011-2016 Canonical Ltd.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/vendor/gopkg.in/yaml.v3/writerc.go:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2011-2019 Canonical Ltd
3 | // Copyright (c) 2006-2010 Kirill Simonov
4 | //
5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | // this software and associated documentation files (the "Software"), to deal in
7 | // the Software without restriction, including without limitation the rights to
8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 | // of the Software, and to permit persons to whom the Software is furnished to do
10 | // so, subject to the following conditions:
11 | //
12 | // The above copyright notice and this permission notice shall be included in all
13 | // copies or substantial portions of the Software.
14 | //
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | // SOFTWARE.
22 |
23 | package yaml
24 |
25 | // Set the writer error and return false.
26 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool {
27 | emitter.error = yaml_WRITER_ERROR
28 | emitter.problem = problem
29 | return false
30 | }
31 |
32 | // Flush the output buffer.
33 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool {
34 | if emitter.write_handler == nil {
35 | panic("write handler not set")
36 | }
37 |
38 | // Check if the buffer is empty.
39 | if emitter.buffer_pos == 0 {
40 | return true
41 | }
42 |
43 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil {
44 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error())
45 | }
46 | emitter.buffer_pos = 0
47 | return true
48 | }
49 |
--------------------------------------------------------------------------------