diff --git a/.github/workflows/check-actionlint.yaml b/.github/workflows/check-actionlint.yaml new file mode 100644 index 00000000..81693d8c --- /dev/null +++ b/.github/workflows/check-actionlint.yaml @@ -0,0 +1,31 @@ +name: Check - actionlint + +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened + paths: + - ".github/workflows/**" + +jobs: + checkactionlint: + name: Check actionlint + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Ensure dependencies installed + shell: bash + run: | + make ensure-deps + + - name: Run actionlint + run: | + make actionlint diff --git a/.github/workflows/check-all.yaml b/.github/workflows/check-all.yaml new file mode 100644 index 00000000..4defa166 --- /dev/null +++ b/.github/workflows/check-all.yaml @@ -0,0 +1,35 @@ +name: Check - All linters, etc +on: + push: + branches: + - main + - release-* + tags-ignore: + - "**" + +jobs: + build: + name: Change to Main/Release Branch + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version: "1.19" + id: go + + - name: Ensure dependencies installed + shell: bash + run: | + make ensure-deps + + - name: Run all checks + shell: bash + run: | + make check diff --git a/.github/workflows/check-lint.yaml b/.github/workflows/check-lint.yaml new file mode 100644 index 00000000..f3da7692 --- /dev/null +++ b/.github/workflows/check-lint.yaml @@ -0,0 +1,53 @@ +name: Check - lint + +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened + paths: + - "**.go" + - "**/go.mod" + - ".golangci.yaml" + +jobs: + checklint: + name: Lint + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version: "1.19" + id: go + + # - name: Get Date + # id: get-date + # shell: bash + # run: | + # echo "date=$(date -u "+%Y-%m")" >> $GITHUB_OUTPUT + + - name: Restore Lint Cache + uses: actions/cache@v3 + timeout-minutes: 10 + continue-on-error: true + with: + path: ${{ runner.temp }}/lint_cache + # key: ${{ runner.os }}-lint-cache-${{ steps.get-date.outputs.date }} + key: ${{ runner.os }}-lint-cache + restore-keys: | + ${{ runner.os }}-lint-cache + + - name: Run golangci-lint + env: + GOLANGCI_LINT_CACHE: ${{ runner.temp }}/lint_cache + run: | + make lint diff --git a/.github/workflows/check-mdlint.yaml b/.github/workflows/check-mdlint.yaml new file mode 100644 index 00000000..ad4883d1 --- /dev/null +++ b/.github/workflows/check-mdlint.yaml @@ -0,0 +1,32 @@ +name: Check - mdlint + +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened + paths: + - "**.md" + - "hack/check/check-mdlint.sh" + +jobs: + checkmdlint: + name: Check mdlint + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Ensure dependencies installed + shell: bash + run: | + make ensure-deps + + - name: Run mdlint + run: | + make mdlint diff --git a/.github/workflows/check-shell.yaml b/.github/workflows/check-shell.yaml new file mode 100644 index 00000000..2f0474af --- /dev/null +++ b/.github/workflows/check-shell.yaml @@ -0,0 +1,33 @@ +name: Check - shell + +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened + paths: + - "**/Makefile" + - "**.sh" + - "hack/check/check-shell.sh" + +jobs: + checkshell: + name: Check shell + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Ensure dependencies installed + shell: bash + run: | + make ensure-deps + + - name: Run shellcheck + run: | + make shellcheck diff --git a/.github/workflows/check-yaml.yaml b/.github/workflows/check-yaml.yaml new file mode 100644 index 00000000..a24209ab --- /dev/null +++ b/.github/workflows/check-yaml.yaml @@ -0,0 +1,31 @@ +name: Check - yaml + +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened + paths: + - ".github/workflows/**" + +jobs: + checkmdlint: + name: Check mdlint + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Ensure dependencies installed + shell: bash + run: | + make ensure-deps + + - name: Run mdlint + run: | + make mdlint diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml deleted file mode 100644 index 8696091d..00000000 --- a/.github/workflows/go.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Go - -on: - push: - branches: [main] - pull_request: - branches: [main] -jobs: - build: - runs-on: ubuntu-latest - timeout-minutes: 5 - steps: - - uses: actions/checkout@v3 - - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: "1.18" - - - name: Go Tidy - run: go mod tidy - - - name: Go Mod - run: go mod download - - - name: Go Mod Verify - run: go mod verify - - - name: Run Tests - run: go test -v ./tests/legacy diff --git a/.github/workflows/tests-daily.yaml b/.github/workflows/tests-daily.yaml new file mode 100644 index 00000000..9793e36b --- /dev/null +++ b/.github/workflows/tests-daily.yaml @@ -0,0 +1,57 @@ +name: Build - Daily Official Build + +on: + workflow_dispatch: + repository_dispatch: + types: + - manual-daily-build + schedule: + - cron: "0 9 * * *" + +jobs: + build-release: + name: Daily Build Tests + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version: "1.19" + id: go + + - name: Config git + env: + GITHUB_TOKEN: ${{ secrets.GH_RELEASE_ACCESS_TOKEN }} + shell: bash + run: | + git config --global init.defaultBranch main + git config --global pull.rebase true + git config --global url."https://git:$GITHUB_TOKEN@github.com".insteadOf "https://github.com" + + - name: Get dependencies + shell: bash + run: | + make ensure-deps + + - name: Get dependencies + shell: bash + run: | + BRANCH_NAME="response-shape-${{ github.run_id }}" + git checkout -b "$BRANCH_NAME" + + # run daily tests + go test -v -run TestDaily_ ./... + + # create a PR + git add -A ./tests/response_data + git commit -s -m "auto-generated - update Response Shapes" + git push origin "$BRANCH_NAME" + gh pr create --title "auto-generated - update API spec" --body "auto-generated - update API spec" --base "main" + sleep 30 + gh pr merge "$BRANCH_NAME" --delete-branch --squash --admin diff --git a/.github/workflows/tests-unit.yaml b/.github/workflows/tests-unit.yaml new file mode 100644 index 00000000..f63c7fd4 --- /dev/null +++ b/.github/workflows/tests-unit.yaml @@ -0,0 +1,47 @@ +name: Go Tests + +on: + pull_request: + types: + - assigned + - opened + - synchronize + - reopened +jobs: + build: + name: Go Tests + # Only run this job if we're in the main repo, not a fork. + if: github.repository == 'deepgram/deepgram-go-sdk' + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + + - name: Checkout code by commit + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.19" + + - name: Ensure dependencies installed + shell: bash + run: | + make ensure-deps + + - name: Go Tidy + shell: bash + run: go mod tidy + + - name: Go Mod + shell: bash + run: go mod download + + - name: Go Mod Verify + shell: bash + run: go mod verify + + - name: Run Tests + shell: bash + run: | + go test -v -run Test_ ./... diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..4c13deb4 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,108 @@ +linters-settings: + revive: + rules: + - name: exported + severity: error + dupl: + threshold: 250 + funlen: + lines: 125 + statements: 75 + goheader: + values: + const: + - LICENSE: MIT + regexp: + YEAR: (?:20\d{2}-2\d{3}|20\d{2}) + template: |- + Copyright {{ YEAR }} Deepgram SDK contributors. All Rights Reserved. + Use of this source code is governed by a MIT license that can be found in the LICENSE file. + SPDX-License-Identifier: {{ LICENSE }} + goconst: + min-len: 2 + min-occurrences: 2 + gocritic: + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + # disabled-checks: + # - ifElseChain + # - octalLiteral + # - whyNoLint + # - wrapperFunc + settings: + rangeValCopy: + sizeThreshold: 1024 + gocyclo: + min-complexity: 20 + goimports: + local-prefixes: github.com/deepgram/deepgram-go-sdk + govet: + check-shadowing: true + settings: + printf: + funcs: + - (github.com/aunum/log").Infof + - (github.com/aunum/log").Warnf + - (github.com/aunum/log").Errorf + - (github.com/aunum/log").Fatalf + misspell: + locale: US + nolintlint: + allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space) + allow-unused: false # report any unused nolint directives + require-explanation: false # don't require an explanation for nolint directives + require-specific: false # don't require nolint directives to be specific about which linter is being skipped + +linters: + disable-all: true + enable: + - bodyclose + - deadcode + - dupl + - errcheck + - funlen + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - goprintffuncname + - gosec + - govet + - ineffassign + - misspell + - nakedret + - noctx + - nolintlint + - revive + - staticcheck + - structcheck + - stylecheck + - typecheck + - unconvert + - unparam + - varcheck + - whitespace + +issues: + exclude: + - 'declaration of "(err|ctx)" shadows declaration at' + - 'unnamedResult: consider giving a name to these results' + - 'G306: Expect WriteFile permissions to be 0600 or less' + + exclude-rules: + - path: _test\.go + linters: + - dupl + - gocritic + - funlen + - gocyclo + # https://github.com/go-critic/go-critic/issues/926 + - linters: + - gocritic + text: "unnecessaryDefer:" diff --git a/.markdownlintrc b/.markdownlintrc new file mode 100644 index 00000000..a7470110 --- /dev/null +++ b/.markdownlintrc @@ -0,0 +1,7 @@ +{ + "default": true, + "line_length": false, + "MD024": { "allow_different_nesting": true }, + "MD026": { "punctuation": ".,;:!" }, + "MD046": { "style": "fenced" } +} diff --git a/.yamllintconfig.yaml b/.yamllintconfig.yaml new file mode 100644 index 00000000..616eee0a --- /dev/null +++ b/.yamllintconfig.yaml @@ -0,0 +1,18 @@ +--- +extends: relaxed + +rules: + line-length: disable + trailing-spaces: enable + new-line-at-end-of-file: enable + new-lines: + type: unix + indentation: disable + key-duplicates: disable + empty-lines: enable + colons: disable + commas: disable + +ignore: | + /deepgram-go-sdk/.github/ISSUE_TEMPLATE/config.yml + /deepgram-go-sdk/addons/**/*/ diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..fa581829 --- /dev/null +++ b/Makefile @@ -0,0 +1,124 @@ +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +# detect the build OS +ifeq ($(OS),Windows_NT) + build_OS := Windows + NUL = NUL +else + build_OS := $(shell uname -s 2>/dev/null || echo Unknown) + NUL = /dev/null +endif + +.DEFAULT_GOAL:=help + +##### GLOBAL +ROOT_DIR := $(shell git rev-parse --show-toplevel) +GO := go +GOOS ?= $(shell go env GOOS) +GOARCH ?= $(shell go env GOARCH) +GOHOSTOS ?= $(shell go env GOHOSTOS) +GOHOSTARCH ?= $(shell go env GOHOSTARCH) + +# Add tooling binaries here and in hack/tools/Makefile +TOOLS_BIN_DIR := $(shell mktemp -d) +GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint + +help: #### Display help + @echo '' + @echo 'Syntax: make ' + @awk 'BEGIN {FS = ":.*## "; printf "\nTargets:\n"} /^[a-zA-Z_-]+:.*?#### / { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + @echo '' +##### GLOBAL + +##### BUILD +export GOHOSTOS +export GOHOSTARCH +export GO +export GOLANGCI_LINT +##### BUILD + +##### LINTING TARGETS +.PHONY: version +version: #### display version of components + @echo 'ROOT_DIR: $(ROOT_DIR)' + @echo 'GOOS: $(GOOS)' + @echo 'GOARCH: $(GOARCH)' + @echo 'go version: $(shell go version)' + +.PHONY: check lint mdlint shellcheck actionlint yamllint ### Performs all of the checks, lint'ing, etc available +check: lint mdlint shellcheck actionlint yamllint + +.PHONY: ensure-deps +ensure-deps: #### Ensure that all required dependency utilities are downloaded or installed + hack/ensure-deps/ensure-dependencies.sh + +GO_MODULES=$(shell find . -path "*/go.mod" | xargs -I _ dirname _) + +# get-deps: +# @for i in $(GO_MODULES); do \ +# echo "-- Getting deps for $$i --"; \ +# working_dir=`pwd`; \ +# if [ "$${i}" = "." ]; then \ +# go mod tidy; \ +# else \ +# cd $${i}; \ +# $(MAKE) get-deps || exit 1; \ +# cd $$working_dir; \ +# fi; \ +# done + +# verify-modules: get-deps +# @for i in $(GO_MODULES); do \ +# echo "-- Verifying modules for $$i --"; \ +# working_dir=`pwd`; \ +# cd $${i}; \ +# if [ "`git diff --name-only HEAD -- go.sum go.mod`" != "" ]; then \ +# echo "go module files in $$i directory are out of date, run 'go mod tidy' and commit the changes"; exit 1; \ +# fi; \ +# cd $$working_dir; \ +# done + +lint: tools #### Performs Golang programming lint + @for i in $(GO_MODULES); do \ + echo "-- Linting $$i --"; \ + working_dir=`pwd`; \ + if [ "$${i}" = "." ]; then \ + $(GOLANGCI_LINT) run -v --timeout=5m; \ + else \ + cd $${i}; \ + $(MAKE) lint || exit 1; \ + cd $$working_dir; \ + fi; \ + done; \ + CHECK=$$(grep -r --include="*.go" ioutil ./); \ + if [ -n "$${CHECK}" ]; then \ + echo "ioutil is deprecated, use io or os replacements"; \ + echo "$${CHECK}"; \ + exit 1; \ + fi + +mdlint: #### Performs Markdown lint + # mdlint rules with common errors and possible fixes can be found here: + # https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md + hack/check/check-mdlint.sh + +shellcheck: #### Performs bash/shell lint + hack/check/check-shell.sh + +yamllint: #### Performs yaml lint + hack/check/check-yaml.sh + +actionlint: #### Performs GitHub Actions lint + actionlint +##### LINTING TARGETS + +##### Tooling Binaries +TOOLS_DIR := $(ROOT_DIR)/hack/check/tools + +tools: $(GOLANGCI_LINT) +.PHONY: $(GOLANGCI_LINT) +$(GOLANGCI_LINT): + make -C $(TOOLS_DIR) $(@F) +##### Tooling Binaries diff --git a/README.md b/README.md index 675ad5af..8659eb20 100644 --- a/README.md +++ b/README.md @@ -4,57 +4,62 @@ Official Go SDK for [Deepgram](https://www.deepgram.com/). Start building with our powerful transcription & speech understanding API. -* [Deepgram Go SDK](#deepgram-go-sdk) -* [SDK Documentation](#sdk-documentation) -* [Getting an API Key](#getting-an-api-key) -* [Installation](#installation) -* [Requirements](#requirements) -* [Quickstarts](#quickstarts) - * [PreRecorded Audio Transcription Quickstart](#prerecorded-audio-transcription-quickstart) - * [Live Audio Transcription Quickstart](#live-audio-transcription-quickstart) -* [Examples](#examples) -* [Logging](#logging) -* [Testing](#testing) -* [Backwards Compatability](#backwards-compatibility) -* [Development and Contributing](#development-and-contributing) -* [Getting Help](#getting-help) - -# SDK Documentation +- [Deepgram Go SDK](#deepgram-go-sdk) +- [SDK Documentation](#sdk-documentation) +- [Getting an API Key](#getting-an-api-key) +- [Installation](#installation) +- [Requirements](#requirements) +- [Quickstarts](#quickstarts) + - [PreRecorded Audio Transcription Quickstart](#prerecorded-audio-transcription-quickstart) + - [Live Audio Transcription Quickstart](#live-audio-transcription-quickstart) +- [Examples](#examples) +- [Logging](#logging) +- [Testing](#testing) +- [Backwards Compatability](#backwards-compatibility) +- [Development and Contributing](#development-and-contributing) +- [Getting Help](#getting-help) + +## SDK Documentation This SDK implements the Deepgram API found at [https://developers.deepgram.com](https://developers.deepgram.com). Documentation for specifics about the structs, interfaces, and functions of this SDK can be found here: [Go SDK Documentation](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main) For documentation relating to Live Audio Transcription: -- Live Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/live -- Live API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1 - - Live API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1/interfaces + +- Live Client - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/live](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/live) +- Live API - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1) +- Live API Interfaces - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1/interfaces](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/live/v1/interfaces) For documentation relating to PreRecorded Audio Transcription and Intelligence: -- PreRecorded Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/prerecorded -- PreRecorded API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1 - - PreRecorded API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1/interfaces + +- PreRecorded Client - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/prerecorded](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/prerecorded) +- PreRecorded API - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1) +- PreRecorded API Interfaces - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1/interfaces](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/prerecorded/v1/interfaces) For documentation relating to Text-to-Speech: -- Speak Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/speak -- Speak API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/speak/v1 - - Speak API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/speak/v1/interfaces + +- Speak Client - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/speak](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/speak) +- Speak API - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/speak/v1](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/speak/v1) +- Speak API Interfaces - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/speak/v1/interfaces](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/speak/v1/interfaces) For documentation relating to Text Intelligence: -- Analyze Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/analyze -- Analyze API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/analyze/v1 - - Analyze API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/analyze/v1/interfaces + +- Analyze Client - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/analyze](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/client/analyze) +- Analyze API - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/analyze/v1](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/analyze/v1) +- Analyze API Interfaces - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/analyze/v1/interfaces](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/analyze/v1/interfaces) For documentation relating to Manage API: -- Management Client - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live -- Manage API - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/manage/v1 - - Manage API Interfaces - https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live/v1/interfaces -# Getting an API Key +- Management Client - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live) +- Manage API - [https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/manage/v1](https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/api/manage/v1) +- Manage API Interfaces -[https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live/v1/interfaces]( https://pkg.go.dev/github.com/deepgram/deepgram-go-sdk@main/pkg/manage/live/v1/interfaces) + +## Getting an API Key 🔑 To access the Deepgram API you will need a [free Deepgram API Key](https://console.deepgram.com/signup?jump=keys). -# Installation +## Installation To incorporate this SDK into your project's `go.mod` file, run the following command from your repo: @@ -62,15 +67,15 @@ To incorporate this SDK into your project's `go.mod` file, run the following com go get github.com/deepgram/deepgram-go-sdk ``` -# Requirements +## Requirements -[Go](https://go.dev/doc/install) (version ^1.18) +[Go](https://go.dev/doc/install) (version ^1.19) -# Quickstarts +## Quickstarts This SDK aims to reduce complexity and abtract/hide some internal Deepgram details that clients shouldn't need to know about. However you can still tweak options and settings if you need. -## PreRecorded Audio Transcription Quickstart +### PreRecorded Audio Transcription Quickstart You can find a [walkthrough](https://developers.deepgram.com/docs/pre-recorded-audio-transcription) on our documentation site. Transcribing Pre-Recorded Audio can be done using the following sample code: @@ -84,31 +89,31 @@ dg := prerecorded.New(c) // transcription options options := PreRecordedTranscriptionOptions{ - Punctuate: true, - Diarize: true, - Language: "en-US", + Punctuate: true, + Diarize: true, + Language: "en-US", } // send URL URL := "https://my-domain.com/files/my-conversation.mp3" res, err := dg.FromURL(ctx, URL, options) if err != nil { - log.Fatalf("FromURL failed. Err: %v\n", err) + log.Fatalf("FromURL failed. Err: %v\n", err) } ``` -## Live Audio Transcription Quickstart +### Live Audio Transcription Quickstart You can find a [walkthrough](https://developers.deepgram.com/docs/live-streaming-audio-transcription) on our documentation site. Transcribing Live Audio can be done using the following sample code: ```go // options transcriptOptions := interfaces.LiveTranscriptionOptions{ - Language: "en-US", - Punctuate: true, - Encoding: "linear16", - Channels: 1, - Sample_rate: 16000, + Language: "en-US", + Punctuate: true, + Encoding: "linear16", + Channels: 1, + Sample_rate: 16000, } // create a callback for transcription messages @@ -118,54 +123,54 @@ transcriptOptions := interfaces.LiveTranscriptionOptions{ // create the client dgClient, err := client.NewWithDefaults(ctx, transcriptOptions, callback) if err != nil { - log.Println("ERROR creating LiveTranscription connection:", err) - return + log.Println("ERROR creating LiveTranscription connection:", err) + return } // call connect! wsconn := dgClient.Connect() if wsconn == nil { - log.Println("Client.Connect failed") - os.Exit(1) + log.Println("Client.Connect failed") + os.Exit(1) } ``` -# Examples +## Examples -There are examples for **every** API call in this SDK. You can find all of these examples in the [examples folder](https://github.com/deepgram/deepgram-go-sdk/tree/main/examples) at the root of this repo. +There are examples for **every*- API call in this SDK. You can find all of these examples in the [examples folder](https://github.com/deepgram/deepgram-go-sdk/tree/main/examples) at the root of this repo. These examples provide: -- Speech-to-Text: PreRecorded Audio: +Speech-to-Text: PreRecorded Audio: - - From an Audio File - [examples/prerecorded/file](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/prerecorded/file/main.go) - - From an URL - [examples/prerecorded/url](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/prerecorded/url/main.go) - - From an Audio Stream - [examples/prerecorded/stream](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/prerecorded/stream/main.go) +- From an Audio File - [examples/prerecorded/file](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/prerecorded/file/main.go) +- From an URL - [examples/prerecorded/url](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/prerecorded/url/main.go) +- From an Audio Stream - [examples/prerecorded/stream](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/prerecorded/stream/main.go) -- Speech-to-Text: Live Audio: +Speech-to-Text: Live Audio: - - From a Microphone - [examples/streaming/microphone](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/streaming/microphone/main.go) - - From an HTTP Endpoint - [examples/streaming/http](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/streaming/http/main.go) +- From a Microphone - [examples/streaming/microphone](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/streaming/microphone/main.go) +- From an HTTP Endpoint - [examples/streaming/http](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/streaming/http/main.go) -- Text-to-Speech +Text-to-Speech - - Save audio to a Path - [examples/speak/save](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/speak/save/main.go) - - Save audio to a user-defined Writer - [examples/speak/file](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/speak/file/main.go) - - Save audio to a Stream/Buffer - [examples/speak/stream](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/speak/stream/main.go) +- Save audio to a Path - [examples/speak/save](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/speak/save/main.go) +- Save audio to a user-defined Writer - [examples/speak/file](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/speak/file/main.go) +- Save audio to a Stream/Buffer - [examples/speak/stream](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/speak/stream/main.go) -- Management API exercise the full [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations for: +Management API exercise the full [CRUD](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete) operations for: - - Balances - [examples/manage/balances](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/balances/main.go) - - Invitations - [examples/manage/invitations](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/invitations/main.go) - - Keys - [examples/manage/keys](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/keys/main.go) - - Members - [examples/manage/members](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/members/main.go) - - Projects - [examples/manage/projects](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/projects/main.go) - - Scopes - [examples/manage/scopes](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/scopes/main.go) - - Usage - [examples/manage/usage](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/usage/main.go) +- Balances - [examples/manage/balances](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/balances/main.go) +- Invitations - [examples/manage/invitations](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/invitations/main.go) +- Keys - [examples/manage/keys](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/keys/main.go) +- Members - [examples/manage/members](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/members/main.go) +- Projects - [examples/manage/projects](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/projects/main.go) +- Scopes - [examples/manage/scopes](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/scopes/main.go) +- Usage - [examples/manage/usage](https://github.com/deepgram/deepgram-go-sdk/blob/main/examples/manage/usage/main.go) To run each example set the `DEEPGRAM_API_KEY` as an environment variable, then `cd` into each example folder and execute the example: `go run main.go`. -# Logging +## Logging This SDK provides logging as a means to troubleshoot and debug issues encountered. By default, this SDK will enable `Information` level messages and higher (ie `Warning`, `Error`, etc) when you initialize the library as follows: @@ -182,21 +187,21 @@ client.Init(client.InitLib{ }) ``` -# Testing +## Testing TBD -# Backwards Compatibility +## Backwards Compatibility Older SDK versions will receive Priority 1 (P1) bug support only. Security issues, both in our code and dependencies, are promptly addressed. Significant bugs without clear workarounds are also given priority attention. -## Development and Contributing +### Development and Contributing Interested in contributing? We ❤️ pull requests! To make sure our community is safe for all, be sure to review and agree to our [Code of Conduct](https://github.com/deepgram/deepgram-go-sdk/blob/main/.github/CODE_OF_CONDUCT.md). Then see the [Contribution](https://github.com/deepgram/deepgram-go-sdk/blob/main/.github/CONTRIBUTING.md) guidelines for more information. -## Getting Help +### Getting Help We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either: diff --git a/docs.go b/docs.go index 46811a31..22cf92eb 100644 --- a/docs.go +++ b/docs.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/examples/analyze/intent/main.go b/examples/analyze/intent/main.go index 5b0d674c..3d3261af 100644 --- a/examples/analyze/intent/main.go +++ b/examples/analyze/intent/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the anaylze options - rOptions := interfaces.AnalyzeOptions{ + rOptions := &interfaces.AnalyzeOptions{ Language: "en", Intents: true, } @@ -54,10 +54,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/analyze/sentiment/main.go b/examples/analyze/sentiment/main.go index cdb8fe61..ff51baf8 100644 --- a/examples/analyze/sentiment/main.go +++ b/examples/analyze/sentiment/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the anaylze options - rOptions := interfaces.AnalyzeOptions{ + rOptions := &interfaces.AnalyzeOptions{ Language: "en", Sentiment: true, } @@ -54,10 +54,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/analyze/summary/main.go b/examples/analyze/summary/main.go index 72c4dce7..c04fbc25 100644 --- a/examples/analyze/summary/main.go +++ b/examples/analyze/summary/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the anaylze options - rOptions := interfaces.AnalyzeOptions{ + rOptions := &interfaces.AnalyzeOptions{ Language: "en", Summarize: true, } @@ -54,10 +54,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/analyze/topic/main.go b/examples/analyze/topic/main.go index 66642fe8..e58d71e8 100644 --- a/examples/analyze/topic/main.go +++ b/examples/analyze/topic/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the anaylze options - rOptions := interfaces.AnalyzeOptions{ + rOptions := &interfaces.AnalyzeOptions{ Language: "en", Topics: true, } @@ -54,10 +54,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/manage/balances/main.go b/examples/manage/balances/main.go index 4a771b8d..d02774ae 100644 --- a/examples/manage/balances/main.go +++ b/examples/manage/balances/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -33,16 +33,16 @@ func main() { os.Exit(1) } - var projectId string + var projectID string for _, item := range respProject.Projects { - projectId = item.ProjectID + projectID = item.ProjectID name := item.Name - fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectId) + fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectID) break } // list balances - respList, err := mgClient.ListBalances(ctx, projectId) + respList, err := mgClient.ListBalances(ctx, projectID) if err != nil { fmt.Printf("ListBalances failed. Err: %v\n", err) os.Exit(1) @@ -57,7 +57,7 @@ func main() { } // get first balance - respGet, err := mgClient.GetBalance(ctx, projectId, id) + respGet, err := mgClient.GetBalance(ctx, projectID, id) if err != nil { fmt.Printf("GetBalance failed. Err: %v\n", err) os.Exit(1) diff --git a/examples/manage/invitations/main.go b/examples/manage/invitations/main.go index 5ab39c09..dff7b037 100644 --- a/examples/manage/invitations/main.go +++ b/examples/manage/invitations/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -32,16 +32,16 @@ func main() { os.Exit(1) } - var projectId string + var projectID string for _, item := range respList.Projects { - projectId = item.ProjectID + projectID = item.ProjectID name := item.Name - fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectId) + fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectID) break } // list invitations - respGet, err := mgClient.ListInvitations(ctx, projectId) + respGet, err := mgClient.ListInvitations(ctx, projectID) if err != nil { fmt.Printf("ListInvitations failed. Err: %v\n", err) os.Exit(1) @@ -58,7 +58,7 @@ func main() { } // send invite - respMessage, err := mgClient.SendInvitation(ctx, projectId, &interfaces.InvitationRequest{ + respMessage, err := mgClient.SendInvitation(ctx, projectID, &interfaces.InvitationRequest{ Email: "spam@spam.com", Scope: "member", }) @@ -69,7 +69,7 @@ func main() { fmt.Printf("SendInvitation() - Result: %s\n", respMessage.Message) // list invitations - respGet, err = mgClient.ListInvitations(ctx, projectId) + respGet, err = mgClient.ListInvitations(ctx, projectID) if err != nil { fmt.Printf("ListInvitations failed. Err: %v\n", err) os.Exit(1) @@ -86,7 +86,7 @@ func main() { } // delete invitation - respMessage, err = mgClient.DeleteInvitation(ctx, projectId, "spam@spam.com") + respMessage, err = mgClient.DeleteInvitation(ctx, projectID, "spam@spam.com") if err != nil { fmt.Printf("DeleteInvitation failed. Err: %v\n", err) os.Exit(1) @@ -94,7 +94,7 @@ func main() { fmt.Printf("DeleteInvitation() - Result: %s\n", respMessage.Message) // list invitations - respGet, err = mgClient.ListInvitations(ctx, projectId) + respGet, err = mgClient.ListInvitations(ctx, projectID) if err != nil { fmt.Printf("ListInvitations failed. Err: %v\n", err) os.Exit(1) @@ -112,7 +112,7 @@ func main() { // There isnt an API call to add a member to a project. So will leave this commented out as an example // Leave Project - // respMessage, err = mgClient.LeaveProject(ctx, projectId) + // respMessage, err = mgClient.LeaveProject(ctx, projectID) // if err != nil { // fmt.Printf("LeaveProject failed. Err: %v\n", err) // os.Exit(1) diff --git a/examples/manage/keys/main.go b/examples/manage/keys/main.go index 78c894d0..bcdc7e02 100644 --- a/examples/manage/keys/main.go +++ b/examples/manage/keys/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -32,16 +32,16 @@ func main() { os.Exit(1) } - var projectId string + var projectID string for _, item := range respList.Projects { - projectId = item.ProjectID + projectID = item.ProjectID name := item.Name - fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectId) + fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectID) break } // list keys - respGet, err := mgClient.ListKeys(ctx, projectId) + respGet, err := mgClient.ListKeys(ctx, projectID) if err != nil { fmt.Printf("ListKeys failed. Err: %v\n", err) os.Exit(1) @@ -54,7 +54,7 @@ func main() { } // create key - respCreate, err := mgClient.CreateKey(ctx, projectId, &interfaces.KeyCreateRequest{ + respCreate, err := mgClient.CreateKey(ctx, projectID, &interfaces.KeyCreateRequest{ Comment: "My Test", Scopes: []string{"onprem:products"}, }) @@ -65,7 +65,7 @@ func main() { fmt.Printf("CreateKey() - Name: %s\n", respCreate.Comment) // list keys - respGet, err = mgClient.ListKeys(ctx, projectId) + respGet, err = mgClient.ListKeys(ctx, projectID) if err != nil { fmt.Printf("ListKeys failed. Err: %v\n", err) os.Exit(1) @@ -78,7 +78,7 @@ func main() { } // get key - respKey, err := mgClient.GetKey(ctx, projectId, respCreate.APIKeyID) + respKey, err := mgClient.GetKey(ctx, projectID, respCreate.APIKeyID) if err != nil { fmt.Printf("GetKey failed. Err: %v\n", err) os.Exit(1) @@ -86,7 +86,7 @@ func main() { fmt.Printf("GetKey() - ID: %s, Comment: %s\n", respKey.APIKey.APIKeyID, respKey.APIKey.Comment) // delete key - respMessage, err := mgClient.DeleteKey(ctx, projectId, respKey.APIKey.APIKeyID) + respMessage, err := mgClient.DeleteKey(ctx, projectID, respKey.APIKey.APIKeyID) if err != nil { fmt.Printf("DeleteKey failed. Err: %v\n", err) os.Exit(1) @@ -94,7 +94,7 @@ func main() { fmt.Printf("DeleteKey() - Name: %s\n", respMessage.Message) // list keys - respGet, err = mgClient.ListKeys(ctx, projectId) + respGet, err = mgClient.ListKeys(ctx, projectID) if err != nil { fmt.Printf("ListKeys failed. Err: %v\n", err) os.Exit(1) diff --git a/examples/manage/members/main.go b/examples/manage/members/main.go index f107b1b9..4e73fc54 100644 --- a/examples/manage/members/main.go +++ b/examples/manage/members/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -35,33 +35,33 @@ func main() { os.Exit(1) } - var projectId string + var projectID string for _, item := range respList.Projects { - projectId = item.ProjectID + projectID = item.ProjectID name := item.Name - fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectId) + fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectID) break } // list members - respGet, err := mgClient.ListMembers(ctx, projectId) + respGet, err := mgClient.ListMembers(ctx, projectID) if err != nil { fmt.Printf("ListMembers failed. Err: %v\n", err) os.Exit(1) } - var delMemberId string + var delmemberID string for _, item := range respGet.Members { - memberId := item.MemberID + memberID := item.MemberID email := item.Email - fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberId, email) + fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberID, email) if email == TestAccountName { - delMemberId = memberId + delmemberID = memberID } } - if delMemberId == "" { + if delmemberID == "" { fmt.Printf("This example requires a member who already email is %s.\n", TestAccountName) fmt.Printf("This is required to exercise the RemoveMember function.\n") fmt.Printf("In the absence of this, this example will exit early.\n") @@ -69,7 +69,7 @@ func main() { } // remove member - respMessage, err := mgClient.RemoveMember(ctx, projectId, delMemberId) + respMessage, err := mgClient.RemoveMember(ctx, projectID, delmemberID) if err != nil { fmt.Printf("RemoveMember failed. Err: %v\n", err) os.Exit(1) @@ -77,15 +77,15 @@ func main() { fmt.Printf("RemoveMember() - Name: %s\n", respMessage.Message) // list members - respGet, err = mgClient.ListMembers(ctx, projectId) + respGet, err = mgClient.ListMembers(ctx, projectID) if err != nil { fmt.Printf("ListMembers failed. Err: %v\n", err) os.Exit(1) } for _, item := range respGet.Members { - memberId := item.MemberID + memberID := item.MemberID email := item.Email - fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberId, email) + fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberID, email) } } diff --git a/examples/manage/projects/main.go b/examples/manage/projects/main.go index 941a8f38..c1d854ad 100644 --- a/examples/manage/projects/main.go +++ b/examples/manage/projects/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -41,7 +41,7 @@ func main() { break } - // if deleteId == "" { + // if deleteID == "" { // fmt.Printf("This example requires a project who already exists where \"DELETE-ME\" is in the name.\n") // fmt.Printf("This is required to exercise the UpdateProject and DeleteProject function.\n") // fmt.Printf("In the absence of this, this example will exit early.\n") @@ -93,7 +93,7 @@ func main() { fmt.Printf("GetProject() - Name: %s\n", respGet.Name) // delete project - // respMessage, err = mgClient.DeleteProject(ctx, deleteId) + // respMessage, err = mgClient.DeleteProject(ctx, deleteID) // if err != nil { // fmt.Printf("DeleteProject failed. Err: %v\n", err) // os.Exit(1) diff --git a/examples/manage/scopes/main.go b/examples/manage/scopes/main.go index 7b86ecf0..baa9b21a 100644 --- a/examples/manage/scopes/main.go +++ b/examples/manage/scopes/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -36,16 +36,16 @@ func main() { os.Exit(1) } - var projectId string + var projectID string for _, item := range respList.Projects { - projectId = item.ProjectID + projectID = item.ProjectID name := item.Name - fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectId) + fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectID) break } // list members - respGet, err := mgClient.ListMembers(ctx, projectId) + respGet, err := mgClient.ListMembers(ctx, projectID) if err != nil { fmt.Printf("ListMembers failed. Err: %v\n", err) os.Exit(1) @@ -53,15 +53,15 @@ func main() { var updateID string for _, item := range respGet.Members { - memberId := item.MemberID + memberID := item.MemberID email := item.Email - fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberId, email) + fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberID, email) for _, scope := range item.Scopes { fmt.Printf("Scope: %s\n", scope) } if email == TestAccountName { - updateID = memberId + updateID = memberID } } @@ -73,7 +73,7 @@ func main() { } // get scope - respScope, err := mgClient.GetMemberScopes(ctx, projectId, updateID) + respScope, err := mgClient.GetMemberScopes(ctx, projectID, updateID) if err != nil { fmt.Printf("GetMemberScopes failed. Err: %v\n", err) os.Exit(1) @@ -85,7 +85,7 @@ func main() { } // update scope - respMessage, err := mgClient.UpdateMemberScopes(ctx, projectId, updateID, &interfaces.ScopeUpdateRequest{ + respMessage, err := mgClient.UpdateMemberScopes(ctx, projectID, updateID, &interfaces.ScopeUpdateRequest{ Scope: "admin", }) if err != nil { @@ -95,23 +95,23 @@ func main() { fmt.Printf("UpdateMemberScopes() - Name: %s\n", respMessage.Message) // list members - respGet, err = mgClient.ListMembers(ctx, projectId) + respGet, err = mgClient.ListMembers(ctx, projectID) if err != nil { fmt.Printf("ListMembers failed. Err: %v\n", err) os.Exit(1) } for _, item := range respGet.Members { - memberId := item.MemberID + memberID := item.MemberID email := item.Email - fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberId, email) + fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberID, email) for _, scope := range item.Scopes { fmt.Printf("Scope: %s\n", scope) } } // update scope - respMessage, err = mgClient.UpdateMemberScopes(ctx, projectId, updateID, &interfaces.ScopeUpdateRequest{ + respMessage, err = mgClient.UpdateMemberScopes(ctx, projectID, updateID, &interfaces.ScopeUpdateRequest{ Scope: "member", }) if err != nil { @@ -121,16 +121,16 @@ func main() { fmt.Printf("UpdateMemberScopes() - Name: %s\n", respMessage.Message) // list members - respGet, err = mgClient.ListMembers(ctx, projectId) + respGet, err = mgClient.ListMembers(ctx, projectID) if err != nil { fmt.Printf("ListMembers failed. Err: %v\n", err) os.Exit(1) } for _, item := range respGet.Members { - memberId := item.MemberID + memberID := item.MemberID email := item.Email - fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberId, email) + fmt.Printf("ListMembers() - ID: %s, Scope: %s\n", memberID, email) for _, scope := range item.Scopes { fmt.Printf("Scope: %s\n", scope) } diff --git a/examples/manage/usage/main.go b/examples/manage/usage/main.go index 83f31bd9..32e96362 100644 --- a/examples/manage/usage/main.go +++ b/examples/manage/usage/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -37,16 +37,16 @@ func main() { os.Exit(1) } - var projectId string + var projectID string for _, item := range respList.Projects { - projectId = item.ProjectID + projectID = item.ProjectID name := item.Name - fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectId) + fmt.Printf("ListProjects() - Name: %s, ID: %s\n", name, projectID) break } // list requests - respRequestGet, err := mgClient.ListRequests(ctx, projectId, &interfaces.UsageListRequest{}) + respRequestGet, err := mgClient.ListRequests(ctx, projectID, &interfaces.UsageListRequest{}) if err != nil { fmt.Printf("ListRequests failed. Err: %v\n", err) os.Exit(1) @@ -60,21 +60,21 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) - var requestId string + var requestID string for _, item := range respRequestGet.Requests { - requestId = item.RequestID + requestID = item.RequestID break } // get request - respRequest, err := mgClient.GetRequest(ctx, projectId, requestId) + respRequest, err := mgClient.GetRequest(ctx, projectID, requestID) if err != nil { fmt.Printf("GetRequest failed. Err: %v\n", err) os.Exit(1) @@ -88,15 +88,15 @@ func main() { } // make the JSON pretty - prettyJson, err = prettyjson.Format(data) + prettyJSON, err = prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) // get fields - respFieldsGet, err := mgClient.GetFields(ctx, projectId, &interfaces.UsageListRequest{}) + respFieldsGet, err := mgClient.GetFields(ctx, projectID, &interfaces.UsageListRequest{}) if err != nil { fmt.Printf("GetFields failed. Err: %v\n", err) os.Exit(1) @@ -110,15 +110,15 @@ func main() { } // make the JSON pretty - prettyJson, err = prettyjson.Format(data) + prettyJSON, err = prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) // get usage - respUsageGet, err := mgClient.GetUsage(ctx, projectId, &interfaces.UsageRequest{}) + respUsageGet, err := mgClient.GetUsage(ctx, projectID, &interfaces.UsageRequest{}) if err != nil { fmt.Printf("GetUsage failed. Err: %v\n", err) os.Exit(1) @@ -132,10 +132,10 @@ func main() { } // make the JSON pretty - prettyJson, err = prettyjson.Format(data) + prettyJSON, err = prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/prerecorded/callback/callback/main.go b/examples/prerecorded/callback/callback/main.go index 744a271a..1230baef 100644 --- a/examples/prerecorded/callback/callback/main.go +++ b/examples/prerecorded/callback/callback/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -37,7 +37,7 @@ func main() { res, err := dg.FromURL( ctx, url, - interfaces.PreRecordedTranscriptionOptions{ + &interfaces.PreRecordedTranscriptionOptions{ Punctuate: true, Diarize: true, Language: "en-US", @@ -56,10 +56,10 @@ func main() { os.Exit(1) } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/prerecorded/callback/endpoint/Makefile b/examples/prerecorded/callback/endpoint/Makefile new file mode 100644 index 00000000..5479c9a9 --- /dev/null +++ b/examples/prerecorded/callback/endpoint/Makefile @@ -0,0 +1,65 @@ +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +# detect the build OS +ifeq ($(OS),Windows_NT) + build_OS := Windows + NUL = NUL +else + build_OS := $(shell uname -s 2>/dev/null || echo Unknown) + NUL = /dev/null +endif + +.DEFAULT_GOAL:=help + +##### GLOBAL +ROOT_DIR := $(shell git rev-parse --show-toplevel) +GO := go +GOOS ?= $(shell go env GOOS) +GOARCH ?= $(shell go env GOARCH) +GOHOSTOS ?= $(shell go env GOHOSTOS) +GOHOSTARCH ?= $(shell go env GOHOSTARCH) + +# Add tooling binaries here and in hack/tools/Makefile +TOOLS_BIN_DIR := $(shell mktemp -d) +GOLANGCI_LINT := $(TOOLS_BIN_DIR)/golangci-lint + +help: #### Display help + @echo '' + @echo 'Syntax: make ' + @awk 'BEGIN {FS = ":.*## "; printf "\nTargets:\n"} /^[a-zA-Z_-]+:.*?#### / { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + @echo '' +##### GLOBAL + +##### BUILD +export GOHOSTOS +export GOHOSTARCH +export GO +export GOLANGCI_LINT +##### BUILD + +##### LINTING TARGETS +.PHONY: version +version: #### display version of components + @echo 'ROOT_DIR: $(ROOT_DIR)' + @echo 'GOOS: $(GOOS)' + @echo 'GOARCH: $(GOARCH)' + @echo 'go version: $(shell go version)' + +.PHONY: lint mdlint shellcheck actionlint yamllint +lint: + @echo 'Noop' + +mdlint: + @echo 'Noop' + +shellcheck: + @echo 'Noop' + +actionlint: + @echo 'Noop' + +yamllint: + @echo 'Noop' + diff --git a/examples/prerecorded/callback/endpoint/main.go b/examples/prerecorded/callback/endpoint/main.go index 355dd901..bcc3684e 100644 --- a/examples/prerecorded/callback/endpoint/main.go +++ b/examples/prerecorded/callback/endpoint/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -66,13 +66,13 @@ func (p *SampleProxy) postPrerecorded(c *gin.Context) { return } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) return } - fmt.Printf("Response:\n%s\n\n", string(prettyJson)) + fmt.Printf("Response:\n%s\n\n", string(prettyJSON)) c.IndentedJSON(http.StatusOK, "") } diff --git a/examples/prerecorded/file/main.go b/examples/prerecorded/file/main.go index ffe8601d..a92d8115 100644 --- a/examples/prerecorded/file/main.go +++ b/examples/prerecorded/file/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.PreRecordedTranscriptionOptions{ + options := &interfaces.PreRecordedTranscriptionOptions{ Punctuate: true, Diarize: true, Language: "en-US", @@ -39,7 +39,7 @@ func main() { } // create a Deepgram client - c := client.New("", interfaces.ClientOptions{ + c := client.New("", &interfaces.ClientOptions{ Host: "https://api.deepgram.com", }) dg := prerecorded.New(c) @@ -72,12 +72,12 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) // dump example VTT vtt, err := res.ToWebVTT() diff --git a/examples/prerecorded/intent/main.go b/examples/prerecorded/intent/main.go index 818a915b..bd64d402 100644 --- a/examples/prerecorded/intent/main.go +++ b/examples/prerecorded/intent/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.PreRecordedTranscriptionOptions{ + options := &interfaces.PreRecordedTranscriptionOptions{ Model: "nova-2", Punctuate: true, Language: "en-US", @@ -57,10 +57,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/prerecorded/sentiment/main.go b/examples/prerecorded/sentiment/main.go index 8a52b14f..2cce1892 100644 --- a/examples/prerecorded/sentiment/main.go +++ b/examples/prerecorded/sentiment/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.PreRecordedTranscriptionOptions{ + options := &interfaces.PreRecordedTranscriptionOptions{ Model: "nova-2", Punctuate: true, Language: "en-US", @@ -57,10 +57,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/prerecorded/stream/main.go b/examples/prerecorded/stream/main.go index 65224753..02ef28bf 100644 --- a/examples/prerecorded/stream/main.go +++ b/examples/prerecorded/stream/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.PreRecordedTranscriptionOptions{ + options := &interfaces.PreRecordedTranscriptionOptions{ Punctuate: true, Diarize: true, Language: "en-US", @@ -64,10 +64,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/prerecorded/summary/main.go b/examples/prerecorded/summary/main.go index 6f58fb61..61415ed1 100644 --- a/examples/prerecorded/summary/main.go +++ b/examples/prerecorded/summary/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.PreRecordedTranscriptionOptions{ + options := &interfaces.PreRecordedTranscriptionOptions{ Model: "nova-2", Punctuate: true, Language: "en-US", @@ -57,10 +57,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/prerecorded/topic/main.go b/examples/prerecorded/topic/main.go index 387c93e3..a4bdbb0f 100644 --- a/examples/prerecorded/topic/main.go +++ b/examples/prerecorded/topic/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.PreRecordedTranscriptionOptions{ + options := &interfaces.PreRecordedTranscriptionOptions{ Model: "nova-2", Punctuate: true, Language: "en-US", @@ -57,10 +57,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/prerecorded/url/main.go b/examples/prerecorded/url/main.go index 59095710..10e31bc6 100644 --- a/examples/prerecorded/url/main.go +++ b/examples/prerecorded/url/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -29,7 +29,7 @@ func main() { ctx := context.Background() // send stream to Deepgram - options := interfaces.PreRecordedTranscriptionOptions{ + options := &interfaces.PreRecordedTranscriptionOptions{ Punctuate: true, Diarize: true, Language: "en-US", @@ -55,10 +55,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/speak/file/hello-world/main.go b/examples/speak/file/hello-world/main.go index cc01a472..f89e942f 100644 --- a/examples/speak/file/hello-world/main.go +++ b/examples/speak/file/hello-world/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -24,13 +24,15 @@ const ( func main() { // init library - client.InitWithDefault() + client.Init(client.InitLib{ + LogLevel: client.LogLevelTrace, // LogLevelDefault, LogLevelFull, LogLevelDebug, LogLevelTrace + }) // Go context ctx := context.Background() // set the Transcription options - options := interfaces.SpeakOptions{ + options := &interfaces.SpeakOptions{ Model: "aura-asteria-en", } @@ -52,10 +54,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/speak/file/woodchuck/main.go b/examples/speak/file/woodchuck/main.go index 1cb5a1ca..255d77d9 100644 --- a/examples/speak/file/woodchuck/main.go +++ b/examples/speak/file/woodchuck/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -32,7 +32,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.SpeakOptions{ + options := &interfaces.SpeakOptions{ Model: "aura-asteria-en", } @@ -54,10 +54,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/speak/stream/hello-world/main.go b/examples/speak/stream/hello-world/main.go index 152f96ac..01b3db4d 100644 --- a/examples/speak/stream/hello-world/main.go +++ b/examples/speak/stream/hello-world/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -30,7 +30,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.SpeakOptions{ + options := &interfaces.SpeakOptions{ Model: "aura-asteria-en", } @@ -39,7 +39,7 @@ func main() { dg := speak.New(c) // create file - file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666) + file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o666) if err != nil { fmt.Printf("os.Create failed. Err: %v\n", err) os.Exit(1) @@ -70,10 +70,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/speak/stream/woodchuck/main.go b/examples/speak/stream/woodchuck/main.go index c52b9966..9d13aad7 100644 --- a/examples/speak/stream/woodchuck/main.go +++ b/examples/speak/stream/woodchuck/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -30,7 +30,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.SpeakOptions{ + options := &interfaces.SpeakOptions{ Model: "aura-asteria-en", } @@ -39,7 +39,7 @@ func main() { dg := speak.New(c) // create file - file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666) + file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o666) if err != nil { fmt.Printf("os.Create failed. Err: %v\n", err) os.Exit(1) @@ -71,10 +71,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/speak/writer/hello-world/main.go b/examples/speak/writer/hello-world/main.go index a20af410..a1ff2068 100644 --- a/examples/speak/writer/hello-world/main.go +++ b/examples/speak/writer/hello-world/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -30,7 +30,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.SpeakOptions{ + options := &interfaces.SpeakOptions{ Model: "aura-asteria-en", } @@ -39,7 +39,7 @@ func main() { dg := speak.New(c) // create file - file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666) + file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o666) if err != nil { fmt.Printf("os.Create failed. Err: %v\n", err) os.Exit(1) @@ -60,10 +60,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/speak/writer/woodchuck/main.go b/examples/speak/writer/woodchuck/main.go index 030d274d..637aff4f 100644 --- a/examples/speak/writer/woodchuck/main.go +++ b/examples/speak/writer/woodchuck/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -30,7 +30,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.SpeakOptions{ + options := &interfaces.SpeakOptions{ Model: "aura-asteria-en", } @@ -39,7 +39,7 @@ func main() { dg := speak.New(c) // create file - file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666) + file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o666) if err != nil { fmt.Printf("os.Create failed. Err: %v\n", err) os.Exit(1) @@ -60,10 +60,10 @@ func main() { } // make the JSON pretty - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { fmt.Printf("prettyjson.Marshal failed. Err: %v\n", err) os.Exit(1) } - fmt.Printf("\n\nResult:\n%s\n\n", prettyJson) + fmt.Printf("\n\nResult:\n%s\n\n", prettyJSON) } diff --git a/examples/streaming/http/main.go b/examples/streaming/http/main.go index e89848f4..0c43941c 100644 --- a/examples/streaming/http/main.go +++ b/examples/streaming/http/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -31,7 +31,7 @@ func main() { fmt.Print("\n\nPress ENTER to exit!\n\n") // set the Transcription options - transcriptOptions := interfaces.LiveTranscriptionOptions{ + transcriptOptions := &interfaces.LiveTranscriptionOptions{ Language: "en-US", Punctuate: true, } diff --git a/examples/streaming/microphone/main.go b/examples/streaming/microphone/main.go index e650dc90..b3120046 100644 --- a/examples/streaming/microphone/main.go +++ b/examples/streaming/microphone/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -109,12 +109,12 @@ func main() { ctx := context.Background() // client options - cOptions := interfaces.ClientOptions{ + cOptions := &interfaces.ClientOptions{ EnableKeepAlive: true, } // set the Transcription options - tOptions := interfaces.LiveTranscriptionOptions{ + tOptions := &interfaces.LiveTranscriptionOptions{ Model: "nova-2", Language: "en-US", Punctuate: true, diff --git a/examples/streaming/replay/main.go b/examples/streaming/replay/main.go index 0aafc1fd..477bc89f 100644 --- a/examples/streaming/replay/main.go +++ b/examples/streaming/replay/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -28,7 +28,7 @@ func main() { ctx := context.Background() // set the Transcription options - options := interfaces.LiveTranscriptionOptions{ + options := &interfaces.LiveTranscriptionOptions{ Language: "en-US", Punctuate: true, Encoding: "mulaw", @@ -53,7 +53,7 @@ func main() { /* Replay wav into Live stream */ - play, err := replay.New(replay.ReplayOptions{ + play, err := replay.New(replay.Options{ FullFilename: "testing.wav", }) if err != nil { diff --git a/examples/streaming/test/main.go b/examples/streaming/test/main.go index cc79ff0e..6162b19d 100644 --- a/examples/streaming/test/main.go +++ b/examples/streaming/test/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -32,7 +32,7 @@ func main() { ctx := context.Background() // set the Transcription options - tOptions := interfaces.LiveTranscriptionOptions{ + tOptions := &interfaces.LiveTranscriptionOptions{ Model: "nova-2", Language: "en-US", Punctuate: true, diff --git a/go.mod b/go.mod index 64e235bb..247d1388 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ module github.com/deepgram/deepgram-go-sdk -go 1.18 +go 1.19 require ( github.com/dvonthenen/websocket v1.5.1-dyv.2 - github.com/google/go-querystring v1.1.0 github.com/gordonklaus/portaudio v0.0.0-20230709114228-aafa478834f5 + github.com/gorilla/schema v1.3.0 github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f github.com/youpy/go-wav v0.3.2 k8s.io/klog/v2 v2.110.1 diff --git a/go.sum b/go.sum index df67ec64..69bd5721 100644 --- a/go.sum +++ b/go.sum @@ -6,14 +6,13 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= -github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/gordonklaus/portaudio v0.0.0-20230709114228-aafa478834f5 h1:5AlozfqaVjGYGhms2OsdUyfdJME76E6rx5MdGpjzZpc= github.com/gordonklaus/portaudio v0.0.0-20230709114228-aafa478834f5/go.mod h1:WY8R6YKlI2ZI3UyzFk7P6yGSuS+hFwNtEzrexRyD7Es= +github.com/gorilla/schema v1.3.0 h1:rbciOzXAx3IB8stEFnfTwO3sYa6EWlQk79XdyustPDA= +github.com/gorilla/schema v1.3.0/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= github.com/jarcoal/httpmock v1.3.0 h1:2RJ8GP0IIaWwcC9Fp2BmVi8Kog3v2Hn7VXM3fTd+nuc= diff --git a/hack/check/check-mdlint.sh b/hack/check/check-mdlint.sh new file mode 100755 index 00000000..a248b4ae --- /dev/null +++ b/hack/check/check-mdlint.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o errexit +set -o nounset +set -o pipefail + +# Change directories to the parent directory of the one in which this +# script is located. +cd "$(dirname "${BASH_SOURCE[0]}")/../.." + +# mdlint rules with common errors and possible fixes can be found here: +# https://github.com/igorshubovych/markdownlint-cli +docker run -v "$PWD":/workdir \ + ghcr.io/igorshubovych/markdownlint-cli:latest \ + -i LICENSE \ + "*.md" diff --git a/hack/check/check-shell.sh b/hack/check/check-shell.sh new file mode 100755 index 00000000..f6fb3d4e --- /dev/null +++ b/hack/check/check-shell.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o errexit +set -o nounset +set -o pipefail + +# Change directories to the parent directory of the one in which this +# script is located. +cd "$(dirname "${BASH_SOURCE[0]}")/../.." + +usage() { + cat <&2; exit 1 + ;; + \?) + { echo "invalid option: -${OPTARG}"; usage; } 1>&2; exit 1 + ;; + :) + echo "option -${OPTARG} requires an argument" 1>&2; exit 1 + ;; + esac +done + +shellcheck --version +find . -path ./vendor -prune -o -name "*.*sh" -type f -print0 | xargs -0 shellcheck diff --git a/hack/check/check-yaml.sh b/hack/check/check-yaml.sh new file mode 100755 index 00000000..e1749394 --- /dev/null +++ b/hack/check/check-yaml.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o nounset +set -o pipefail + +CHECK_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +REPO_DIR="$(dirname "${CHECK_DIR}")/.." + +docker run --rm -t cytopia/yamllint --version +CONTAINER_NAME="dg_yamllint_$RANDOM" +docker run --name ${CONTAINER_NAME} -t -v "${REPO_DIR}":/deepgram-go-sdk:ro cytopia/yamllint -s -c /deepgram-go-sdk/.yamllintconfig.yaml /deepgram-go-sdk +EXIT_CODE=$(docker inspect ${CONTAINER_NAME} --format='{{.State.ExitCode}}') +docker rm -f ${CONTAINER_NAME} &> /dev/null + +if [[ ${EXIT_CODE} == "0" ]]; then + echo "yamllint passed!" +else + echo "yamllint exit code ${EXIT_CODE}: YAML linting failed!" + echo "Please fix the listed yamllint errors and verify using 'make yamllint'" + exit "${EXIT_CODE}" +fi diff --git a/hack/check/tools/Makefile b/hack/check/tools/Makefile new file mode 100644 index 00000000..5ff6e61d --- /dev/null +++ b/hack/check/tools/Makefile @@ -0,0 +1,64 @@ +# Copyright 2021 VMware Tanzu Community Edition contributors. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +# Build tooling that is used for the main project + +# Ensure Make is run with bash shell as some syntax below is bash-specific +SHELL := /usr/bin/env bash + +.DEFAULT_GOAL := help + +# Use GOPROXY environment variable if set +GOPROXY := $(shell go env GOPROXY) +ifeq (,$(strip $(GOPROXY))) +GOPROXY := https://proxy.golang.org +endif +export GOPROXY + +# Active module mode, as we use go modules to manage dependencies +export GO111MODULE := on + +# Directories. +SRCS := go.mod go.sum + +# Host information. +HOST_OS=$(shell go env GOOS) +HOST_ARCH=$(shell go env GOARCH) + + +lint: + echo "N/A: Skipping tools linting" + +get-deps: ## Get all dependencies + go mod tidy + +test: + echo "N/A: No unit tests for hack/tools" + +e2e-test: + echo "N/A: No e2e tests for hack/tools" + +build: + echo "N/A: No binary output for hack/tools" + +## -------------------------------------- +## Help +## -------------------------------------- + +help: ## Display this help + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +## -------------------------------------- +## Binaries +## -------------------------------------- + +golangci-lint: + go build -tags=tools -o $(GOLANGCI_LINT) github.com/golangci/golangci-lint/cmd/golangci-lint + +## -------------------------------------- +## Cleanup +## -------------------------------------- + +.PHONY: clean +clean: ## Remove all generated binaries + rm -rf bin diff --git a/hack/check/tools/go.mod b/hack/check/tools/go.mod new file mode 100644 index 00000000..0915e832 --- /dev/null +++ b/hack/check/tools/go.mod @@ -0,0 +1,173 @@ +module github.com/vmware-tanzu/community-edition/hack/tools + +go 1.19 + +require ( + github.com/golangci/golangci-lint v1.48.0 //v1.45.0 + github.com/shuLhan/go-bindata v4.0.0+incompatible +) + +require ( + 4d63.com/gochecknoglobals v0.1.0 // indirect + github.com/Antonboom/errname v0.1.7 // indirect + github.com/Antonboom/nilnil v0.1.1 // indirect + github.com/BurntSushi/toml v1.2.0 // indirect + github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect + github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.2 // indirect + github.com/Masterminds/semver v1.5.0 // indirect + github.com/OpenPeeDeeP/depguard v1.1.0 // indirect + github.com/alexkohler/prealloc v1.0.0 // indirect + github.com/alingse/asasalint v0.0.11 // indirect + github.com/ashanbrown/forbidigo v1.3.0 // indirect + github.com/ashanbrown/makezero v1.1.1 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bkielbasa/cyclop v1.2.0 // indirect + github.com/blizzy78/varnamelen v0.8.0 // indirect + github.com/bombsimon/wsl/v3 v3.3.0 // indirect + github.com/breml/bidichk v0.2.3 // indirect + github.com/breml/errchkjson v0.3.0 // indirect + github.com/butuzov/ireturn v0.1.1 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/charithe/durationcheck v0.0.9 // indirect + github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4 // indirect + github.com/daixiang0/gci v0.6.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/denis-tingaikin/go-header v0.4.3 // indirect + github.com/esimonov/ifshort v1.0.4 // indirect + github.com/ettle/strcase v0.1.1 // indirect + github.com/fatih/color v1.13.0 // indirect + github.com/fatih/structtag v1.2.0 // indirect + github.com/firefart/nonamedreturns v1.0.4 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/fzipp/gocyclo v0.6.0 // indirect + github.com/go-critic/go-critic v0.6.3 // indirect + github.com/go-toolsmith/astcast v1.0.0 // indirect + github.com/go-toolsmith/astcopy v1.0.0 // indirect + github.com/go-toolsmith/astequal v1.0.1 // indirect + github.com/go-toolsmith/astfmt v1.0.0 // indirect + github.com/go-toolsmith/astp v1.0.0 // indirect + github.com/go-toolsmith/strparse v1.0.0 // indirect + github.com/go-toolsmith/typep v1.0.2 // indirect + github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b // indirect + github.com/gobwas/glob v0.2.3 // indirect + github.com/gofrs/flock v0.8.1 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect + github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect + github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe // indirect + github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a // indirect + github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 // indirect + github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca // indirect + github.com/golangci/misspell v0.3.5 // indirect + github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 // indirect + github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect + github.com/google/go-cmp v0.5.8 // indirect + github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect + github.com/gostaticanalysis/analysisutil v0.7.1 // indirect + github.com/gostaticanalysis/comment v1.4.2 // indirect + github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect + github.com/gostaticanalysis/nilerr v0.1.1 // indirect + github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/hexops/gotextdiff v1.0.3 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/jgautheron/goconst v1.5.1 // indirect + github.com/jingyugao/rowserrcheck v1.1.1 // indirect + github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect + github.com/julz/importas v0.1.0 // indirect + github.com/kisielk/errcheck v1.6.2 // indirect + github.com/kisielk/gotool v1.0.0 // indirect + github.com/kulti/thelper v0.6.3 // indirect + github.com/kunwardeep/paralleltest v1.0.6 // indirect + github.com/kyoh86/exportloopref v0.1.8 // indirect + github.com/ldez/gomoddirectives v0.2.3 // indirect + github.com/ldez/tagliatelle v0.3.1 // indirect + github.com/leonklingele/grouper v1.1.0 // indirect + github.com/lufeee/execinquery v1.2.1 // indirect + github.com/magiconair/properties v1.8.6 // indirect + github.com/maratori/testpackage v1.1.0 // indirect + github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-runewidth v0.0.9 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/mbilski/exhaustivestruct v1.2.0 // indirect + github.com/mgechev/revive v1.2.1 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moricho/tparallel v0.2.1 // indirect + github.com/nakabonne/nestif v0.3.1 // indirect + github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 // indirect + github.com/nishanths/exhaustive v0.8.1 // indirect + github.com/nishanths/predeclared v0.2.2 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect + github.com/pelletier/go-toml/v2 v2.0.2 // indirect + github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/polyfloyd/go-errorlint v1.0.0 // indirect + github.com/prometheus/client_golang v1.12.1 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/procfs v0.7.3 // indirect + github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a // indirect + github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect + github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 // indirect + github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect + github.com/ryancurrah/gomodguard v1.2.4 // indirect + github.com/ryanrolds/sqlclosecheck v0.3.0 // indirect + github.com/sanposhiho/wastedassign/v2 v2.0.6 // indirect + github.com/sashamelentyev/usestdlibvars v1.8.0 // indirect + github.com/securego/gosec/v2 v2.12.0 // indirect + github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect + github.com/sirupsen/logrus v1.9.0 // indirect + github.com/sivchari/containedctx v1.0.2 // indirect + github.com/sivchari/nosnakecase v1.7.0 // indirect + github.com/sivchari/tenv v1.7.0 // indirect + github.com/sonatard/noctx v0.0.1 // indirect + github.com/sourcegraph/go-diff v0.6.1 // indirect + github.com/spf13/afero v1.8.2 // indirect + github.com/spf13/cast v1.5.0 // indirect + github.com/spf13/cobra v1.5.0 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/viper v1.12.0 // indirect + github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect + github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect + github.com/stretchr/objx v0.4.0 // indirect + github.com/stretchr/testify v1.8.0 // indirect + github.com/subosito/gotenv v1.4.0 // indirect + github.com/sylvia7788/contextcheck v1.0.4 // indirect + github.com/tdakkota/asciicheck v0.1.1 // indirect + github.com/tetafro/godot v1.4.11 // indirect + github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 // indirect + github.com/tomarrell/wrapcheck/v2 v2.6.2 // indirect + github.com/tommy-muehle/go-mnd/v2 v2.5.0 // indirect + github.com/ultraware/funlen v0.0.3 // indirect + github.com/ultraware/whitespace v0.0.5 // indirect + github.com/uudashr/gocognit v1.0.6 // indirect + github.com/yagipy/maintidx v1.0.0 // indirect + github.com/yeya24/promlinter v0.2.0 // indirect + gitlab.com/bosi/decorder v0.2.3 // indirect + go.uber.org/atomic v1.7.0 // indirect + go.uber.org/multierr v1.6.0 // indirect + go.uber.org/zap v1.17.0 // indirect + golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d // indirect + golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect + golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect + golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/tools v0.1.12 // indirect + google.golang.org/protobuf v1.28.0 // indirect + gopkg.in/ini.v1 v1.66.6 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + honnef.co/go/tools v0.3.3 // indirect + mvdan.cc/gofumpt v0.3.1 // indirect + mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect + mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b // indirect + mvdan.cc/unparam v0.0.0-20220706161116-678bad134442 // indirect +) diff --git a/hack/check/tools/go.sum b/hack/check/tools/go.sum new file mode 100644 index 00000000..f47e3c57 --- /dev/null +++ b/hack/check/tools/go.sum @@ -0,0 +1,1200 @@ +4d63.com/gochecknoglobals v0.1.0 h1:zeZSRqj5yCg28tCkIV/z/lWbwvNm5qnKVS15PI8nhD0= +4d63.com/gochecknoglobals v0.1.0/go.mod h1:wfdC5ZjKSPr7CybKEcgJhUOgeAQW1+7WcyK8OvUilfo= +bitbucket.org/creachadair/shell v0.0.6/go.mod h1:8Qqi/cYk7vPnsOePHroKXDJYmb5x7ENhtiFtfZq8K+M= +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.60.0/go.mod h1:yw2G51M9IfRboUH61Us8GqCeF1PzPblB823Mn2q2eAU= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= +cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/pubsub v1.5.0/go.mod h1:ZEwJccE3z93Z2HWvstpri00jOg7oO4UZDtKhwDwqF0w= +cloud.google.com/go/spanner v1.7.0/go.mod h1:sd3K2gZ9Fd0vMPLXzeCrF6fq4i63Q7aTLW/lBIfBkIk= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +contrib.go.opencensus.io/exporter/stackdriver v0.13.4/go.mod h1:aXENhDJ1Y4lIg4EUaVTwzvYETVNZk10Pu26tevFKLUc= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/Antonboom/errname v0.1.7 h1:mBBDKvEYwPl4WFFNwec1CZO096G6vzK9vvDQzAwkako= +github.com/Antonboom/errname v0.1.7/go.mod h1:g0ONh16msHIPgJSGsecu1G/dcF2hlYR/0SddnIAGavU= +github.com/Antonboom/nilnil v0.1.1 h1:PHhrh5ANKFWRBh7TdYmyyq2gyT2lotnvFvvFbylF81Q= +github.com/Antonboom/nilnil v0.1.1/go.mod h1:L1jBqoWM7AOeTD+tSquifKSesRHs4ZdaxvZR+xdJEaI= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0= +github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= +github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= +github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.2 h1:DGdS4FlsdM6OkluXOhgkvwx05ZjD3Idm9WqtYnOmSuY= +github.com/GaijinEntertainment/go-exhaustruct/v2 v2.2.2/go.mod h1:xj0D2jwLdp6tOKLheyZCsfL0nz8DaicmJxSwj3VcHtY= +github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww= +github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.15.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/Masterminds/sprig v2.22.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/OpenPeeDeeP/depguard v1.1.0 h1:pjK9nLPS1FwQYGGpPxoMYpe7qACHOhAWQMQzV71i49o= +github.com/OpenPeeDeeP/depguard v1.1.0/go.mod h1:JtAMzWkmFEzDPyAd+W0NHl1lvpQKTvT9jnRVsohBKpc= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw= +github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= +github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= +github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= +github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q= +github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= +github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= +github.com/ashanbrown/forbidigo v1.3.0 h1:VkYIwb/xxdireGAdJNZoo24O4lmnEWkactplBlWTShc= +github.com/ashanbrown/forbidigo v1.3.0/go.mod h1:vVW7PEdqEFqapJe95xHkTfB1+XvZXBFg8t0sG2FIxmI= +github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s= +github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= +github.com/aws/aws-sdk-go v1.23.20/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.25.37/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.36.30/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bkielbasa/cyclop v1.2.0 h1:7Jmnh0yL2DjKfw28p86YTd/B4lRGcNuu12sKE35sM7A= +github.com/bkielbasa/cyclop v1.2.0/go.mod h1:qOI0yy6A7dYC4Zgsa72Ppm9kONl0RoIlPbzot9mhmeI= +github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M= +github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= +github.com/bombsimon/wsl/v3 v3.3.0 h1:Mka/+kRLoQJq7g2rggtgQsjuI/K5Efd87WX96EWFxjM= +github.com/bombsimon/wsl/v3 v3.3.0/go.mod h1:st10JtZYLE4D5sC7b8xV4zTKZwAQjCH/Hy2Pm1FNZIc= +github.com/breml/bidichk v0.2.3 h1:qe6ggxpTfA8E75hdjWPZ581sY3a2lnl0IRxLQFelECI= +github.com/breml/bidichk v0.2.3/go.mod h1:8u2C6DnAy0g2cEq+k/A2+tr9O1s+vHGxWn0LTc70T2A= +github.com/breml/errchkjson v0.3.0 h1:YdDqhfqMT+I1vIxPSas44P+9Z9HzJwCeAzjB8PxP1xw= +github.com/breml/errchkjson v0.3.0/go.mod h1:9Cogkyv9gcT8HREpzi3TiqBxCqDzo8awa92zSDFcofU= +github.com/butuzov/ireturn v0.1.1 h1:QvrO2QF2+/Cx1WA/vETCIYBKtRjc30vesdoPUNo1EbY= +github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/charithe/durationcheck v0.0.9 h1:mPP4ucLrf/rKZiIG/a9IPXHGlh8p4CzgpyTy6EEutYk= +github.com/charithe/durationcheck v0.0.9/go.mod h1:SSbRIBVfMjCi/kEB6K65XEA83D6prSM8ap1UCpNKtgg= +github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4 h1:tFXjAxje9thrTF4h57Ckik+scJjTWdwAtZqZPtOT48M= +github.com/chavacava/garif v0.0.0-20220316182200-5cad0b5181d4/go.mod h1:W8EnPSQ8Nv4fUjc/v1/8tHFqhuOJXnRub0dTfuAQktU= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= +github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= +github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd v0.0.0-20190620071333-e64a0ec8b42a/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/daixiang0/gci v0.6.2 h1:TXCP5RqjE/UupXO+p33MEhqdv7QxjKGw5MVkt9ATiMs= +github.com/daixiang0/gci v0.6.2/go.mod h1:EpVfrztufwVgQRXjnX4zuNinEpLj5OmMjtu/+MB0V0c= +github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/denis-tingaikin/go-header v0.4.3 h1:tEaZKAlqql6SKCY++utLmkPLd6K8IBM20Ha7UVm+mtU= +github.com/denis-tingaikin/go-header v0.4.3/go.mod h1:0wOCWuN71D5qIgE2nz9KrKmuYBAC2Mra5RassOIQ2/c= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/protoc-gen-validate v0.0.14/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/esimonov/ifshort v1.0.4 h1:6SID4yGWfRae/M7hkVDVVyppy8q/v9OuxNdmjLQStBA= +github.com/esimonov/ifshort v1.0.4/go.mod h1:Pe8zjlRrJ80+q2CxHLfEOfTwxCZ4O+MuhcHcfgNWTk0= +github.com/ettle/strcase v0.1.1 h1:htFueZyVeE1XNnMEfbqp5r67qAN/4r6ya1ysq8Q+Zcw= +github.com/ettle/strcase v0.1.1/go.mod h1:hzDLsPC7/lwKyBOywSHEP89nt2pDgdy+No1NBA9o9VY= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= +github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= +github.com/firefart/nonamedreturns v1.0.4 h1:abzI1p7mAEPYuR4A+VLKn4eNDOycjYo2phmY9sfv40Y= +github.com/firefart/nonamedreturns v1.0.4/go.mod h1:TDhe/tjI1BXo48CmYbUduTV7BdIga8MAO/xbKdcVsGI= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fullstorydev/grpcurl v1.6.0/go.mod h1:ZQ+ayqbKMJNhzLmbpCiurTVlaK2M/3nqZCxaQ2Ze/sM= +github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= +github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-critic/go-critic v0.6.3 h1:abibh5XYBTASawfTQ0rA7dVtQT+6KzpGqb/J+DxRDaw= +github.com/go-critic/go-critic v0.6.3/go.mod h1:c6b3ZP1MQ7o6lPR7Rv3lEf7pYQUmAcx8ABHgdZCQt/k= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-redis/redis v6.15.8+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= +github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= +github.com/go-toolsmith/astcast v1.0.0 h1:JojxlmI6STnFVG9yOImLeGREv8W2ocNUM+iOhR6jE7g= +github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= +github.com/go-toolsmith/astcopy v1.0.0 h1:OMgl1b1MEpjFQ1m5ztEO06rz5CUd3oBv9RF7+DyvdG8= +github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= +github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY= +github.com/go-toolsmith/astequal v1.0.1 h1:JbSszi42Jiqu36Gnf363HWS9MTEAz67vTQLponh3Moc= +github.com/go-toolsmith/astequal v1.0.1/go.mod h1:4oGA3EZXTVItV/ipGiOx7NWkY5veFfcsOJVS2YxltLw= +github.com/go-toolsmith/astfmt v1.0.0 h1:A0vDDXt+vsvLEdbMFJAUBI/uTbRw1ffOPnxsILnFL6k= +github.com/go-toolsmith/astfmt v1.0.0/go.mod h1:cnWmsOAuq4jJY6Ct5YWlVLmcmLMn1JUPuQIHCY7CJDw= +github.com/go-toolsmith/astp v1.0.0 h1:alXE75TXgcmupDsMK1fRAy0YUzLzqPVvBKoyWV+KPXg= +github.com/go-toolsmith/astp v1.0.0/go.mod h1:RSyrtpVlfTFGDYRbrjyWP1pYu//tSFcvdYrA8meBmLI= +github.com/go-toolsmith/pkgload v1.0.2-0.20220101231613-e814995d17c5 h1:eD9POs68PHkwrx7hAB78z1cb6PfGq/jyWn3wJywsH1o= +github.com/go-toolsmith/pkgload v1.0.2-0.20220101231613-e814995d17c5/go.mod h1:3NAwwmD4uY/yggRxoEjk/S00MIV3A+H7rrE3i87eYxM= +github.com/go-toolsmith/strparse v1.0.0 h1:Vcw78DnpCAKlM20kSbAyO4mPfJn/lyYA4BJUDxe2Jb4= +github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= +github.com/go-toolsmith/typep v1.0.2 h1:8xdsa1+FSIH/RhEkgnD1j2CJOy5mNllW1Q9tRiYwvlk= +github.com/go-toolsmith/typep v1.0.2/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU= +github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b h1:khEcpUM4yFcxg4/FHQWkvVRmgijNXRfzkIDHh23ggEo= +github.com/go-xmlfmt/xmlfmt v0.0.0-20191208150333-d5b6f63a941b/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 h1:23T5iq8rbUYlhpt5DB4XJkc6BU31uODLD1o1gKvZmD0= +github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= +github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9uMCefW1WDie15eSP/4MssdenaM= +github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= +github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe h1:6RGUuS7EGotKx6J5HIP8ZtyMdiDscjMLfRBSPuzVVeo= +github.com/golangci/go-misc v0.0.0-20220329215616-d24fe342adfe/go.mod h1:gjqyPShc/m8pEMpk0a3SeagVb0kaqvhscv+i9jI5ZhQ= +github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a h1:iR3fYXUjHCR97qWS8ch1y9zPNsgXThGwjKPrYfqMPks= +github.com/golangci/gofmt v0.0.0-20190930125516-244bba706f1a/go.mod h1:9qCChq59u/eW8im404Q2WWTrnBUQKjpNYKMbU4M7EFU= +github.com/golangci/golangci-lint v1.48.0 h1:hRiBNk9iRqdAKMa06ntfEiLyza1/3IE9rHLNJaek4a8= +github.com/golangci/golangci-lint v1.48.0/go.mod h1:5N+oxduCho+7yuccW69upg/O7cxjfR/d+IQeiNxGmKM= +github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0 h1:MfyDlzVjl1hoaPzPD4Gpb/QgoRfSBR0jdhwGyAWwMSA= +github.com/golangci/lint-1 v0.0.0-20191013205115-297bf364a8e0/go.mod h1:66R6K6P6VWk9I95jvqGxkqJxVWGFy9XlDwLwVz1RCFg= +github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca h1:kNY3/svz5T29MYHubXix4aDDuE3RWHkPvopM/EDv/MA= +github.com/golangci/maligned v0.0.0-20180506175553-b1d89398deca/go.mod h1:tvlJhZqDe4LMs4ZHD0oMUlt9G2LWuDGoisJTBzLMV9o= +github.com/golangci/misspell v0.3.5 h1:pLzmVdl3VxTOncgzHcvLOKirdvcx/TydsClUQXTehjo= +github.com/golangci/misspell v0.3.5/go.mod h1:dEbvlSfYbMQDtrpRMQU675gSDLDNa8sCPPChZ7PhiVA= +github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6 h1:DIPQnGy2Gv2FSA4B/hh8Q7xx3B7AIDk3DAMeHclH1vQ= +github.com/golangci/revgrep v0.0.0-20220804021717-745bb2f7c2e6/go.mod h1:0AKcRCkMoKvUvlf89F6O7H2LYdhr1zBh736mBItOdRs= +github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 h1:zwtduBRr5SSWhqsYNgcuWO2kFlpdOZbP0+yRjmvPGys= +github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg8RkN3rCIMLGE9CyYmU9pY2Jer6DgANEnZ/L/cQ= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg= +github.com/google/certificate-transparency-go v1.1.1/go.mod h1:FDKqPvSXawb2ecErVRrD+nfy23RCzyl7eqVCEmlT1Zs= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200507031123-427632fa3b1c/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/trillian v1.3.11/go.mod h1:0tPraVHrSDkA3BO6vKX67zgLXs6SsOAbHEivX+9mPgw= +github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/gookit/color v1.5.1/go.mod h1:wZFzea4X8qN6vHOSP2apMb4/+w/orMznEzYsIHPaqKM= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= +github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 h1:PVRE9d4AQKmbelZ7emNig1+NT27DUmKZn5qXxfio54U= +github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8/go.mod h1:Qcp2HIAYhR7mNUVSIxZww3Guk4it82ghYcEXIAk+QT0= +github.com/gorhill/cronexpr v0.0.0-20180427100037-88b0669f7d75/go.mod h1:g2644b03hfBX9Ov0ZBDgXXens4rxSxmqFBbhvKv2yVA= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= +github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gostaticanalysis/analysisutil v0.0.0-20190318220348-4088753ea4d3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= +github.com/gostaticanalysis/analysisutil v0.0.3/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= +github.com/gostaticanalysis/analysisutil v0.1.0/go.mod h1:dMhHRU9KTiDcuLGdy87/2gTR8WruwYZrKdRq9m1O6uw= +github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk= +github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc= +github.com/gostaticanalysis/comment v1.3.0/go.mod h1:xMicKDx7XRXYdVwY9f9wQpDJVnqWxw9wCauCMKp+IBI= +github.com/gostaticanalysis/comment v1.4.1/go.mod h1:ih6ZxzTHLdadaiSnF5WY3dxUoXfXAlTaRzuaNDlSado= +github.com/gostaticanalysis/comment v1.4.2 h1:hlnx5+S2fY9Zo9ePo4AhgYsYHbM2+eAv8m/s1JiCd6Q= +github.com/gostaticanalysis/comment v1.4.2/go.mod h1:KLUTGDv6HOCotCH8h2erHKmpci2ZoR8VPu34YA2uzdM= +github.com/gostaticanalysis/forcetypeassert v0.1.0 h1:6eUflI3DiGusXGK6X7cCcIgVCpZ2CiZ1Q7jl6ZxNV70= +github.com/gostaticanalysis/forcetypeassert v0.1.0/go.mod h1:qZEedyP/sY1lTGV1uJ3VhWZ2mqag3IkWsDHVbplHXak= +github.com/gostaticanalysis/nilerr v0.1.1 h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3Uqrmrcpk= +github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= +github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= +github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoISdUv3PPQgHY= +github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.12.1/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= +github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.0.0/go.mod h1:4qWG/gcEcfX4z/mBDHJ++3ReCw9ibxbsNJbcucJdbSo= +github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imdario/mergo v0.3.4/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jgautheron/goconst v1.5.1 h1:HxVbL1MhydKs8R8n/HE5NPvzfaYmQJA3o879lE4+WcM= +github.com/jgautheron/goconst v1.5.1/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4= +github.com/jhump/protoreflect v1.6.1/go.mod h1:RZQ/lnuN+zqeRVpQigTwO6o0AJUkxbnSnpuG7toUTG4= +github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= +github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= +github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af h1:KA9BjwUk7KlCh6S9EAGWBt1oExIUv9WyNCiRz5amv48= +github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jonboulle/clockwork v0.2.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/juju/ratelimit v1.0.1/go.mod h1:qapgC/Gy+xNh9UxzV13HGGl/6UXNN+ct+vwSgWNm/qk= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/julz/importas v0.1.0 h1:F78HnrsjY3cR7j0etXy5+TU1Zuy7Xt08X/1aJnH5xXY= +github.com/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= +github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/errcheck v1.6.2 h1:uGQ9xI8/pgc9iOoCe7kWQgRE6SBTrCGmTSf0LrEtY7c= +github.com/kisielk/errcheck v1.6.2/go.mod h1:nXw/i/MfnvRHqXa7XXmQMUB0oNFGuBrNI8d8NLy0LPw= +github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/kulti/thelper v0.6.3 h1:ElhKf+AlItIu+xGnI990no4cE2+XaSu1ULymV2Yulxs= +github.com/kulti/thelper v0.6.3/go.mod h1:DsqKShOvP40epevkFrvIwkCMNYxMeTNjdWL4dqWHZ6I= +github.com/kunwardeep/paralleltest v1.0.6 h1:FCKYMF1OF2+RveWlABsdnmsvJrei5aoyZoaGS+Ugg8g= +github.com/kunwardeep/paralleltest v1.0.6/go.mod h1:Y0Y0XISdZM5IKm3TREQMZ6iteqn1YuwCsJO/0kL9Zes= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/kyoh86/exportloopref v0.1.8 h1:5Ry/at+eFdkX9Vsdw3qU4YkvGtzuVfzT4X7S77LoN/M= +github.com/kyoh86/exportloopref v0.1.8/go.mod h1:1tUcJeiioIs7VWe5gcOObrux3lb66+sBqGZrRkMwPgg= +github.com/ldez/gomoddirectives v0.2.3 h1:y7MBaisZVDYmKvt9/l1mjNCiSA1BVn34U0ObUcJwlhA= +github.com/ldez/gomoddirectives v0.2.3/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0= +github.com/ldez/tagliatelle v0.3.1 h1:3BqVVlReVUZwafJUwQ+oxbx2BEX2vUG4Yu/NOfMiKiM= +github.com/ldez/tagliatelle v0.3.1/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88= +github.com/leonklingele/grouper v1.1.0 h1:tC2y/ygPbMFSBOs3DcyaEMKnnwH7eYKzohOtRrf0SAg= +github.com/leonklingele/grouper v1.1.0/go.mod h1:uk3I3uDfi9B6PeUjsCKi6ndcf63Uy7snXgR4yDYQVDY= +github.com/letsencrypt/pkcs11key/v4 v4.0.0/go.mod h1:EFUvBDay26dErnNb70Nd0/VW3tJiIbETBPTl9ATXQag= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lufeee/execinquery v1.2.1 h1:hf0Ems4SHcUGBxpGN7Jz78z1ppVkP/837ZlETPCEtOM= +github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/maratori/testpackage v1.1.0 h1:GJY4wlzQhuBusMF1oahQCBtUV/AQ/k69IZ68vxaac2Q= +github.com/maratori/testpackage v1.1.0/go.mod h1:PeAhzU8qkCwdGEMTEupsHJNlQu2gZopMC6RjbhmHeDc= +github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 h1:pWxk9e//NbPwfxat7RXkts09K+dEBJWakUWwICVqYbA= +github.com/matoous/godox v0.0.0-20210227103229-6504466cf951/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= +github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= +github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= +github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mbilski/exhaustivestruct v1.2.0 h1:wCBmUnSYufAHO6J4AVWY6ff+oxWxsVFrwgOdMUQePUo= +github.com/mbilski/exhaustivestruct v1.2.0/go.mod h1:OeTBVxQWoEmB2J2JCHmXWPJ0aksxSUOUy+nvtVEfzXc= +github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517/go.mod h1:KQ7+USdGKfpPjXk4Ga+5XxQM4Lm4e3gAogrreFAYpOg= +github.com/mgechev/revive v1.2.1 h1:GjFml7ZsoR0IrQ2E2YIvWFNS5GPDV7xNwvA5GM1HZC4= +github.com/mgechev/revive v1.2.1/go.mod h1:+Ro3wqY4vakcYNtkBWdZC7dBg1xSB6sp054wWwmeFm0= +github.com/miekg/dns v1.1.35/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM= +github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/miekg/pkcs11 v1.0.3/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= +github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/moricho/tparallel v0.2.1 h1:95FytivzT6rYzdJLdtfn6m1bfFJylOJK41+lgv/EHf4= +github.com/moricho/tparallel v0.2.1/go.mod h1:fXEIZxG2vdfl0ZF8b42f5a78EhjjD5mX8qUplsoSU4k= +github.com/mozilla/scribe v0.0.0-20180711195314-fb71baf557c1/go.mod h1:FIczTrinKo8VaLxe6PWTPEXRXDIHz2QAwiaBaP5/4a8= +github.com/mozilla/tls-observatory v0.0.0-20210609171429-7bc42856d2e5/go.mod h1:FUqVoUPHSEdDR0MnFM3Dh8AU0pZHLXUD127SAJGER/s= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-proto-validators v0.0.0-20180403085117-0950a7990007/go.mod h1:m2XC9Qq0AlmmVksL6FktJCdTYyLk7V3fKyp0sl1yWQo= +github.com/mwitkow/go-proto-validators v0.2.0/go.mod h1:ZfA1hW+UH/2ZHOWvQ3HnQaU0DtnpXu850MZiy+YUgcc= +github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81U= +github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE= +github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354 h1:4kuARK6Y6FxaNu/BnU2OAaLF86eTVhP2hjTB6iMvItA= +github.com/nbutton23/zxcvbn-go v0.0.0-20210217022336-fa2cb2858354/go.mod h1:KSVJerMDfblTH7p5MZaTt+8zaT2iEk3AkVb9PQdZuE8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nishanths/exhaustive v0.8.1 h1:0QKNascWv9qIHY7zRoZSxeRr6kuk5aAT3YXLTiDmjTo= +github.com/nishanths/exhaustive v0.8.1/go.mod h1:qj+zJJUgJ76tR92+25+03oYUhzF4R7/2Wk7fGTfCHmg= +github.com/nishanths/predeclared v0.0.0-20190419143655-18a43bb90ffc/go.mod h1:62PewwiQTlm/7Rj+cxVYqZvDIUc+JjZq6GHAC1fsObQ= +github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= +github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= +github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= +github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.2/go.mod h1:rSAaSIOAGT9odnlyGlUfAJaoc5w2fSBUmeGDbRWPxyQ= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= +github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= +github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c= +github.com/onsi/ginkgo/v2 v2.1.4 h1:GNapqRSid3zijZ9H77KrgVG4/8KqiyRsxcSxe+7ApXY= +github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU= +github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY= +github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw= +github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= +github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= +github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= +github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= +github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= +github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= +github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= +github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d h1:CdDQnGF8Nq9ocOS/xlSptM1N3BbrA6/kmaep5ggwaIA= +github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7FXDQlpCiw2j81fOmAwQLnZnLGXVKUzeKQXIAw= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/polyfloyd/go-errorlint v1.0.0 h1:pDrQG0lrh68e602Wfp68BlUTRFoHn8PZYAjLgt2LFsM= +github.com/polyfloyd/go-errorlint v1.0.0/go.mod h1:KZy4xxPJyy88/gldCe5OdW6OQRtNO3EZE7hXzmnebgA= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= +github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= +github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= +github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/pseudomuto/protoc-gen-doc v1.3.2/go.mod h1:y5+P6n3iGrbKG+9O04V5ld71in3v/bX88wUwgt+U8EA= +github.com/pseudomuto/protokit v0.2.0/go.mod h1:2PdH30hxVHsup8KpBTOXTBeMVhJZVio3Q8ViKSAXT0Q= +github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= +github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a h1:sWFavxtIctGrVs5SYZ5Ml1CvrDAs8Kf5kx2PI3C41dA= +github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a/go.mod h1:VMX+OnnSw4LicdiEGtRSD/1X8kW7GuEscjYNr4cOIT4= +github.com/quasilyte/go-ruleguard/dsl v0.3.0/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/dsl v0.3.16/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= +github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc= +github.com/quasilyte/go-ruleguard/rules v0.0.0-20211022131956-028d6511ab71/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50= +github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 h1:PDWGei+Rf2bBiuZIbZmM20J2ftEy9IeUCHA8HbQqed8= +github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5/go.mod h1:wSEyW6O61xRV6zb6My3HxrQ5/8ke7NE2OayqCHa3xRM= +github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95 h1:L8QM9bvf68pVdQ3bCFZMDmnt9yqcMBro1pC7F+IPYMY= +github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= +github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs= +github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryancurrah/gomodguard v1.2.4 h1:CpMSDKan0LtNGGhPrvupAoLeObRFjND8/tU1rEOtBp4= +github.com/ryancurrah/gomodguard v1.2.4/go.mod h1:+Kem4VjWwvFpUJRJSwa16s1tBJe+vbv02+naTow2f6M= +github.com/ryanrolds/sqlclosecheck v0.3.0 h1:AZx+Bixh8zdUBxUA1NxbxVAS78vTPq4rCb8OUZI9xFw= +github.com/ryanrolds/sqlclosecheck v0.3.0/go.mod h1:1gREqxyTGR3lVtpngyFo3hZAgk0KCtEdgEkHwDbigdA= +github.com/sanposhiho/wastedassign/v2 v2.0.6 h1:+6/hQIHKNJAUixEj6EmOngGIisyeI+T3335lYTyxRoA= +github.com/sanposhiho/wastedassign/v2 v2.0.6/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= +github.com/sashamelentyev/usestdlibvars v1.8.0 h1:QnWP9IOEuRyYKH+IG0LlQIjuJlc0rfdo4K3/Zh3WRMw= +github.com/sashamelentyev/usestdlibvars v1.8.0/go.mod h1:BFt7b5mSVHaaa26ZupiNRV2ODViQBxZZVhtAxAJRrjs= +github.com/securego/gosec/v2 v2.12.0 h1:CQWdW7ATFpvLSohMVsajscfyHJ5rsGmEXmsNcsDNmAg= +github.com/securego/gosec/v2 v2.12.0/go.mod h1:iTpT+eKTw59bSgklBHlSnH5O2tNygHMDxfvMubA4i7I= +github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= +github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqPQ0YvHYKwcMEMVWIzWC5iNQQfBTU= +github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c/go.mod h1:/PevMnwAxekIXwN8qQyfc5gl2NlkB3CQlkizAbOkeBs= +github.com/shuLhan/go-bindata v4.0.0+incompatible h1:xD8LkuVZLV5OOn/IEuFdt6EEAW7deWiqgwaaSGhjAJc= +github.com/shuLhan/go-bindata v4.0.0+incompatible/go.mod h1:pkcPAATLBDD2+SpAPnX5vEM90F7fcwHCvvLCMXcmw3g= +github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= +github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sivchari/containedctx v1.0.2 h1:0hLQKpgC53OVF1VT7CeoFHk9YKstur1XOgfYIc1yrHI= +github.com/sivchari/containedctx v1.0.2/go.mod h1:PwZOeqm4/DLoJOqMSIJs3aKqXRX4YO+uXww087KZ7Bw= +github.com/sivchari/nosnakecase v1.7.0 h1:7QkpWIRMe8x25gckkFd2A5Pi6Ymo0qgr4JrhGt95do8= +github.com/sivchari/nosnakecase v1.7.0/go.mod h1:CwDzrzPea40/GB6uynrNLiorAlgFRvRbFSgJx2Gs+QY= +github.com/sivchari/tenv v1.7.0 h1:d4laZMBK6jpe5PWepxlV9S+LC0yXqvYHiq8E6ceoVVE= +github.com/sivchari/tenv v1.7.0/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/sonatard/noctx v0.0.1 h1:VC1Qhl6Oxx9vvWo3UDgrGXYCeKCe3Wbw7qAWL6FrmTY= +github.com/sonatard/noctx v0.0.1/go.mod h1:9D2D/EoULe8Yy2joDHJj7bv3sZoq9AaSb8B4lqBjiZI= +github.com/sourcegraph/go-diff v0.6.1 h1:hmA1LzxW0n1c3Q4YbrFgg4P99GSnebYa3x8gr0HZqLQ= +github.com/sourcegraph/go-diff v0.6.1/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= +github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= +github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= +github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= +github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= +github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0= +github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= +github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= +github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/subosito/gotenv v1.4.0 h1:yAzM1+SmVcz5R4tXGsNMu1jUl2aOJXoiWUCEwwnGrvs= +github.com/subosito/gotenv v1.4.0/go.mod h1:mZd6rFysKEcUhUHXJk0C/08wAgyDBFuwEYL7vWWGaGo= +github.com/sylvia7788/contextcheck v1.0.4 h1:MsiVqROAdr0efZc/fOCt0c235qm9XJqHtWwM+2h2B04= +github.com/sylvia7788/contextcheck v1.0.4/go.mod h1:vuPKJMQ7MQ91ZTqfdyreNKwZjyUg6KO+IebVyQDedZQ= +github.com/tdakkota/asciicheck v0.1.1 h1:PKzG7JUTUmVspQTDqtkX9eSiLGossXTybutHwTXuO0A= +github.com/tdakkota/asciicheck v0.1.1/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM= +github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= +github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= +github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= +github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= +github.com/tetafro/godot v1.4.11 h1:BVoBIqAf/2QdbFmSwAWnaIqDivZdOV0ZRwEm6jivLKw= +github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8= +github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144 h1:kl4KhGNsJIbDHS9/4U9yQo1UcPQM0kOMJHn29EoH/Ro= +github.com/timakin/bodyclose v0.0.0-20210704033933-f49887972144/go.mod h1:Qimiffbc6q9tBWlVV6x0P9sat/ao1xEkREYPPj9hphk= +github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tomarrell/wrapcheck/v2 v2.6.2 h1:3dI6YNcrJTQ/CJQ6M/DUkc0gnqYSIk6o0rChn9E/D0M= +github.com/tomarrell/wrapcheck/v2 v2.6.2/go.mod h1:ao7l5p0aOlUNJKI0qVwB4Yjlqutd0IvAB9Rdwyilxvg= +github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce/go.mod h1:o8v6yHRoik09Xen7gje4m9ERNah1d1PPsVq1VEx9vE4= +github.com/tommy-muehle/go-mnd/v2 v2.5.0 h1:iAj0a8e6+dXSL7Liq0aXPox36FiN1dBbjA6lt9fl65s= +github.com/tommy-muehle/go-mnd/v2 v2.5.0/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iLA= +github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA= +github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI= +github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA= +github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= +github.com/uudashr/gocognit v1.0.6 h1:2Cgi6MweCsdB6kpcVQp7EW4U23iBFQWfTXiWlyp842Y= +github.com/uudashr/gocognit v1.0.6/go.mod h1:nAIUuVBnYU7pcninia3BHOvQkpQCeO76Uscky5BOwcY= +github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= +github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= +github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= +github.com/yeya24/promlinter v0.2.0 h1:xFKDQ82orCU5jQujdaD8stOHiv8UN68BSdn2a8u8Y3o= +github.com/yeya24/promlinter v0.2.0/go.mod h1:u54lkmBOZrpEbQQ6gox2zWKKLKu2SGe+2KOiextY+IA= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= +github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +gitlab.com/bosi/decorder v0.2.3 h1:gX4/RgK16ijY8V+BRQHAySfQAb354T7/xQpDB2n10P0= +gitlab.com/bosi/decorder v0.2.3/go.mod h1:9K1RB5+VPNQYtXtTDAzd2OEftsZb1oV0IrJrzChSdGE= +go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= +go.etcd.io/etcd v0.0.0-20200513171258-e048e166ab9c/go.mod h1:xCI7ZzBfRuGgBXyXO6yfWfDmlWd35khcWpUa4L0xI/k= +go.mozilla.org/mozlog v0.0.0-20170222151521-4bb13139d403/go.mod h1:jHoPAGnDrCy6kaI2tAze5Prf0Nr0w/oNkROt2lw3n3o= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= +go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= +go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +golang.org/x/crypto v0.0.0-20180501155221-613d6eafa307/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d h1:+W8Qf4iJtMGKkyAygcKohjxTk4JPsL9DpzApJ22m5Ic= +golang.org/x/exp/typeparams v0.0.0-20220613132600-b0d781184e0d/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200421231249-e086a090c8fd/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= +golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190307163923-6a08e3108db3/go.mod h1:25r3+/G6/xytQM8iWZKq3Hn0kr0rgFKPUNVEL/dr3z4= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190321232350-e250d351ecad/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190322203728-c1a832b0ad89/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190910044552-dd2b5c81c578/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190916130336-e45ffcd953cc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191010075000-0337d82405ff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117220505-0cba7a3a9ee9/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200324003944-a576cf524670/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200329025819-fd4102a86c65/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200414032229-332987a829c3/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200426102838-f3a5411a4c3b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200622203043-20e05c1c8ffa/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200624225443-88f3c62a19ff/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200625211823-6506e20df31f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200626171337-aa94e735be7f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200630154851-b2d8b0336632/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200706234117-b22de6825cf7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200724022722-7017fd6b1305/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200812195022-5ae4c3c160a0/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200831203904-5a2aa26beb65/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +golang.org/x/tools v0.0.0-20201001104356-43ebab892c4c/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201002184944-ecd9fd270d5d/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20201230224404-63754364767c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= +golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= +golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.10.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= +google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= +google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20181107211654-5fc9ac540362/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20190927181202-20e1ac93f88c/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200626011028-ee7919e894b5/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200707001353-8e8330bf89df/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.24.0/go.mod h1:XDChyiUovWa60DnaeDeZmSW86xtLtjtZbwvSiRnRtcA= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.0/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= +google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= +google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/cheggaaa/pb.v1 v1.0.28/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= +gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= +gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.6/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA= +honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw= +mvdan.cc/gofumpt v0.3.1 h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8= +mvdan.cc/gofumpt v0.3.1/go.mod h1:w3ymliuxvzVx8DAutBnVyDqYb1Niy/yCJt/lk821YCE= +mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed h1:WX1yoOaKQfddO/mLzdV4wptyWgoH/6hwLs7QHTixo0I= +mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed/go.mod h1:Xkxe497xwlCKkIaQYRfC7CSLworTXY9RMqwhhCm+8Nc= +mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b h1:DxJ5nJdkhDlLok9K6qO+5290kphDJbHOQO1DFFFTeBo= +mvdan.cc/lint v0.0.0-20170908181259-adc824a0674b/go.mod h1:2odslEg/xrtNQqCYg2/jCoyKnw3vv5biOc3JnIcYfL4= +mvdan.cc/unparam v0.0.0-20220706161116-678bad134442 h1:seuXWbRB1qPrS3NQnHmFKLJLtskWyueeIzmLXghMGgk= +mvdan.cc/unparam v0.0.0-20220706161116-678bad134442/go.mod h1:F/Cxw/6mVrNKqrR2YjFf5CaW0Bw4RL8RfbEf4GRggJk= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= diff --git a/hack/check/tools/tools.go b/hack/check/tools/tools.go new file mode 100644 index 00000000..dd52c0e1 --- /dev/null +++ b/hack/check/tools/tools.go @@ -0,0 +1,13 @@ +//go:build tools +// +build tools + +// Copyright 2021 VMware, Inc. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// Package tools imports things required by build scripts, to force `go mod` to see them as dependencies +package tools + +import ( + _ "github.com/golangci/golangci-lint/cmd/golangci-lint" + _ "github.com/shuLhan/go-bindata" // Force load of go-bindata +) diff --git a/hack/ensure-deps/ensure-actionlint.sh b/hack/ensure-deps/ensure-actionlint.sh new file mode 100755 index 00000000..7f0e70ea --- /dev/null +++ b/hack/ensure-deps/ensure-actionlint.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o nounset +set -o pipefail +set -o xtrace + +CI_BUILD="${CI_BUILD:-""}" +BUILD_OS=$(uname 2>/dev/null || echo Unknown) +# BUILD_ARCH=$(uname -m 2>/dev/null || echo Unknown) +ACTIONLINT_VERSION="1.6.27" + +SUDO_CMD="sudo" +if [[ "${CI_BUILD}" == "true" ]]; then + SUDO_CMD="" +fi + +CMD="actionlint" +if [[ -z "$(command -v ${CMD})" ]]; then +echo "Attempting install of ${CMD}..." +case "${BUILD_OS}" in + Linux) + curl -LO https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz + mkdir actionlint_${ACTIONLINT_VERSION}_linux_amd64 + mv actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz ./actionlint_${ACTIONLINT_VERSION}_linux_amd64 + pushd "./actionlint_${ACTIONLINT_VERSION}_linux_amd64" || exit 1 + tar -xvf actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz + chmod +x ${CMD} + ${SUDO_CMD} install ./${CMD} /usr/local/bin + popd || exit 1 + rm -rf ./actionlint_${ACTIONLINT_VERSION}_linux_amd64 + rm actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz + ;; + Darwin) + brew install actionlint + ;; +esac +fi diff --git a/hack/ensure-deps/ensure-dependencies.sh b/hack/ensure-deps/ensure-dependencies.sh new file mode 100755 index 00000000..158b8b20 --- /dev/null +++ b/hack/ensure-deps/ensure-dependencies.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +# set -o errexit +set -o nounset +set -o pipefail +set -o xtrace + +BUILD_OS=$(uname 2>/dev/null || echo Unknown) +REPO_PATH="$(git rev-parse --show-toplevel)" + +case "${BUILD_OS}" in + Linux) + ;; + Darwin) + ;; + *) + echo "${BUILD_OS} is unsupported" + exit 1 + ;; +esac + +i=0 + +# these are must have dependencies to just get going +if [[ -z "$(command -v go)" ]]; then + echo "Missing go" + ((i=i+1)) +fi +if [[ -z "$(command -v docker)" ]]; then + echo "Missing docker" + ((i=i+1)) +fi +# these are must have dependencies to just get going + +if [[ $i -gt 0 ]]; then + echo "Total missing: $i" + echo "Please install these minimal dependencies in order to continue" + exit 1 +fi + +"${REPO_PATH}/hack/ensure-deps/ensure-actionlint.sh" +"${REPO_PATH}/hack/ensure-deps/ensure-shellcheck.sh" +"${REPO_PATH}/hack/ensure-deps/ensure-diffutils.sh" +"${REPO_PATH}/hack/ensure-deps/ensure-gh-cli.sh" +"${REPO_PATH}/hack/ensure-deps/ensure-jq.sh" +"${REPO_PATH}/hack/ensure-deps/ensure-portaudio.sh" + +echo "No missing dependencies!" diff --git a/hack/ensure-deps/ensure-diffutils.sh b/hack/ensure-deps/ensure-diffutils.sh new file mode 100755 index 00000000..fd8ede5c --- /dev/null +++ b/hack/ensure-deps/ensure-diffutils.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o nounset +set -o pipefail +set -o xtrace + +_CI_BUILD="${_CI_BUILD:-""}" +BUILD_OS=$(uname 2>/dev/null || echo Unknown) +# BUILD_ARCH=$(uname -m 2>/dev/null || echo Unknown) +# VERSION="1.7.1" + +SUDO_CMD="sudo" +if [[ "${_CI_BUILD}" == "true" ]]; then + SUDO_CMD="" +fi + +CMD="diff3" +if [[ -z "$(command -v ${CMD})" ]]; then +echo "Attempting install of ${CMD}..." +case "${BUILD_OS}" in + Linux) + if [[ -f "/etc/redhat-release" ]]; then + ${SUDO_CMD} yum -y install diffutils + elif [[ "$(grep Ubuntu /etc/os-release)" != "" ]]; then + ${SUDO_CMD} apt-get -y install diffutils + else + echo "**** Please install diffutils before proceeding *****" + exit 1 + fi + ;; + Darwin) + brew install diffutils + ;; +esac +fi diff --git a/hack/ensure-deps/ensure-gh-cli.sh b/hack/ensure-deps/ensure-gh-cli.sh new file mode 100755 index 00000000..372a8bbd --- /dev/null +++ b/hack/ensure-deps/ensure-gh-cli.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o nounset +set -o pipefail +set -o xtrace + +CI_BUILD="${CI_BUILD:-""}" +BUILD_OS=$(uname 2>/dev/null || echo Unknown) +# BUILD_ARCH=$(uname -m 2>/dev/null || echo Unknown) +VERSION="2.48.0" + +SUDO_CMD="sudo" +if [[ "${CI_BUILD}" == "true" ]]; then + SUDO_CMD="" +fi + +CMD="gh" +if [[ -z "$(command -v ${CMD})" ]]; then +echo "Attempting install of ${CMD}..." +case "${BUILD_OS}" in + Linux) + curl -LO https://github.com/cli/cli/releases/download/v${VERSION}/gh_${VERSION}_linux_amd64.tar.gz + tar -xvf gh_${VERSION}_linux_amd64.tar.gz + pushd "./gh_${VERSION}_linux_amd64/bin" || exit 1 + chmod +x ${CMD} + ${SUDO_CMD} install ./${CMD} /usr/local/bin + popd || exit 1 + rm -rf ./gh_${VERSION}_linux_amd64 + rm gh_${VERSION}_linux_amd64.tar.gz + ;; + Darwin) + brew install gh + ;; +esac +fi diff --git a/hack/ensure-deps/ensure-jq.sh b/hack/ensure-deps/ensure-jq.sh new file mode 100755 index 00000000..492310ab --- /dev/null +++ b/hack/ensure-deps/ensure-jq.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o nounset +set -o pipefail +set -o xtrace + +_CI_BUILD="${_CI_BUILD:-""}" +BUILD_OS=$(uname 2>/dev/null || echo Unknown) +# BUILD_ARCH=$(uname -m 2>/dev/null || echo Unknown) +VERSION="1.7.1" + +SUDO_CMD="sudo" +if [[ "${_CI_BUILD}" == "true" ]]; then + SUDO_CMD="" +fi + +CMD="jq" +if [[ -z "$(command -v ${CMD})" ]]; then +echo "Attempting install of ${CMD}..." +case "${BUILD_OS}" in + Linux) + curl -L "https://github.com/stedolan/jq/releases/download/jq-${VERSION}/jq-linux64" -o "jq" + chmod +x jq + ${SUDO_CMD} mv ${CMD} /usr/local/bin + ;; + Darwin) + brew install jq + ;; +esac +fi diff --git a/hack/ensure-deps/ensure-portaudio.sh b/hack/ensure-deps/ensure-portaudio.sh new file mode 100755 index 00000000..c9f3b7b6 --- /dev/null +++ b/hack/ensure-deps/ensure-portaudio.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o nounset +set -o pipefail +set -o xtrace + +_CI_BUILD="${_CI_BUILD:-""}" +BUILD_OS=$(uname 2>/dev/null || echo Unknown) +# BUILD_ARCH=$(uname -m 2>/dev/null || echo Unknown) +# VERSION="1.7.1" + +SUDO_CMD="sudo" +if [[ "${_CI_BUILD}" == "true" ]]; then + SUDO_CMD="" +fi + +CMD="portaudio" +if [[ -z "$(command -v ${CMD})" ]]; then +echo "Attempting install of ${CMD}..." +case "${BUILD_OS}" in + Linux) + if [[ -f "/etc/redhat-release" ]]; then + ${SUDO_CMD} yum -y install portaudio19-dev + elif [[ "$(grep Ubuntu /etc/os-release)" != "" ]]; then + ${SUDO_CMD} apt-get -y install portaudio19-dev + else + echo "**** Please install portaudio before proceeding *****" + exit 1 + fi + ;; + Darwin) + brew install portaudio + ;; +esac +fi diff --git a/hack/ensure-deps/ensure-shellcheck.sh b/hack/ensure-deps/ensure-shellcheck.sh new file mode 100755 index 00000000..dc8afb72 --- /dev/null +++ b/hack/ensure-deps/ensure-shellcheck.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +# Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +# Use of this source code is governed by a MIT license that can be found in the LICENSE file. +# SPDX-License-Identifier: MIT + +set -o nounset +set -o pipefail +set -o xtrace + +_CI_BUILD="${_CI_BUILD:-""}" +BUILD_OS=$(uname 2>/dev/null || echo Unknown) +# BUILD_ARCH=$(uname -m 2>/dev/null || echo Unknown) +VERSION="0.10.0" + +SUDO_CMD="sudo" +if [[ "${_CI_BUILD}" == "true" ]]; then + SUDO_CMD="" +fi + +CMD="shellcheck" +if [[ -z "$(command -v ${CMD})" ]]; then +echo "Attempting install of ${CMD}..." +case "${BUILD_OS}" in + Linux) + curl -LO https://github.com/koalaman/shellcheck/releases/download/v${VERSION}/shellcheck-v${VERSION}.linux.x86_64.tar.xz + tar -xvf shellcheck-v${VERSION}.linux.x86_64.tar.xz + pushd "./shellcheck-v${VERSION}" || exit 1 + chmod +x ${CMD} + ${SUDO_CMD} install ./${CMD} /usr/local/bin + popd || exit 1 + rm -rf ./shellcheck-v${VERSION} + rm shellcheck-v${VERSION}.linux.x86_64.tar.xz + ;; + Darwin) + # case "${BUILD_ARCH}" in + # x86_64) + # brew install shellcheck + # ;; + # arm64) + # brew install shellcheck + # ;; + # esac + brew install shellcheck + ;; +esac +fi diff --git a/pkg/api/analyze/v1/analyze.go b/pkg/api/analyze/v1/analyze.go index f5e08b54..85c12501 100644 --- a/pkg/api/analyze/v1/analyze.go +++ b/pkg/api/analyze/v1/analyze.go @@ -8,126 +8,82 @@ package analyze import ( "context" "io" - "net/http" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/analyze/v1/interfaces" - client "github.com/deepgram/deepgram-go-sdk/pkg/client/analyze" + analyze "github.com/deepgram/deepgram-go-sdk/pkg/client/analyze" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) -type AnalyzeClient struct { - *client.Client +type Client struct { + *analyze.Client } -func New(client *client.Client) *AnalyzeClient { - return &AnalyzeClient{client} +// New creates a new Client +func New(client *analyze.Client) *Client { + return &Client{client} } -func (c *AnalyzeClient) FromFile(ctx context.Context, file string, options interfaces.AnalyzeOptions) (*api.AnalyzeResponse, error) { - klog.V(6).Infof("analyze.FromFile ENTER\n") - klog.V(3).Infof("filePath: %s\n", file) - - // checks - if ctx == nil { - ctx = context.Background() - } - err := options.Check() - if err != nil { - klog.V(1).Infof("AnalyzeOptions.Check() failed. Err: %v\n", err) - return nil, err - } - - // send the file! - var resp api.AnalyzeResponse - err = c.Client.DoFile(ctx, file, options, &resp) - if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("analyze.FromFile ENTER\n") - return nil, err - } - } +// FromFile transcribes a prerecorded audio file from a file +func (c *Client) FromFile(ctx context.Context, file string, options *interfaces.AnalyzeOptions) (*api.AnalyzeResponse, error) { + return c.sendAnalysis(ctx, func(ctx context.Context, opts *interfaces.AnalyzeOptions, resp interface{}) error { + return c.sendFile(ctx, file, opts, resp) + }, options) +} - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("analyze.FromFile ENTER\n") - return nil, err - } +// FromStream transcribes a prerecorded audio file from a stream +func (c *Client) FromStream(ctx context.Context, src io.Reader, options *interfaces.AnalyzeOptions) (*api.AnalyzeResponse, error) { + return c.sendAnalysis(ctx, func(ctx context.Context, opts *interfaces.AnalyzeOptions, resp interface{}) error { + return c.sendStream(ctx, src, opts, resp) + }, options) +} - klog.V(3).Infof("FromFile Succeeded\n") - klog.V(6).Infof("analyze.FromFile ENTER\n") - return &resp, nil +// FromURL transcribes a prerecorded audio file from a URL +func (c *Client) FromURL(ctx context.Context, url string, options *interfaces.AnalyzeOptions) (*api.AnalyzeResponse, error) { + return c.sendAnalysis(ctx, func(ctx context.Context, opts *interfaces.AnalyzeOptions, resp interface{}) error { + return c.sendURL(ctx, url, opts, resp) + }, options) } -func (c *AnalyzeClient) FromStream(ctx context.Context, src io.Reader, options interfaces.AnalyzeOptions) (*api.AnalyzeResponse, error) { - klog.V(6).Infof("analyze.FromStream ENTER\n") +// private functions +type sendFunc func(ctx context.Context, options *interfaces.AnalyzeOptions, resp interface{}) error - // checks - if ctx == nil { - ctx = context.Background() - } - err := options.Check() - if err != nil { - klog.V(1).Infof("AnalyzeOptions.Check() failed. Err: %v\n", err) - return nil, err - } - - // send the file! - var resp api.AnalyzeResponse - err = c.Client.DoStream(ctx, src, options, &resp) - if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("analyze.FromStream LEAVE\n") - return nil, err - } - } +func (c *Client) sendFile(ctx context.Context, filePath string, options *interfaces.AnalyzeOptions, resp interface{}) error { + return c.Client.DoFile(ctx, filePath, options, resp) +} - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("analyze.FromStream LEAVE\n") - return nil, err - } +func (c *Client) sendStream(ctx context.Context, src io.Reader, options *interfaces.AnalyzeOptions, resp interface{}) error { + return c.Client.DoStream(ctx, src, options, resp) +} - klog.V(3).Infof("FromStream Succeeded\n") - klog.V(6).Infof("analyze.FromStream LEAVE\n") - return &resp, nil +func (c *Client) sendURL(ctx context.Context, url string, options *interfaces.AnalyzeOptions, resp interface{}) error { + return c.Client.DoURL(ctx, url, options, resp) } -func (c *AnalyzeClient) FromURL(ctx context.Context, url string, options interfaces.AnalyzeOptions) (*api.AnalyzeResponse, error) { - klog.V(6).Infof("analyze.FromURL ENTER\n") +func (c *Client) sendAnalysis(ctx context.Context, sender sendFunc, options *interfaces.AnalyzeOptions) (*api.AnalyzeResponse, error) { + klog.V(6).Infof("analyze.sendAnalysis ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } err := options.Check() if err != nil { klog.V(1).Infof("AnalyzeOptions.Check() failed. Err: %v\n", err) + klog.V(6).Infof("analyze.sendAnalysis LEAVE\n") return nil, err } - // send the file! var resp api.AnalyzeResponse - err = c.Client.DoURL(ctx, url, options, &resp) + + err = sender(ctx, options, &resp) if err != nil { if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("analyze.FromURL LEAVE\n") - return nil, err - } + klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) } - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("analyze.FromURL LEAVE\n") + klog.V(6).Infof("analyze.sendAnalysis LEAVE\n") return nil, err } - klog.V(3).Infof("FromURL Succeeded\n") - klog.V(6).Infof("analyze.FromURL LEAVE\n") - + klog.V(3).Infof("sendAnalysis Succeeded\n") + klog.V(6).Infof("analyze.sendAnalysis LEAVE\n") return &resp, nil } diff --git a/pkg/api/live/v1/constants.go b/pkg/api/live/v1/constants.go index ab3a7b3a..7b786d4d 100644 --- a/pkg/api/live/v1/constants.go +++ b/pkg/api/live/v1/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/live/v1/default.go b/pkg/api/live/v1/default.go index bdb9af6c..0ae3b9a0 100644 --- a/pkg/api/live/v1/default.go +++ b/pkg/api/live/v1/default.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -33,19 +33,19 @@ func (dch DefaultCallbackHandler) Open(or *interfaces.OpenResponse) error { debugStr = v } - if strings.Compare(strings.ToLower(debugStr), "true") == 0 { + if strings.EqualFold(debugStr, "true") { data, err := json.Marshal(or) if err != nil { klog.V(1).Infof("Open json.Marshal failed. Err: %v\n", err) return err } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { klog.V(1).Infof("prettyjson.Marshal failed. Err: %v\n", err) return err } - klog.V(2).Infof("\n\nOpen Object:\n%s\n\n", prettyJson) + klog.V(2).Infof("\n\nOpen Object:\n%s\n\n", prettyJSON) return nil } @@ -64,19 +64,19 @@ func (dch DefaultCallbackHandler) Message(mr *interfaces.MessageResponse) error debugStr = v } - if strings.Compare(strings.ToLower(debugStr), "true") == 0 { + if strings.EqualFold(debugStr, "true") { data, err := json.Marshal(mr) if err != nil { klog.V(1).Infof("Message json.Marshal failed. Err: %v\n", err) return err } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { klog.V(1).Infof("prettyjson.Marshal failed. Err: %v\n", err) return err } - klog.V(2).Infof("\n\nMessage Object:\n%s\n\n", prettyJson) + klog.V(2).Infof("\n\nMessage Object:\n%s\n\n", prettyJSON) return nil } @@ -84,7 +84,7 @@ func (dch DefaultCallbackHandler) Message(mr *interfaces.MessageResponse) error // handle the message sentence := strings.TrimSpace(mr.Channel.Alternatives[0].Transcript) - if len(mr.Channel.Alternatives) == 0 || len(sentence) == 0 { + if len(mr.Channel.Alternatives) == 0 || sentence == "" { klog.V(7).Infof("DEEPGRAM - no transcript") return nil } @@ -101,19 +101,19 @@ func (dch DefaultCallbackHandler) Metadata(md *interfaces.MetadataResponse) erro debugStr = v } - if strings.Compare(strings.ToLower(debugStr), "true") == 0 { + if strings.EqualFold(debugStr, "true") { data, err := json.Marshal(md) if err != nil { klog.V(1).Infof("Metadata json.Marshal failed. Err: %v\n", err) return err } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { klog.V(1).Infof("prettyjson.Marshal failed. Err: %v\n", err) return err } - klog.V(2).Infof("\n\nMetadata Object:\n%s\n\n", prettyJson) + klog.V(2).Infof("\n\nMetadata Object:\n%s\n\n", prettyJSON) return nil } @@ -134,19 +134,19 @@ func (dch DefaultCallbackHandler) SpeechStarted(ssr *interfaces.SpeechStartedRes debugStr = v } - if strings.Compare(strings.ToLower(debugStr), "true") == 0 { + if strings.EqualFold(debugStr, "true") { data, err := json.Marshal(ssr) if err != nil { klog.V(1).Infof("SpeechStarted json.Marshal failed. Err: %v\n", err) return err } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { klog.V(1).Infof("prettyjson.Marshal failed. Err: %v\n", err) return err } - klog.V(2).Infof("\n\nSpeechStarted Object:\n%s\n\n", prettyJson) + klog.V(2).Infof("\n\nSpeechStarted Object:\n%s\n\n", prettyJSON) return nil } @@ -177,19 +177,19 @@ func (dch DefaultCallbackHandler) Close(or *interfaces.CloseResponse) error { debugStr = v } - if strings.Compare(strings.ToLower(debugStr), "true") == 0 { + if strings.EqualFold(debugStr, "true") { data, err := json.Marshal(or) if err != nil { klog.V(1).Infof("Close json.Marshal failed. Err: %v\n", err) return err } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { klog.V(1).Infof("prettyjson.Marshal failed. Err: %v\n", err) return err } - klog.V(2).Infof("\n\nClose Object:\n%s\n\n", prettyJson) + klog.V(2).Infof("\n\nClose Object:\n%s\n\n", prettyJSON) return nil } @@ -208,19 +208,19 @@ func (dch DefaultCallbackHandler) Error(er *interfaces.ErrorResponse) error { debugStr = v } - if strings.Compare(strings.ToLower(debugStr), "true") == 0 { + if strings.EqualFold(debugStr, "true") { data, err := json.Marshal(er) if err != nil { klog.V(1).Infof("Error json.Marshal failed. Err: %v\n", err) return err } - prettyJson, err := prettyjson.Format(data) + prettyJSON, err := prettyjson.Format(data) if err != nil { klog.V(1).Infof("prettyjson.Marshal failed. Err: %v\n", err) return err } - klog.V(2).Infof("\n\nError Object:\n%s\n\n", prettyJson) + klog.V(2).Infof("\n\nError Object:\n%s\n\n", prettyJSON) return nil } @@ -241,12 +241,12 @@ func (dch DefaultCallbackHandler) UnhandledEvent(byData []byte) error { debugStr = v } - if strings.Compare(strings.ToLower(debugStr), "true") == 0 { - prettyJson, err := prettyjson.Format(byData) + if strings.EqualFold(debugStr, "true") { + prettyJSON, err := prettyjson.Format(byData) if err != nil { klog.V(2).Infof("\n\nRaw Data:\n%s\n\n", string(byData)) } else { - klog.V(2).Infof("\n\nError Object:\n%s\n\n", prettyJson) + klog.V(2).Infof("\n\nError Object:\n%s\n\n", prettyJSON) } return nil diff --git a/pkg/api/live/v1/interfaces/interfaces.go b/pkg/api/live/v1/interfaces/interfaces.go index 63fa433c..c667b47f 100644 --- a/pkg/api/live/v1/interfaces/interfaces.go +++ b/pkg/api/live/v1/interfaces/interfaces.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/live/v1/interfaces/types.go b/pkg/api/live/v1/interfaces/types.go index 1d891ce3..fa2e532b 100644 --- a/pkg/api/live/v1/interfaces/types.go +++ b/pkg/api/live/v1/interfaces/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/live/v1/router.go b/pkg/api/live/v1/router.go index 31df72f2..148419a5 100644 --- a/pkg/api/live/v1/router.go +++ b/pkg/api/live/v1/router.go @@ -1,8 +1,6 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT - -// This package defines the live API for Deepgram package live import ( @@ -16,351 +14,175 @@ import ( interfaces "github.com/deepgram/deepgram-go-sdk/pkg/api/live/v1/interfaces" ) -// MessageRouter is helper struct that routes events +// MessageRouter routes events type MessageRouter struct { callback interfaces.LiveMessageCallback debugWebsocket bool } -// NewWithDefault creates a default MessageRouter +// NewWithDefault creates a MessageRouter with the default callback handler func NewWithDefault() *MessageRouter { return New(NewDefaultCallbackHandler()) } -// New creates a MessageRouter with user defined callback +// New creates a MessageRouter with a user-defined callback func New(callback interfaces.LiveMessageCallback) *MessageRouter { - var debugStr string - if v := os.Getenv("DEEPGRAM_DEBUG_WEBSOCKET"); v != "" { - klog.V(4).Infof("DEEPGRAM_DEBUG_WEBSOCKET found") - debugStr = v - } - + debugStr := os.Getenv("DEEPGRAM_DEBUG_WEBSOCKET") return &MessageRouter{ callback: callback, - debugWebsocket: (strings.EqualFold(strings.ToLower(debugStr), "true")), + debugWebsocket: strings.EqualFold(strings.ToLower(debugStr), "true"), } } -// OpenResponse handles the OpenResponse message +// OpenHelper handles the OpenResponse message func (r *MessageRouter) OpenHelper(or *interfaces.OpenResponse) error { - obj, err := json.Marshal(or) - if err != nil { - klog.V(1).Infof("Open json.Marshal failed. Err: %v\n", err) - return err - } - - return r.OpenResponse(obj) + return r.callback.Open(or) } // OpenResponse handles the OpenResponse message -func (r *MessageRouter) OpenResponse(byMsg []byte) error { - klog.V(6).Infof("router.OpenResponse ENTER\n") - - // trace debugging - r.printDebugMessages(5, "OpenResponse", byMsg) - - var or interfaces.OpenResponse - err := json.Unmarshal(byMsg, &or) - if err != nil { - klog.V(1).Infof("OpenResponse json.Unmarshal failed. Err: %v\n", err) - klog.V(6).Infof("router.OpenResponse LEAVE\n") - return err - } - - if r.callback != nil { - err := r.callback.Open(&or) - if err != nil { - klog.V(1).Infof("callback.OpenResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.OpenResponse succeeded\n") - } - klog.V(6).Infof("router.OpenResponse LEAVE\n") - return err - } - - klog.V(1).Infof("User callback is undefined\n") - klog.V(6).Infof("router.OpenResponse LEAVE\n") - - return nil +func (r *MessageRouter) CloseHelper(or *interfaces.CloseResponse) error { + return r.callback.Close(or) } -// Message handles platform messages -func (r *MessageRouter) Message(byMsg []byte) error { - klog.V(6).Infof("router.Message ENTER\n") +// processMessage generalizes the handling of all message types +func (r *MessageRouter) processGeneric(msgType string, byMsg []byte, action func(data *interface{}) error, data interface{}) error { + klog.V(6).Infof("router.%s ENTER\n", msgType) - if r.debugWebsocket { - klog.V(5).Infof("Raw Message:\n%s\n", string(byMsg)) - } + r.printDebugMessages(5, msgType, byMsg) - // what is the high level message here? - var mt MessageType - err := json.Unmarshal(byMsg, &mt) - if err != nil { - klog.V(1).Infof("json.Unmarshal(MessageType) failed. Err: %v\n", err) - klog.V(6).Infof("router.Message LEAVE\n") - return err - } - - klog.V(6).Infof("MessageType(%s) before\n", mt.Type) - - switch mt.Type { - case interfaces.TypeMessageResponse: - err = r.MessageResponse(byMsg) - case interfaces.TypeMetadataResponse: - err = r.MetadataResponse(byMsg) - case interfaces.TypeSpeechStartedResponse: - err = r.SpeechStartedResponse(byMsg) - case interfaces.TypeUtteranceEndResponse: - err = r.UtteranceEndResponse(byMsg) - case interfaces.TypeErrorResponse: - err = r.ErrorResponse(byMsg) - default: - err = r.UnhandledMessage(byMsg) - } - - if err == nil { - klog.V(6).Infof("MessageType(%s) after - Result: succeeded\n", mt.Type) + var err error + if err = action(&data); err != nil { + klog.V(1).Infof("callback.%s failed. Err: %v\n", msgType, err) } else { - klog.V(5).Infof("MessageType(%s) after - Result: %v\n", mt.Type, err) + klog.V(5).Infof("callback.%s succeeded\n", msgType) } - klog.V(6).Infof("router.Message LEAVE\n") + klog.V(6).Infof("router.%s LEAVE\n", msgType) return err } -// MessageResponse handles the MessageResponse message -func (r *MessageRouter) MessageResponse(byMsg []byte) error { - klog.V(6).Infof("router.MessageResponse ENTER\n") - - var mr interfaces.MessageResponse - err := json.Unmarshal(byMsg, &mr) - if err != nil { - klog.V(1).Infof("MessageResponse json.Unmarshal failed. Err: %v\n", err) - klog.V(6).Infof("router.MessageResponse LEAVE\n") +func (r *MessageRouter) processMessage(byMsg []byte) error { + var msg interfaces.MessageResponse + if err := json.Unmarshal(byMsg, &msg); err != nil { return err } - // this is too chatty is sentence is " " reduce the frequency of the log - if len(mr.Channel.Alternatives) > 0 && len(strings.TrimSpace(mr.Channel.Alternatives[0].Transcript)) == 0 { - r.printDebugMessages(7, "MessageResponse", byMsg) - } else { - r.printDebugMessages(5, "MessageResponse", byMsg) + action := func(data *interface{}) error { + return r.callback.Message(&msg) } - if r.callback != nil { - err := r.callback.Message(&mr) - if err != nil { - klog.V(1).Infof("callback.MessageResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.MessageResponse succeeded\n") - } - klog.V(6).Infof("router.MessageResponse LEAVE\n") - return err - } - - klog.V(1).Infof("User callback is undefined\n") - klog.V(6).Infof("router.MessageResponse LEAVE\n") - - return ErrUserCallbackNotDefined + return r.processGeneric("MessageResponse", byMsg, action, msg) } -func (r *MessageRouter) MetadataResponse(byMsg []byte) error { - klog.V(6).Infof("router.MetadataResponse ENTER\n") - - // trace debugging - r.printDebugMessages(5, "MetadataResponse", byMsg) - - var md interfaces.MetadataResponse - err := json.Unmarshal(byMsg, &md) - if err != nil { - klog.V(1).Infof("MetadataResponse json.Unmarshal failed. Err: %v\n", err) - klog.V(6).Infof("router.MetadataResponse LEAVE\n") +func (r *MessageRouter) processMetadata(byMsg []byte) error { + var msg interfaces.MetadataResponse + if err := json.Unmarshal(byMsg, &msg); err != nil { return err } - if r.callback != nil { - err := r.callback.Metadata(&md) - if err != nil { - klog.V(1).Infof("callback.MetadataResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.MetadataResponse succeeded\n") - } - klog.V(6).Infof("router.MetadataResponse LEAVE\n") - return err + action := func(data *interface{}) error { + return r.callback.Metadata(&msg) } - klog.V(1).Infof("User callback is undefined\n") - klog.V(6).Infof("router.MetadataResponse ENTER\n") - - return nil + return r.processGeneric("MetadataResponse", byMsg, action, msg) } -func (r *MessageRouter) SpeechStartedResponse(byMsg []byte) error { - klog.V(6).Infof("router.SpeechStartedResponse ENTER\n") - - // trace debugging - r.printDebugMessages(5, "SpeechStartedResponse", byMsg) - - var ssr interfaces.SpeechStartedResponse - err := json.Unmarshal(byMsg, &ssr) - if err != nil { - klog.V(1).Infof("SpeechStartedResponse json.Unmarshal failed. Err: %v\n", err) - klog.V(6).Infof("router.SpeechStartedResponse LEAVE\n") +func (r *MessageRouter) processSpeechStartedResponse(byMsg []byte) error { + var msg interfaces.SpeechStartedResponse + if err := json.Unmarshal(byMsg, &msg); err != nil { return err } - if r.callback != nil { - err := r.callback.SpeechStarted(&ssr) - if err != nil { - klog.V(1).Infof("callback.SpeechStartedResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.SpeechStartedResponse succeeded\n") - } - klog.V(6).Infof("router.SpeechStartedResponse LEAVE\n") - return err + action := func(data *interface{}) error { + return r.callback.SpeechStarted(&msg) } - klog.V(1).Infof("User callback is undefined\n") - klog.V(6).Infof("router.SpeechStartedResponse ENTER\n") - - return nil + return r.processGeneric("SpeechStartedResponse", byMsg, action, msg) } -func (r *MessageRouter) UtteranceEndResponse(byMsg []byte) error { - klog.V(6).Infof("router.UtteranceEndResponse ENTER\n") - - // trace debugging - r.printDebugMessages(5, "UtteranceEndResponse", byMsg) - - var ur interfaces.UtteranceEndResponse - err := json.Unmarshal(byMsg, &ur) - if err != nil { - klog.V(1).Infof("UtteranceEndResponse json.Unmarshal failed. Err: %v\n", err) - klog.V(6).Infof("router.UtteranceEndResponse LEAVE\n") +func (r *MessageRouter) processUtteranceEndResponse(byMsg []byte) error { + var msg interfaces.UtteranceEndResponse + if err := json.Unmarshal(byMsg, &msg); err != nil { return err } - if r.callback != nil { - err := r.callback.UtteranceEnd(&ur) - if err != nil { - klog.V(1).Infof("callback.UtteranceEndResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.UtteranceEndResponse succeeded\n") - } - klog.V(6).Infof("router.UtteranceEndResponse LEAVE\n") - return err - } - - klog.V(1).Infof("User callback is undefined\n") - klog.V(6).Infof("router.UtteranceEndResponse ENTER\n") - - return nil -} - -// CloseHelper handles the CloseResponse message -func (r *MessageRouter) CloseHelper(cr *interfaces.CloseResponse) error { - obj, err := json.Marshal(cr) - if err != nil { - klog.V(1).Infof("close json.Marshal failed. Err: %v\n", err) - return err + action := func(data *interface{}) error { + return r.callback.UtteranceEnd(&msg) } - return r.CloseResponse(obj) + return r.processGeneric("UtteranceEndResponse", byMsg, action, msg) } -// CloseResponse handles the CloseResponse message -func (r *MessageRouter) CloseResponse(byMsg []byte) error { - klog.V(6).Infof("router.CloseResponse ENTER\n") - - // trace debugging - r.printDebugMessages(5, "CloseResponse", byMsg) - - var cr interfaces.CloseResponse - err := json.Unmarshal(byMsg, &cr) - if err != nil { - klog.V(1).Infof("CloseResponse json.Unmarshal failed. Err: %v\n", err) - klog.V(6).Infof("router.CloseResponse LEAVE\n") +func (r *MessageRouter) processErrorResponse(byMsg []byte) error { + var msg interfaces.ErrorResponse + if err := json.Unmarshal(byMsg, &msg); err != nil { return err } - if r.callback != nil { - err := r.callback.Close(&cr) - if err != nil { - klog.V(1).Infof("callback.CloseResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.CloseResponse succeeded\n") - } - klog.V(6).Infof("router.CloseResponse LEAVE\n") - return err + action := func(data *interface{}) error { + return r.callback.Error(&msg) } - klog.V(1).Infof("User callback is undefined\n") - klog.V(6).Infof("router.CloseResponse ENTER\n") - - return nil + return r.processGeneric("ErrorResponse", byMsg, action, msg) } -func (r *MessageRouter) ErrorResponse(byMsg []byte) error { - klog.V(6).Infof("router.ErrorResponse ENTER\n") - - // trace debugging - r.printDebugMessages(5, "ErrorResponse", byMsg) +// Message handles platform messages and routes them appropriately based on the MessageType +func (r *MessageRouter) Message(byMsg []byte) error { + klog.V(6).Infof("router.Message ENTER\n") - var er interfaces.ErrorResponse - err := json.Unmarshal(byMsg, &er) - if err != nil { - klog.V(1).Infof("ErrorResponse json.Unmarshal failed. Err: %v\n", err) - klog.V(6).Infof("router.ErrorResponse LEAVE\n") - return err + if r.debugWebsocket { + klog.V(5).Infof("Raw Message:\n%s\n", string(byMsg)) } - if r.callback != nil { - err := r.callback.Error(&er) - if err != nil { - klog.V(1).Infof("callback.ErrorResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.ErrorResponse succeeded\n") - } - klog.V(6).Infof("router.ErrorResponse LEAVE\n") + var mt MessageType + if err := json.Unmarshal(byMsg, &mt); err != nil { + klog.V(1).Infof("json.Unmarshal(MessageType) failed. Err: %v\n", err) + klog.V(6).Infof("router.Message LEAVE\n") return err } - klog.V(1).Infof("User callback is undefined\n") - klog.V(6).Infof("router.ErrorResponse ENTER\n") + var err error + switch mt.Type { + case interfaces.TypeMessageResponse: + err = r.processMessage(byMsg) + case interfaces.TypeMetadataResponse: + err = r.processMetadata(byMsg) + case interfaces.TypeSpeechStartedResponse: + err = r.processSpeechStartedResponse(byMsg) + case interfaces.TypeUtteranceEndResponse: + err = r.processUtteranceEndResponse(byMsg) + case interfaces.TypeErrorResponse: + err = r.processErrorResponse(byMsg) + default: + err = r.UnhandledMessage(byMsg) + } - return nil + if err == nil { + klog.V(6).Infof("MessageType(%s) after - Result: succeeded\n", mt.Type) + } else { + klog.V(5).Infof("MessageType(%s) after - Result: %v\n", mt.Type, err) + } + klog.V(6).Infof("router.Message LEAVE\n") + return err } -// UnhandledMessage handles the UnhandledMessage message +// UnhandledMessage logs and handles any unexpected message types func (r *MessageRouter) UnhandledMessage(byMsg []byte) error { klog.V(6).Infof("router.UnhandledMessage ENTER\n") - - // trace debugging r.printDebugMessages(3, "UnhandledMessage", byMsg) - - if r.callback != nil { - err := r.callback.UnhandledEvent(byMsg) - if err != nil { - klog.V(1).Infof("callback.ErrorResponse failed. Err: %v\n", err) - } else { - klog.V(5).Infof("callback.ErrorResponse succeeded\n") - } - klog.V(6).Infof("router.ErrorResponse LEAVE\n") - return err - } - klog.V(1).Infof("Unknown Event was received\n") klog.V(6).Infof("router.UnhandledMessage LEAVE\n") return ErrInvalidMessageType } +// printDebugMessages formats and logs debugging messages func (r *MessageRouter) printDebugMessages(level klog.Level, function string, byMsg []byte) { - prettyJson, err := prettyjson.Format(byMsg) + prettyJSON, err := prettyjson.Format(byMsg) if err != nil { klog.V(1).Infof("prettyjson.Format failed. Err: %v\n", err) + return } - klog.V(level).Infof("\n\n-----------------------------------------------\n") - klog.V(level).Infof("%s RAW:\n%s\n", function, prettyJson) + klog.V(level).Infof("%s RAW:\n%s\n", function, prettyJSON) klog.V(level).Infof("-----------------------------------------------\n\n\n") } diff --git a/pkg/api/live/v1/types.go b/pkg/api/live/v1/types.go index 52a21dd6..3e30f205 100644 --- a/pkg/api/live/v1/types.go +++ b/pkg/api/live/v1/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/manage/v1/balances.go b/pkg/api/manage/v1/balances.go index 13a23a4a..8c900f1a 100644 --- a/pkg/api/manage/v1/balances.go +++ b/pkg/api/manage/v1/balances.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -11,108 +11,41 @@ package manage import ( "context" - "net/http" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/manage/v1/interfaces" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) // ListBalances lists all balances for a project -func (c *ManageClient) ListBalances(ctx context.Context, projectId string) (*api.BalancesResult, error) { +func (c *Client) ListBalances(ctx context.Context, projectID string) (*api.BalancesResult, error) { klog.V(6).Infof("manage.ListBalances() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.BalancesURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListBalances() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListBalances() LEAVE\n") - return nil, err - } - - // Do it! var resp api.BalancesResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.BalancesURI, nil, &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.ListBalances() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.ListBalances() LEAVE\n") - return nil, err + klog.V(1).Infof("ListBalances failed. Err: %v\n", err) + } else { + klog.V(3).Infof("ListBalances Succeeded\n") } - klog.V(3).Infof("ListBalances Succeeded\n") klog.V(6).Infof("manage.ListBalances() LEAVE\n") return &resp, nil } // GetBalance gets a balance for a project -func (c *ManageClient) GetBalance(ctx context.Context, projectId string, balanceId string) (*api.BalanceResult, error) { +func (c *Client) GetBalance(ctx context.Context, projectID, balanceID string) (*api.BalanceResult, error) { klog.V(6).Infof("manage.GetBalance() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.BalancesByIdURI, nil, projectId, balanceId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetBalance() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetBalance() LEAVE\n") - return nil, err - } - - // Do it! var resp api.BalanceResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.BalancesByIDURI, nil, &resp, projectID, balanceID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.GetBalance() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.GetBalance() LEAVE\n") - return nil, err + klog.V(1).Infof("GetBalance failed. Err: %v\n", err) + } else { + klog.V(3).Infof("GetBalance Succeeded\n") } - klog.V(3).Infof("GetBalance Succeeded\n") klog.V(6).Infof("manage.GetBalance() LEAVE\n") return &resp, nil } diff --git a/pkg/api/manage/v1/constants.go b/pkg/api/manage/v1/constants.go index d5b51546..83b64f48 100644 --- a/pkg/api/manage/v1/constants.go +++ b/pkg/api/manage/v1/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/manage/v1/interfaces/types.go b/pkg/api/manage/v1/interfaces/types.go index b1efbd72..390e832b 100644 --- a/pkg/api/manage/v1/interfaces/types.go +++ b/pkg/api/manage/v1/interfaces/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/manage/v1/invitations.go b/pkg/api/manage/v1/invitations.go index 4491b33a..b1c50572 100644 --- a/pkg/api/manage/v1/invitations.go +++ b/pkg/api/manage/v1/invitations.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -15,210 +15,79 @@ import ( "bytes" "context" "encoding/json" - "net/http" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/manage/v1/interfaces" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) // ListInvitations lists all invitations for a project -func (c *ManageClient) ListInvitations(ctx context.Context, projectId string) (*api.InvitationsResult, error) { +func (c *Client) ListInvitations(ctx context.Context, projectID string) (*api.InvitationsResult, error) { klog.V(6).Infof("manage.ListInvitations() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.InvitationsURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListInvitations() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListInvitations() LEAVE\n") - return nil, err - } - - // Do it! var resp api.InvitationsResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.InvitationsURI, nil, &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.ListInvitations() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.ListInvitations() LEAVE\n") - return nil, err + klog.V(1).Infof("ListInvitations failed. Err: %v\n", err) + } else { + klog.V(3).Infof("ListInvitations Succeeded\n") } - klog.V(3).Infof("ListInvitations Succeeded\n") klog.V(6).Infof("manage.ListInvitations() LEAVE\n") - return &resp, nil + return &resp, err } // SendInvitation sends an invitation to a project -func (c *ManageClient) SendInvitation(ctx context.Context, projectId string, invite *api.InvitationRequest) (*api.MessageResult, error) { +func (c *Client) SendInvitation(ctx context.Context, projectID string, invite *api.InvitationRequest) (*api.MessageResult, error) { klog.V(6).Infof("manage.SendInvitation() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.InvitationsURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.SendInvitation() ENTER\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - jsonStr, err := json.Marshal(invite) if err != nil { klog.V(1).Infof("json.Marshal failed. Err: %v\n", err) - klog.V(6).Infof("manage.SendInvitation() ENTER\n") return nil, err } - req, err := http.NewRequestWithContext(ctx, "POST", URI, bytes.NewBuffer(jsonStr)) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.SendInvitation() ENTER\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err = c.apiRequest(ctx, "POST", version.InvitationsURI, bytes.NewBuffer(jsonStr), &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.SendInvitation() ENTER\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.SendInvitation() ENTER\n") - return nil, err + klog.V(1).Infof("SendInvitation failed. Err: %v\n", err) + } else { + klog.V(3).Infof("SendInvitation Succeeded\n") } - klog.V(3).Infof("SendInvitation Succeeded\n") klog.V(6).Infof("manage.SendInvitation() ENTER\n") - return &resp, nil + return &resp, err } // DeleteInvitation deletes an invitation to a project -func (c *ManageClient) DeleteInvitation(ctx context.Context, projectId string, email string) (*api.MessageResult, error) { +func (c *Client) DeleteInvitation(ctx context.Context, projectID, email string) (*api.MessageResult, error) { klog.V(6).Infof("manage.DeleteInvitation() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.InvitationsByIdURI, nil, projectId, email) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.DeleteInvitation() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "DELETE", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.DeleteInvitation() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "DELETE", version.InvitationsByIDURI, nil, &resp, projectID, email) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.DeleteInvitation() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.DeleteInvitation() LEAVE\n") - return nil, err + klog.V(1).Infof("DeleteInvitation failed. Err: %v\n", err) + } else { + klog.V(3).Infof("DeleteInvitation Succeeded\n") } - klog.V(3).Infof("DeleteInvitation Succeeded\n") klog.V(6).Infof("manage.DeleteInvitation() LEAVE\n") - return &resp, nil + return &resp, err } // LeaveProject leaves a project -func (c *ManageClient) LeaveProject(ctx context.Context, projectId string) (*api.MessageResult, error) { +func (c *Client) LeaveProject(ctx context.Context, projectID string) (*api.MessageResult, error) { klog.V(6).Infof("manage.LeaveProject() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.InvitationsLeaveURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.LeaveProject() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "DELETE", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.LeaveProject() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "DELETE", version.InvitationsLeaveURI, nil, &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.LeaveProject() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.LeaveProject() LEAVE\n") - return nil, err + klog.V(1).Infof("LeaveProject failed. Err: %v\n", err) + } else { + klog.V(3).Infof("LeaveProject Succeeded\n") } - klog.V(3).Infof("LeaveProject Succeeded\n") klog.V(6).Infof("manage.LeaveProject() LEAVE\n") - return &resp, nil + return &resp, err } diff --git a/pkg/api/manage/v1/keys.go b/pkg/api/manage/v1/keys.go index 75375890..1e93fd06 100644 --- a/pkg/api/manage/v1/keys.go +++ b/pkg/api/manage/v1/keys.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -15,135 +15,55 @@ import ( "bytes" "context" "encoding/json" - "net/http" "time" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/manage/v1/interfaces" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) // ListKeys lists all keys for a project -func (c *ManageClient) ListKeys(ctx context.Context, projectId string) (*api.KeysResult, error) { +func (c *Client) ListKeys(ctx context.Context, projectID string) (*api.KeysResult, error) { klog.V(6).Infof("manage.ListKeys() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.KeysURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListKeys() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListKeys() LEAVE\n") - return nil, err - } - - // Do it! var resp api.KeysResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.KeysURI, nil, &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.ListKeys() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.ListKeys() LEAVE\n") - return nil, err + klog.V(1).Infof("ListKeys failed. Err: %v\n", err) + } else { + klog.V(3).Infof("ListKeys Succeeded\n") } - klog.V(3).Infof("ListKeys Succeeded\n") klog.V(6).Infof("manage.ListKeys() LEAVE\n") return &resp, nil } // GetKey gets a key for a project -func (c *ManageClient) GetKey(ctx context.Context, projectId string, keyId string) (*api.KeyResult, error) { +func (c *Client) GetKey(ctx context.Context, projectID, keyID string) (*api.KeyResult, error) { klog.V(6).Infof("manage.GetKey() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.KeysByIdURI, nil, projectId, keyId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetKey() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetKey() LEAVE\n") - return nil, err - } - - // Do it! var resp api.KeyResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.KeysByIDURI, nil, &resp, projectID, keyID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.GetKey() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.GetKey() LEAVE\n") - return nil, err + klog.V(1).Infof("GetKey failed. Err: %v\n", err) + } else { + klog.V(3).Infof("GetKey Succeeded\n") } - klog.V(3).Infof("GetKey Succeeded\n") klog.V(6).Infof("manage.GetKey() LEAVE\n") return &resp, nil } // CreateKey creates a key for a project -func (c *ManageClient) CreateKey(ctx context.Context, projectId string, key *api.KeyCreateRequest) (*api.APIKey, error) { +func (c *Client) CreateKey(ctx context.Context, projectID string, key *api.KeyCreateRequest) (*api.APIKey, error) { klog.V(6).Infof("manage.CreateKey() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - var expirationStr string if !key.ExpirationDate.IsZero() { expirationStr = key.ExpirationDate.Format(time.RFC3339) } - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.KeysURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.CreateKey() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - type InternalKeyCreateRequest struct { Comment string `json:"comment"` Scopes []string `json:"scopes"` @@ -166,80 +86,30 @@ func (c *ManageClient) CreateKey(ctx context.Context, projectId string, key *api return nil, err } - req, err := http.NewRequestWithContext(ctx, "POST", URI, bytes.NewBuffer(jsonStr)) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.CreateKey() LEAVE\n") - return nil, err - } - - // Do it! var resp api.APIKey - err = c.Client.Do(ctx, req, &resp) - + err = c.apiRequest(ctx, "POST", version.KeysURI, bytes.NewBuffer(jsonStr), &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.CreateKey() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.CreateKey() LEAVE\n") - return nil, err + klog.V(1).Infof("CreateKey failed. Err: %v\n", err) + } else { + klog.V(3).Infof("CreateKey Succeeded\n") } - klog.V(3).Infof("CreateKey Succeeded\n") klog.V(6).Infof("manage.CreateKey() LEAVE\n") return &resp, nil } // DeleteKey deletes a key for a project -func (c *ManageClient) DeleteKey(ctx context.Context, projectId string, keyId string) (*api.MessageResult, error) { +func (c *Client) DeleteKey(ctx context.Context, projectID, keyID string) (*api.MessageResult, error) { klog.V(6).Infof("manage.DeleteKey() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.KeysByIdURI, nil, projectId, keyId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.DeleteKey() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "DELETE", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.DeleteKey() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "DELETE", version.KeysByIDURI, nil, &resp, projectID, keyID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.DeleteKey() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.DeleteKey() LEAVE\n") - return nil, err + klog.V(1).Infof("DeleteKey failed. Err: %v\n", err) + } else { + klog.V(3).Infof("DeleteKey Succeeded\n") } - klog.V(3).Infof("DeleteKey Succeeded\n") klog.V(6).Infof("manage.DeleteKey() LEAVE\n") return &resp, nil } diff --git a/pkg/api/manage/v1/manage.go b/pkg/api/manage/v1/manage.go index 2cb604ae..beae0c2f 100644 --- a/pkg/api/manage/v1/manage.go +++ b/pkg/api/manage/v1/manage.go @@ -8,15 +8,56 @@ This package contains the code for the Keys APIs in the Deepgram Manage API package manage import ( - client "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" + "context" + "io" + + klog "k8s.io/klog/v2" + + version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" + common "github.com/deepgram/deepgram-go-sdk/pkg/client/common" + rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" ) -// ManageClient is the client for the Deepgram Manage API -type ManageClient struct { - *client.Client +// Client is the client for the Deepgram Manage API +type Client struct { + *common.Client +} + +// New creates a new Client +func New(client *rest.Client) *Client { + return &Client{ + Client: &common.Client{ + Client: client, + }, + } } -// New creates a new ManageClient -func New(client *client.Client) *ManageClient { - return &ManageClient{client} +func (c *Client) apiRequest(ctx context.Context, method, apiPath string, body io.Reader, resBody interface{}, params ...interface{}) error { + klog.V(6).Infof("manage.%s() ENTER\n", method+apiPath) // Dynamic entry log based on method and path + + // Construct the uri with parameters + uri, err := version.GetManageAPI(ctx, c.Options.Host, c.Options.APIVersion, apiPath, nil, params...) + if err != nil { + klog.V(1).Infof("GetManageAPI failed. Err: %v\n", err) + klog.V(6).Infof("manage.%s() LEAVE\n", method+apiPath) + return err + } + + // Setup the HTTP request + req, err := c.Client.SetupRequest(ctx, method, uri, body) + if err != nil { + klog.V(6).Infof("manage.%s() LEAVE\n", method+apiPath) + return err + } + + // Execute the request + err = c.Client.Do(ctx, req, &resBody) + if err != nil { + klog.V(6).Infof("manage.%s() LEAVE\n", method+apiPath) + return err + } + + klog.V(3).Infof("%s succeeded\n", method+apiPath) + klog.V(6).Infof("manage.%s() LEAVE\n", method+apiPath) + return nil } diff --git a/pkg/api/manage/v1/members.go b/pkg/api/manage/v1/members.go index 15cf7def..8af368e5 100644 --- a/pkg/api/manage/v1/members.go +++ b/pkg/api/manage/v1/members.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -11,107 +11,41 @@ package manage import ( "context" - "net/http" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/manage/v1/interfaces" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) // ListMembers lists all members for a project -func (c *ManageClient) ListMembers(ctx context.Context, projectId string) (*api.MembersResult, error) { +func (c *Client) ListMembers(ctx context.Context, projectID string) (*api.MembersResult, error) { klog.V(6).Infof("manage.ListMembers() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.MembersURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListMembers() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListMembers() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MembersResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.MembersURI, nil, &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.ListMembers() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.ListMembers() LEAVE\n") - return nil, err + klog.V(1).Infof("ListMembers failed. Err: %v\n", err) + } else { + klog.V(3).Infof("ListMembers Succeeded\n") } - klog.V(3).Infof("ListMembers Succeeded\n") klog.V(6).Infof("manage.ListMembers() LEAVE\n") return &resp, nil } // RemoveMember removes a member from a project -func (c *ManageClient) RemoveMember(ctx context.Context, projectId string, memberId string) (*api.MessageResult, error) { +func (c *Client) RemoveMember(ctx context.Context, projectID, memberID string) (*api.MessageResult, error) { klog.V(6).Infof("manage.RemoveMember() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.MembersByIdURI, nil, projectId, memberId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.RemoveMember() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "DELETE", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.RemoveMember() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "DELETE", version.MembersByIDURI, nil, &resp, projectID, memberID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.RemoveMember() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.RemoveMember() LEAVE\n") - return nil, err + klog.V(1).Infof("RemoveMember failed. Err: %v\n", err) + } else { + klog.V(3).Infof("RemoveMember Succeeded\n") } - klog.V(3).Infof("RemoveMember Succeeded\n") klog.V(6).Infof("manage.RemoveMember() LEAVE\n") return &resp, nil } diff --git a/pkg/api/manage/v1/projects.go b/pkg/api/manage/v1/projects.go index 7a69811c..c46acfe4 100644 --- a/pkg/api/manage/v1/projects.go +++ b/pkg/api/manage/v1/projects.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -15,210 +15,79 @@ import ( "bytes" "context" "encoding/json" - "net/http" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/manage/v1/interfaces" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) // ListProjects lists all projects for a user -func (c *ManageClient) ListProjects(ctx context.Context) (*api.ProjectsResult, error) { +func (c *Client) ListProjects(ctx context.Context) (*api.ProjectsResult, error) { klog.V(6).Infof("manage.ListProjects() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.ProjectsURI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListProjects() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListProjects() LEAVE\n") - return nil, err - } - - // Do it! var resp api.ProjectsResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.ProjectsURI, nil, &resp) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.ListProjects() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.ListProjects() LEAVE\n") - return nil, err + klog.V(1).Infof("ListProjects failed. Err: %v\n", err) + } else { + klog.V(3).Infof("ListProjects Succeeded\n") } - klog.V(3).Infof("ListProjects Succeeded\n") klog.V(6).Infof("manage.ListProjects() LEAVE\n") return &resp, nil } // GetProject gets a project by ID -func (c *ManageClient) GetProject(ctx context.Context, projectId string) (*api.ProjectResult, error) { +func (c *Client) GetProject(ctx context.Context, projectID string) (*api.ProjectResult, error) { klog.V(6).Infof("manage.GetProject() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.ProjectsByIdURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetProject() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetProject() LEAVE\n") - return nil, err - } - - // Do it! var resp api.ProjectResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.ProjectsByIDURI, nil, &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.GetProject() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.GetProject() LEAVE\n") - return nil, err + klog.V(1).Infof("GetProject failed. Err: %v\n", err) + } else { + klog.V(3).Infof("GetProject Succeeded\n") } - klog.V(3).Infof("GetProject Succeeded\n") klog.V(6).Infof("manage.GetProject() LEAVE\n") return &resp, nil } // UpdateProject updates a project -func (c *ManageClient) UpdateProject(ctx context.Context, projectId string, proj *api.ProjectUpdateRequest) (*api.MessageResult, error) { +func (c *Client) UpdateProject(ctx context.Context, projectID string, proj *api.ProjectUpdateRequest) (*api.MessageResult, error) { klog.V(6).Infof("manage.UpdateProject() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.ProjectsByIdURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.UpdateProject() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - jsonStr, err := json.Marshal(proj) if err != nil { klog.V(1).Infof("json.Marshal failed. Err: %v\n", err) - klog.V(6).Infof("manage.UpdateProject() LEAVE\n") return nil, err } - req, err := http.NewRequestWithContext(ctx, "PATCH", URI, bytes.NewBuffer(jsonStr)) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.UpdateProject() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err = c.apiRequest(ctx, "PATCH", version.ProjectsByIDURI, bytes.NewBuffer(jsonStr), &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.UpdateProject() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.UpdateProject() LEAVE\n") - return nil, err + klog.V(1).Infof("UpdateProject failed. Err: %v\n", err) + } else { + klog.V(3).Infof("UpdateProject Succeeded\n") } - klog.V(3).Infof("UpdateProject Succeeded\n") klog.V(6).Infof("manage.UpdateProject() LEAVE\n") return &resp, nil } // DeleteProject deletes a project -func (c *ManageClient) DeleteProject(ctx context.Context, projectId string) (*api.MessageResult, error) { +func (c *Client) DeleteProject(ctx context.Context, projectID string) (*api.MessageResult, error) { klog.V(6).Infof("manage.DeleteProject() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.ProjectsByIdURI, nil, projectId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.DeleteProject() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "DELETE", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.DeleteProject() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "DELETE", version.InvitationsByIDURI, nil, &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.DeleteProject() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.DeleteProject() LEAVE\n") - return nil, err + klog.V(1).Infof("DeleteProject failed. Err: %v\n", err) + } else { + klog.V(3).Infof("DeleteProject Succeeded\n") } - klog.V(3).Infof("DeleteProject Succeeded\n") klog.V(6).Infof("manage.DeleteProject() LEAVE\n") return &resp, nil } diff --git a/pkg/api/manage/v1/scopes.go b/pkg/api/manage/v1/scopes.go index eead3af3..0db8d540 100644 --- a/pkg/api/manage/v1/scopes.go +++ b/pkg/api/manage/v1/scopes.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -13,114 +13,47 @@ import ( "bytes" "context" "encoding/json" - "net/http" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/manage/v1/interfaces" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) // GetMemberScopes gets the scopes for a member -func (c *ManageClient) GetMemberScopes(ctx context.Context, projectId string, memberId string) (*api.ScopeResult, error) { +func (c *Client) GetMemberScopes(ctx context.Context, projectID, memberID string) (*api.ScopeResult, error) { klog.V(6).Infof("manage.GetMemberScopes() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.MembersScopeByIdURI, nil, projectId, memberId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetMemberScopes() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetMemberScopes() LEAVE\n") - return nil, err - } - - // Do it! var resp api.ScopeResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.MembersScopeByIDURI, nil, &resp, projectID, memberID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.GetMemberScopes() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.GetMemberScopes() LEAVE\n") - return nil, err + klog.V(1).Infof("GetMemberScopes failed. Err: %v\n", err) + } else { + klog.V(3).Infof("GetMemberScopes Succeeded\n") } - klog.V(3).Infof("GetMemberScopes Succeeded\n") klog.V(6).Infof("manage.GetMemberScopes() LEAVE\n") return &resp, nil } // UpdateMemberScopes updates the scopes for a member -func (c *ManageClient) UpdateMemberScopes(ctx context.Context, projectId string, memberId string, scope *api.ScopeUpdateRequest) (*api.MessageResult, error) { +func (c *Client) UpdateMemberScopes(ctx context.Context, projectID, memberID string, scope *api.ScopeUpdateRequest) (*api.MessageResult, error) { klog.V(6).Infof("manage.UpdateMemberScopes() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.MembersScopeByIdURI, nil, projectId, memberId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.UpdateMemberScopes() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - jsonStr, err := json.Marshal(scope) if err != nil { klog.V(1).Infof("json.Marshal failed. Err: %v\n", err) - klog.V(6).Infof("manage.UpdateMemberScopes() LEAVE\n") return nil, err } - req, err := http.NewRequestWithContext(ctx, "PUT", URI, bytes.NewBuffer(jsonStr)) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.UpdateMemberScopes() LEAVE\n") - return nil, err - } - - // Do it! var resp api.MessageResult - err = c.Client.Do(ctx, req, &resp) - + err = c.apiRequest(ctx, "PUT", version.MembersScopeByIDURI, bytes.NewBuffer(jsonStr), &resp, projectID, memberID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.UpdateMemberScopes() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.UpdateMemberScopes() LEAVE\n") - return nil, err + klog.V(1).Infof("UpdateMemberScopes failed. Err: %v\n", err) + } else { + klog.V(3).Infof("UpdateMemberScopes Succeeded\n") } - klog.V(3).Infof("UpdateMemberScopes Succeeded\n") klog.V(6).Infof("manage.UpdateMemberScopes() LEAVE\n") return &resp, nil } diff --git a/pkg/api/manage/v1/usage.go b/pkg/api/manage/v1/usage.go index 8e5331ab..6d404c07 100644 --- a/pkg/api/manage/v1/usage.go +++ b/pkg/api/manage/v1/usage.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -12,204 +12,94 @@ https://developers.deepgram.com/reference/get-fields package manage import ( + "bytes" "context" - "net/http" + "encoding/json" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/manage/v1/interfaces" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) // ListRequests lists all requests for a project -func (c *ManageClient) ListRequests(ctx context.Context, projectId string, use *api.UsageListRequest) (*api.UsageListResult, error) { +func (c *Client) ListRequests(ctx context.Context, projectID string, use *api.UsageListRequest) (*api.UsageListResult, error) { klog.V(6).Infof("manage.ListRequests() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.UsageRequestURI, use, projectId) + jsonStr, err := json.Marshal(use) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListRequests() LEAVE\n") + klog.V(1).Infof("json.Marshal failed. Err: %v\n", err) return nil, err } - klog.V(4).Infof("Calling %s\n", URI) - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.ListRequests() LEAVE\n") - return nil, err - } - - // Do it! var resp api.UsageListResult - err = c.Client.Do(ctx, req, &resp) - + err = c.apiRequest(ctx, "GET", version.UsageRequestURI, bytes.NewBuffer(jsonStr), &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.ListRequests() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.ListRequests() LEAVE\n") - return nil, err + klog.V(1).Infof("ListRequests failed. Err: %v\n", err) + } else { + klog.V(3).Infof("ListRequests Succeeded\n") } - klog.V(3).Infof("ListRequests Succeeded\n") klog.V(6).Infof("manage.ListRequests() LEAVE\n") return &resp, nil } // GetRequest gets a request by ID -func (c *ManageClient) GetRequest(ctx context.Context, projectId string, requestId string) (*api.UsageRequestResult, error) { +func (c *Client) GetRequest(ctx context.Context, projectID, requestID string) (*api.UsageRequestResult, error) { klog.V(6).Infof("manage.GetRequest() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.UsageRequestByIdURI, nil, projectId, requestId) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetRequest() LEAVE\n") - return nil, err - } - klog.V(4).Infof("Calling %s\n", URI) - - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetRequest() LEAVE\n") - return nil, err - } - - // Do it! var resp api.UsageRequestResult - err = c.Client.Do(ctx, req, &resp) - + err := c.apiRequest(ctx, "GET", version.UsageRequestByIDURI, nil, &resp, projectID, requestID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.GetRequest() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.GetRequest() LEAVE\n") - return nil, err + klog.V(1).Infof("GetRequest failed. Err: %v\n", err) + } else { + klog.V(3).Infof("GetRequest Succeeded\n") } - klog.V(3).Infof("GetRequest Succeeded\n") klog.V(6).Infof("manage.GetRequest() LEAVE\n") return &resp, nil } // GetFields gets a list of fields for a project -func (c *ManageClient) GetFields(ctx context.Context, projectId string, use *api.UsageListRequest) (*api.UsageFieldResult, error) { +func (c *Client) GetFields(ctx context.Context, projectID string, use *api.UsageListRequest) (*api.UsageFieldResult, error) { klog.V(6).Infof("manage.GetFields() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.UsageFieldsURI, use, projectId) + jsonStr, err := json.Marshal(use) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetFields() LEAVE\n") + klog.V(1).Infof("json.Marshal failed. Err: %v\n", err) return nil, err } - klog.V(4).Infof("Calling %s\n", URI) - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetFields() LEAVE\n") - return nil, err - } - - // Do it! var resp api.UsageFieldResult - err = c.Client.Do(ctx, req, &resp) - + err = c.apiRequest(ctx, "GET", version.UsageFieldsURI, bytes.NewBuffer(jsonStr), &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.GetFields() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.GetFields() LEAVE\n") - return nil, err + klog.V(1).Infof("GetFields failed. Err: %v\n", err) + } else { + klog.V(3).Infof("GetFields Succeeded\n") } - klog.V(3).Infof("GetFields Succeeded\n") klog.V(6).Infof("manage.GetFields() LEAVE\n") return &resp, nil } // GetUsage gets a usage by ID -func (c *ManageClient) GetUsage(ctx context.Context, projectId string, use *api.UsageRequest) (*api.UsageResult, error) { +func (c *Client) GetUsage(ctx context.Context, projectID string, use *api.UsageRequest) (*api.UsageResult, error) { klog.V(6).Infof("manage.GetUsage() ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } - - // request - URI, err := version.GetManageAPI(ctx, c.Client.Options.Host, c.Client.Options.ApiVersion, version.UsageURI, use, projectId) + jsonStr, err := json.Marshal(use) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetUsage() LEAVE\n") + klog.V(1).Infof("json.Marshal failed. Err: %v\n", err) return nil, err } - klog.V(4).Infof("Calling %s\n", URI) - req, err := http.NewRequestWithContext(ctx, "GET", URI, nil) - if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("manage.GetUsage() LEAVE\n") - return nil, err - } - - // Do it! var resp api.UsageResult - err = c.Client.Do(ctx, req, &resp) - + err = c.apiRequest(ctx, "GET", version.UsageURI, bytes.NewBuffer(jsonStr), &resp, projectID) if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("manage.GetUsage() LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("manage.GetUsage() LEAVE\n") - return nil, err + klog.V(1).Infof("GetUsage failed. Err: %v\n", err) + } else { + klog.V(3).Infof("GetUsage Succeeded\n") } - klog.V(3).Infof("GetUsage Succeeded\n") klog.V(6).Infof("manage.GetUsage() LEAVE\n") return &resp, nil } diff --git a/pkg/api/prerecorded/v1/constants.go b/pkg/api/prerecorded/v1/constants.go index 4e78d934..381139d0 100644 --- a/pkg/api/prerecorded/v1/constants.go +++ b/pkg/api/prerecorded/v1/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/prerecorded/v1/interfaces/prerecorded.go b/pkg/api/prerecorded/v1/interfaces/prerecorded.go index c139aea4..d87dfa77 100644 --- a/pkg/api/prerecorded/v1/interfaces/prerecorded.go +++ b/pkg/api/prerecorded/v1/interfaces/prerecorded.go @@ -1,6 +1,6 @@ -// // Copyright 2023 Deepgram SDK contributors. All Rights Reserved. -// // Use of this source code is governed by a MIT license that can be found in the LICENSE file. -// // SPDX-License-Identifier: MIT +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT /* This package provides the types for the Deepgram PreRecorded API. @@ -8,10 +8,8 @@ This package provides the types for the Deepgram PreRecorded API. package interfaces import ( - "encoding/json" "errors" "fmt" - "net/http" "strings" ) @@ -47,7 +45,6 @@ func (resp *PreRecordedResponse) ToSRT() (string, error) { end := SecondsToTimestamp(utterance.End) end = strings.ReplaceAll(end, ".", ",") srt += fmt.Sprintf("%d\n%s --> %s\n%s\n\n", i+1, start, end, utterance.Transcript) - } return srt, nil } @@ -58,9 +55,3 @@ func SecondsToTimestamp(seconds float64) string { seconds = seconds - float64(hours*3600) - float64(minutes*60) return fmt.Sprintf("%02d:%02d:%02.3f", hours, minutes, seconds) } - -func GetJson(resp *http.Response, target interface{}) error { - defer resp.Body.Close() - - return json.NewDecoder(resp.Body).Decode(target) -} diff --git a/pkg/api/prerecorded/v1/interfaces/types.go b/pkg/api/prerecorded/v1/interfaces/types.go index 3f538ba8..2a0d2e5d 100644 --- a/pkg/api/prerecorded/v1/interfaces/types.go +++ b/pkg/api/prerecorded/v1/interfaces/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/api/prerecorded/v1/prerecorded.go b/pkg/api/prerecorded/v1/prerecorded.go index 2c7e9223..72184e59 100644 --- a/pkg/api/prerecorded/v1/prerecorded.go +++ b/pkg/api/prerecorded/v1/prerecorded.go @@ -8,126 +8,82 @@ package prerecorded import ( "context" "io" - "net/http" klog "k8s.io/klog/v2" api "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1/interfaces" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded" + prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded" ) -type PrerecordedClient struct { - *client.Client +type Client struct { + *prerecorded.Client } -func New(client *client.Client) *PrerecordedClient { - return &PrerecordedClient{client} +// New creates a new Client +func New(client *prerecorded.Client) *Client { + return &Client{client} } -func (c *PrerecordedClient) FromFile(ctx context.Context, file string, options interfaces.PreRecordedTranscriptionOptions) (*api.PreRecordedResponse, error) { - klog.V(6).Infof("FromFile ENTER\n") - klog.V(3).Infof("filePath: %s\n", file) - - // checks - if ctx == nil { - ctx = context.Background() - } - err := options.Check() - if err != nil { - klog.V(1).Infof("TranscribeOptions.Check() failed. Err: %v\n", err) - return nil, err - } - - // send the file! - var resp api.PreRecordedResponse - err = c.Client.DoFile(ctx, file, options, &resp) - if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("prerecorded.FromFile ENTER\n") - return nil, err - } - } +// FromFile transcribes a prerecorded audio file from a file +func (c *Client) FromFile(ctx context.Context, file string, options *interfaces.PreRecordedTranscriptionOptions) (*api.PreRecordedResponse, error) { + return c.sendAudio(ctx, func(ctx context.Context, opts *interfaces.PreRecordedTranscriptionOptions, resp interface{}) error { + return c.sendFile(ctx, file, opts, resp) + }, options) +} - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("prerecorded.FromFile ENTER\n") - return nil, err - } +// FromStream transcribes a prerecorded audio file from a stream +func (c *Client) FromStream(ctx context.Context, src io.Reader, options *interfaces.PreRecordedTranscriptionOptions) (*api.PreRecordedResponse, error) { + return c.sendAudio(ctx, func(ctx context.Context, opts *interfaces.PreRecordedTranscriptionOptions, resp interface{}) error { + return c.sendStream(ctx, src, opts, resp) + }, options) +} - klog.V(3).Infof("FromFile Succeeded\n") - klog.V(6).Infof("prerecorded.FromFile ENTER\n") - return &resp, nil +// FromURL transcribes a prerecorded audio file from a URL +func (c *Client) FromURL(ctx context.Context, url string, options *interfaces.PreRecordedTranscriptionOptions) (*api.PreRecordedResponse, error) { + return c.sendAudio(ctx, func(ctx context.Context, opts *interfaces.PreRecordedTranscriptionOptions, resp interface{}) error { + return c.sendURL(ctx, url, opts, resp) + }, options) } -func (c *PrerecordedClient) FromStream(ctx context.Context, src io.Reader, options interfaces.PreRecordedTranscriptionOptions) (*api.PreRecordedResponse, error) { - klog.V(6).Infof("prerecorded.FromStream ENTER\n") +// private functions +type sendFunc func(ctx context.Context, options *interfaces.PreRecordedTranscriptionOptions, resp interface{}) error - // checks - if ctx == nil { - ctx = context.Background() - } - err := options.Check() - if err != nil { - klog.V(1).Infof("TranscribeOptions.Check() failed. Err: %v\n", err) - return nil, err - } - - // send the file! - var resp api.PreRecordedResponse - err = c.Client.DoStream(ctx, src, options, &resp) - if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("prerecorded.FromStream LEAVE\n") - return nil, err - } - } +func (c *Client) sendFile(ctx context.Context, filePath string, options *interfaces.PreRecordedTranscriptionOptions, resp interface{}) error { + return c.Client.DoFile(ctx, filePath, options, resp) +} - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("prerecorded.FromStream LEAVE\n") - return nil, err - } +func (c *Client) sendStream(ctx context.Context, src io.Reader, options *interfaces.PreRecordedTranscriptionOptions, resp interface{}) error { + return c.Client.DoStream(ctx, src, options, resp) +} - klog.V(3).Infof("FromStream Succeeded\n") - klog.V(6).Infof("prerecorded.FromStream LEAVE\n") - return &resp, nil +func (c *Client) sendURL(ctx context.Context, url string, options *interfaces.PreRecordedTranscriptionOptions, resp interface{}) error { + return c.Client.DoURL(ctx, url, options, resp) } -func (c *PrerecordedClient) FromURL(ctx context.Context, url string, options interfaces.PreRecordedTranscriptionOptions) (*api.PreRecordedResponse, error) { - klog.V(6).Infof("prerecorded.FromURL ENTER\n") +func (c *Client) sendAudio(ctx context.Context, sender sendFunc, options *interfaces.PreRecordedTranscriptionOptions) (*api.PreRecordedResponse, error) { + klog.V(6).Infof("analyze.sendAudio ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } err := options.Check() if err != nil { - klog.V(1).Infof("TranscribeOptions.Check() failed. Err: %v\n", err) + klog.V(1).Infof("PreRecordedTranscriptionOptions.Check() failed. Err: %v\n", err) + klog.V(6).Infof("prerecorded.sendAudio LEAVE\n") return nil, err } - // send the file! var resp api.PreRecordedResponse - err = c.Client.DoURL(ctx, url, options, &resp) + + err = sender(ctx, options, &resp) if err != nil { if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("prerecorded.FromURL LEAVE\n") - return nil, err - } + klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) } - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("prerecorded.FromURL LEAVE\n") + klog.V(6).Infof("prerecorded.sendAudio LEAVE\n") return nil, err } - klog.V(3).Infof("FromURL Succeeded\n") - klog.V(6).Infof("prerecorded.FromURL LEAVE\n") - + klog.V(3).Infof("sendAudio Succeeded\n") + klog.V(6).Infof("prerecorded.sendAudio LEAVE\n") return &resp, nil } diff --git a/pkg/api/speak/v1/interfaces/types.go b/pkg/api/speak/v1/interfaces/types.go index c7ecc056..8dd993f6 100644 --- a/pkg/api/speak/v1/interfaces/types.go +++ b/pkg/api/speak/v1/interfaces/types.go @@ -18,8 +18,8 @@ type SpeakOptions interfaces.SpeakOptions /***********************************/ type SpeakResponse struct { ContextType string `json:"content_type,omitempty"` - RequestId string `json:"request_id,omitempty"` - ModelUuid string `json:"model_uuid,omitempty"` + RequestID string `json:"request_id,omitempty"` + ModelUUID string `json:"model_uuid,omitempty"` Characters int `json:"characters,omitempty"` ModelName string `json:"model_name,omitempty"` TransferEncoding string `json:"transfer_encoding,omitempty"` diff --git a/pkg/api/speak/v1/speak.go b/pkg/api/speak/v1/speak.go index 82769c22..7234ef18 100644 --- a/pkg/api/speak/v1/speak.go +++ b/pkg/api/speak/v1/speak.go @@ -7,8 +7,8 @@ package speak import ( "context" + "fmt" "io" - "net/http" "os" "strconv" @@ -16,143 +16,80 @@ import ( api "github.com/deepgram/deepgram-go-sdk/pkg/api/speak/v1/interfaces" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - client "github.com/deepgram/deepgram-go-sdk/pkg/client/speak" + speak "github.com/deepgram/deepgram-go-sdk/pkg/client/speak" ) -type SpeakClient struct { - *client.Client +type Client struct { + *speak.Client } -func New(client *client.Client) *SpeakClient { - return &SpeakClient{client} +func New(client *speak.Client) *Client { + return &Client{client} } -func (c *SpeakClient) ToStream(ctx context.Context, text string, options interfaces.SpeakOptions, buf *interfaces.RawResponse) (*api.SpeakResponse, error) { +// ToStream TTS streamed to a buffer +func (c *Client) ToStream(ctx context.Context, text string, options *interfaces.SpeakOptions, buf *interfaces.RawResponse) (*api.SpeakResponse, error) { klog.V(6).Infof("speak.ToStream ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } + keys := initializeKeys() + err := options.Check() if err != nil { klog.V(1).Infof("SpeakOptions.Check() failed. Err: %v\n", err) + klog.V(6).Infof("speak.ToStream LEAVE\n") return nil, err } - // send the file! - retVal := make(map[string]string) - retVal["content-type"] = "" - retVal["request-id"] = "" - retVal["model-uuid"] = "" - retVal["model-name"] = "" - retVal["char-count"] = "" - retVal["transfer-encoding"] = "" - retVal["date"] = "" - - err = c.Client.DoText(ctx, text, options, &retVal, buf) - if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("speak.ToStream LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("speak.ToStream LEAVE\n") - return nil, err + action := func() (map[string]string, error) { + return c.Client.DoText(ctx, text, options, keys, buf) } - charCnt, err := strconv.Atoi(retVal["char-count"]) + result, err := c.performAction(action) if err != nil { - klog.V(1).Infof("strconv.Atoi failed. Err: %v\n", err) - klog.V(6).Infof("speak.ToStream LEAVE\n") - return nil, err + klog.V(1).Infof("performAction failed. Err: %v\n", err) + } else { + klog.V(3).Infof("Transcription successful\n") } - - var result api.SpeakResponse - result.ContextType = retVal["content-type"] - result.RequestId = retVal["request-id"] - result.ModelUuid = retVal["model-uuid"] - result.ModelName = retVal["model-name"] - result.Characters = charCnt - result.TransferEncoding = retVal["transfer-encoding"] - result.Date = retVal["date"] - - klog.V(3).Infof("ToStream Succeeded\n") klog.V(6).Infof("speak.ToStream LEAVE\n") - return &result, nil + return result, err } -func (c *SpeakClient) ToFile(ctx context.Context, text string, options interfaces.SpeakOptions, w io.Writer) (*api.SpeakResponse, error) { +// ToFile TTS saved to a file +func (c *Client) ToFile(ctx context.Context, text string, options *interfaces.SpeakOptions, w io.Writer) (*api.SpeakResponse, error) { klog.V(6).Infof("speak.ToFile ENTER\n") - // checks - if ctx == nil { - ctx = context.Background() - } + keys := initializeKeys() + err := options.Check() if err != nil { klog.V(1).Infof("SpeakOptions.Check() failed. Err: %v\n", err) + klog.V(6).Infof("speak.ToFile LEAVE\n") return nil, err } - // send the file! - retVal := make(map[string]string) - retVal["content-type"] = "" - retVal["request-id"] = "" - retVal["model-uuid"] = "" - retVal["model-name"] = "" - retVal["char-count"] = "" - retVal["transfer-encoding"] = "" - retVal["date"] = "" - - err = c.Client.DoText(ctx, text, options, &retVal, w) - if err != nil { - if e, ok := err.(*interfaces.StatusError); ok { - if e.Resp.StatusCode != http.StatusOK { - klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) - klog.V(6).Infof("speak.ToFile LEAVE\n") - return nil, err - } - } - - klog.V(1).Infof("Platform Supplied Err: %v\n", err) - klog.V(6).Infof("speak.ToFile LEAVE\n") - return nil, err + action := func() (map[string]string, error) { + return c.Client.DoText(ctx, text, options, keys, w) } - charCnt, err := strconv.Atoi(retVal["char-count"]) + result, err := c.performAction(action) if err != nil { - klog.V(1).Infof("strconv.Atoi failed. Err: %v\n", err) - klog.V(6).Infof("speak.ToFile LEAVE\n") - return nil, err + klog.V(1).Infof("performAction failed. Err: %v\n", err) + } else { + klog.V(3).Infof("Transcription successful\n") } - - var result api.SpeakResponse - result.ContextType = retVal["content-type"] - result.RequestId = retVal["request-id"] - result.ModelUuid = retVal["model-uuid"] - result.ModelName = retVal["model-name"] - result.Characters = charCnt - result.TransferEncoding = retVal["transfer-encoding"] - result.Date = retVal["date"] - - klog.V(3).Infof("ToFile Succeeded\n") klog.V(6).Infof("speak.ToFile LEAVE\n") - return &result, nil + return result, err } -func (c *SpeakClient) ToSave(ctx context.Context, filename string, text string, options interfaces.SpeakOptions) (*api.SpeakResponse, error) { +// ToSave TTS saved to a file +func (c *Client) ToSave(ctx context.Context, filename, text string, options *interfaces.SpeakOptions) (*api.SpeakResponse, error) { klog.V(6).Infof("speak.ToSave ENTER\n") - file, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0666) + file, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o666) if err != nil { - klog.V(1).Infof("os.Create failed. Err: %v\n", err) + klog.V(1).Infof("os.OpenFile failed. Err: %v\n", err) klog.V(6).Infof("speak.ToSave LEAVE\n") return nil, err } @@ -167,8 +104,52 @@ func (c *SpeakClient) ToSave(ctx context.Context, filename string, text string, result.Filename = filename - klog.V(3).Infof("ToSave Succeeded\n") + klog.V(3).Infof("Saved to file: %v\n", filename) klog.V(6).Infof("speak.ToSave LEAVE\n") return result, nil } + +// helper function +func initializeKeys() []string { + return []string{ + "content-type", + "request-id", + "model-uuid", + "model-name", + "char-count", + "transfer-encoding", + "date", + } +} + +// performAction performs the common actions of sending text to the Deepgram API and handling the response. +func (c *Client) performAction(action func() (map[string]string, error)) (*api.SpeakResponse, error) { + var resp api.SpeakResponse + retVal, err := action() + if err != nil { + if e, ok := err.(*interfaces.StatusError); ok { + klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) + return nil, err + } + klog.V(1).Infof("Platform Supplied Err: %v\n", err) + return nil, err + } + fmt.Printf("retVal: %v\n", retVal) + + charCnt, err := strconv.Atoi(retVal["char-count"]) + if err != nil { + klog.V(1).Infof("strconv.Atoi failed. Err: %v\n", err) + return nil, err + } + + resp.ContextType = retVal["content-type"] + resp.RequestID = retVal["request-id"] + resp.ModelUUID = retVal["model-uuid"] + resp.ModelName = retVal["model-name"] + resp.Characters = charCnt + resp.TransferEncoding = retVal["transfer-encoding"] + resp.Date = retVal["date"] + + return &resp, nil +} diff --git a/pkg/api/version/analyze-version.go b/pkg/api/version/analyze-version.go index e2501c20..a9acf9c9 100644 --- a/pkg/api/version/analyze-version.go +++ b/pkg/api/version/analyze-version.go @@ -6,24 +6,8 @@ package version import ( "context" - "fmt" - "net/url" - "regexp" - "strings" - - "github.com/google/go-querystring/query" - klog "k8s.io/klog/v2" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - common "github.com/deepgram/deepgram-go-sdk/pkg/common" -) - -const ( - // ReadAPIVersion current supported version - ReadAPIVersion string = "v1" - - // ReadPath is the current path for prerecorded transcription - ReadPath string = "read" ) /* @@ -37,75 +21,6 @@ mechanism for: The return value is the complete URL endpoint to be used for the live transcription */ -func GetAnalyzeAPI(ctx context.Context, host, version, path string, options interfaces.AnalyzeOptions, args ...interface{}) (string, error) { - if path == "" { - path = ReadPath - } - - // handle protocol and host - protocol := APIProtocol - if host == "" { - host = common.DefaultHost - } - - r, err := regexp.Compile("^(https|http)://(.+)$") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match := r.MatchString(host) - klog.V(3).Infof("host decompose... match: %t\n", match) - if match { - matches := r.FindStringSubmatch(host) - for _, match := range matches { - klog.V(5).Infof("match: %s\n", match) - } - protocol = matches[1] - host = matches[2] - - slash := strings.Index(host, "/") - if slash > 0 { - host = host[:slash] - } - } - klog.V(3).Infof("protocol: %s\n", protocol) - klog.V(3).Infof("host: %s\n", host) - - // handle version and path - if version == "" { - version = ReadAPIVersion - } - - r, err = regexp.Compile("^(v[0-9]+|%%s)/") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match = r.MatchString(path) - klog.V(3).Infof("path decompose - match: %t\n", match) - if match { - // version = r.FindStringSubmatch(path)[0] - path = r.ReplaceAllString(path, "") - } - - q, err := query.Values(options) - if err != nil { - return "", err - } - - if parameters, ok := ctx.Value(interfaces.ParametersContext{}).(map[string][]string); ok { - for k, vs := range parameters { - for _, v := range vs { - q.Add(k, v) - } - } - } - - fullpath := fmt.Sprintf("%%s/%s", path) - completeFullpath := fmt.Sprintf(fullpath, append([]interface{}{version}, args...)...) - u := url.URL{Scheme: protocol, Host: host, Path: completeFullpath, RawQuery: q.Encode()} - - return u.String(), nil +func GetAnalyzeAPI(ctx context.Context, host, version, path string, options *interfaces.AnalyzeOptions, args ...interface{}) (string, error) { + return getAPIURL(ctx, "analyze", host, version, path, options, args...) } diff --git a/pkg/api/version/constants.go b/pkg/api/version/constants.go index cfb6af83..3cf29177 100644 --- a/pkg/api/version/constants.go +++ b/pkg/api/version/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -9,13 +9,33 @@ import "errors" const ( // APIProtocol default protocol - APIProtocol string = "https" + HTTPProtocol string = "https" // WSProtocol default protocol WSProtocol string = "wss" + + // APIPathListen + APIPathListen string = "listen" + + // APITypeLive + APITypeLive string = "live" +) + +const ( + // DefaultAPIVersion is the current supported default version for APIs + DefaultAPIVersion string = "v1" ) var ( // ErrInvalidPath invalid path ErrInvalidPath = errors.New("invalid path") + + // APIPathMap maps the API types to their default paths + APIPathMap = map[string]string{ + "analyze": "read", + "prerecorded": APIPathListen, + "speak": "speak", + "manage": "", + "live": APIPathListen, + } ) diff --git a/pkg/api/version/live-version.go b/pkg/api/version/live-version.go index be4f30bf..2eb7a926 100644 --- a/pkg/api/version/live-version.go +++ b/pkg/api/version/live-version.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -6,16 +6,8 @@ package version import ( "context" - "fmt" - "net/url" - "regexp" - "strings" - - "github.com/google/go-querystring/query" - klog "k8s.io/klog/v2" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - common "github.com/deepgram/deepgram-go-sdk/pkg/common" ) const ( @@ -37,75 +29,6 @@ mechanism for: The return value is the complete URL endpoint to be used for the live transcription */ -func GetLiveAPI(ctx context.Context, host, version, path string, options interfaces.LiveTranscriptionOptions, args ...interface{}) (string, error) { - if path == "" { - path = LivePath - } - - // handle protocol and host - protocol := WSProtocol - if host == "" { - host = common.DefaultHost - } - - r, err := regexp.Compile("^(wss|ws)://(.+)$") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match := r.MatchString(host) - klog.V(3).Infof("host decompose... match: %t\n", match) - if match { - matches := r.FindStringSubmatch(host) - for _, match := range matches { - klog.V(5).Infof("match: %s\n", match) - } - protocol = matches[1] - host = matches[2] - - slash := strings.Index(host, "/") - if slash > 0 { - host = host[:slash] - } - } - klog.V(3).Infof("protocol: %s\n", protocol) - klog.V(3).Infof("host: %s\n", host) - - // handle version and path - if version == "" { - version = LiveAPIVersion - } - - r, err = regexp.Compile("^(v[0-9]+|%%s)/") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match = r.MatchString(path) - klog.V(3).Infof("path decompose - match: %t\n", match) - if match { - // version = r.FindStringSubmatch(path)[0] - path = r.ReplaceAllString(path, "") - } - - q, err := query.Values(options) - if err != nil { - return "", err - } - - if parameters, ok := ctx.Value(interfaces.ParametersContext{}).(map[string][]string); ok { - for k, vs := range parameters { - for _, v := range vs { - q.Add(k, v) - } - } - } - - fullpath := fmt.Sprintf("%%s/%s", path) - completeFullpath := fmt.Sprintf(fullpath, append([]interface{}{version}, args...)...) - u := url.URL{Scheme: protocol, Host: host, Path: completeFullpath, RawQuery: q.Encode()} - - return u.String(), nil +func GetLiveAPI(ctx context.Context, host, version, path string, options *interfaces.LiveTranscriptionOptions, args ...interface{}) (string, error) { + return getAPIURL(ctx, "live", host, version, path, options, args...) } diff --git a/pkg/api/version/manage-version.go b/pkg/api/version/manage-version.go index ba895747..cfe2d26d 100644 --- a/pkg/api/version/manage-version.go +++ b/pkg/api/version/manage-version.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -6,16 +6,6 @@ package version import ( "context" - "fmt" - "net/url" - "regexp" - "strings" - - klog "k8s.io/klog/v2" - - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - common "github.com/deepgram/deepgram-go-sdk/pkg/common" - "github.com/google/go-querystring/query" ) const ( @@ -24,31 +14,31 @@ const ( // balances BalancesURI string = "projects/%s/balances" - BalancesByIdURI string = "projects/%s/balances/%s" + BalancesByIDURI string = "projects/%s/balances/%s" // invitations InvitationsURI string = "projects/%s/invites" - InvitationsByIdURI string = "projects/%s/invites/%s" + InvitationsByIDURI string = "projects/%s/invites/%s" InvitationsLeaveURI string = "projects/%s/leave" // Keys KeysURI string = "projects/%s/keys" - KeysByIdURI string = "projects/%s/keys/%s" + KeysByIDURI string = "projects/%s/keys/%s" // Members MembersURI string = "projects/%s/members" - MembersByIdURI string = "projects/%s/members/%s" + MembersByIDURI string = "projects/%s/members/%s" // projects ProjectsURI string = "projects" - ProjectsByIdURI string = "projects/%s" + ProjectsByIDURI string = "projects/%s" // scopes - MembersScopeByIdURI string = "projects/%s/members/%s/scopes" + MembersScopeByIDURI string = "projects/%s/members/%s/scopes" // usage UsageRequestURI string = "projects/%s/requests" - UsageRequestByIdURI string = "projects/%s/requests/%s" + UsageRequestByIDURI string = "projects/%s/requests/%s" UsageURI string = "projects/%s/usage" UsageFieldsURI string = "projects/%s/usage/fields" ) @@ -65,87 +55,5 @@ mechanism for: The return value is the complete URL endpoint to be used for manage */ func GetManageAPI(ctx context.Context, host, version, path string, vals interface{}, args ...interface{}) (string, error) { - if path == "" { - return "", ErrInvalidPath - } - - // handle protocol and host - protocol := APIProtocol - if host == "" { - host = common.DefaultHost - } - - r, err := regexp.Compile("^(https|http)://(.+)$") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match := r.MatchString(host) - klog.V(3).Infof("host decompose... match: %t\n", match) - if match { - matches := r.FindStringSubmatch(host) - for _, match := range matches { - klog.V(5).Infof("match: %s\n", match) - } - protocol = matches[1] - host = matches[2] - - slash := strings.Index(host, "/") - if slash > 0 { - host = host[:slash] - } - } - klog.V(3).Infof("protocol: %s\n", protocol) - klog.V(3).Infof("host: %s\n", host) - - // handle version and path - if version == "" { - version = ManageAPIVersion - } - - r, err = regexp.Compile("^(v[0-9]+|%%s)/") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match = r.MatchString(path) - klog.V(3).Infof("match: %t\n", match) - - if match { - // version = r.FindStringSubmatch(path)[0] - path = r.ReplaceAllString(path, "") - } - - var q url.Values - if vals != nil { - q, err = query.Values(vals) - if err != nil { - return "", err - } - } - - if parameters, ok := ctx.Value(interfaces.ParametersContext{}).(map[string][]string); ok { - for k, vs := range parameters { - for _, v := range vs { - if q == nil { - q = url.Values{} - } - q.Add(k, v) - } - } - } - - fullpath := fmt.Sprintf("%%s/%s", path) - completeFullpath := fmt.Sprintf(fullpath, append([]interface{}{version}, args...)...) - - var u url.URL - if q != nil { - u = url.URL{Scheme: protocol, Host: host, Path: completeFullpath, RawQuery: q.Encode()} - } else { - u = url.URL{Scheme: protocol, Host: host, Path: completeFullpath} - } - - return u.String(), nil + return getAPIURL(ctx, "speak", host, version, path, nil, args...) } diff --git a/pkg/api/version/prerecorded-version.go b/pkg/api/version/prerecorded-version.go index 8d524090..12d1f825 100644 --- a/pkg/api/version/prerecorded-version.go +++ b/pkg/api/version/prerecorded-version.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -6,24 +6,8 @@ package version import ( "context" - "fmt" - "net/url" - "regexp" - "strings" - - "github.com/google/go-querystring/query" - klog "k8s.io/klog/v2" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - common "github.com/deepgram/deepgram-go-sdk/pkg/common" -) - -const ( - // PrerecordedAPIVersion current supported version - PrerecordedAPIVersion string = "v1" - - // PrerecordedPath is the current path for prerecorded transcription - PrerecordedPath string = "listen" ) /* @@ -37,75 +21,6 @@ mechanism for: The return value is the complete URL endpoint to be used for the live transcription */ -func GetPrerecordedAPI(ctx context.Context, host, version, path string, options interfaces.PreRecordedTranscriptionOptions, args ...interface{}) (string, error) { - if path == "" { - path = PrerecordedPath - } - - // handle protocol and host - protocol := APIProtocol - if host == "" { - host = common.DefaultHost - } - - r, err := regexp.Compile("^(https|http)://(.+)$") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match := r.MatchString(host) - klog.V(3).Infof("host decompose... match: %t\n", match) - if match { - matches := r.FindStringSubmatch(host) - for _, match := range matches { - klog.V(5).Infof("match: %s\n", match) - } - protocol = matches[1] - host = matches[2] - - slash := strings.Index(host, "/") - if slash > 0 { - host = host[:slash] - } - } - klog.V(3).Infof("protocol: %s\n", protocol) - klog.V(3).Infof("host: %s\n", host) - - // handle version and path - if version == "" { - version = PrerecordedAPIVersion - } - - r, err = regexp.Compile("^(v[0-9]+|%%s)/") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match = r.MatchString(path) - klog.V(3).Infof("path decompose - match: %t\n", match) - if match { - // version = r.FindStringSubmatch(path)[0] - path = r.ReplaceAllString(path, "") - } - - q, err := query.Values(options) - if err != nil { - return "", err - } - - if parameters, ok := ctx.Value(interfaces.ParametersContext{}).(map[string][]string); ok { - for k, vs := range parameters { - for _, v := range vs { - q.Add(k, v) - } - } - } - - fullpath := fmt.Sprintf("%%s/%s", path) - completeFullpath := fmt.Sprintf(fullpath, append([]interface{}{version}, args...)...) - u := url.URL{Scheme: protocol, Host: host, Path: completeFullpath, RawQuery: q.Encode()} - - return u.String(), nil +func GetPrerecordedAPI(ctx context.Context, host, version, path string, options *interfaces.PreRecordedTranscriptionOptions, args ...interface{}) (string, error) { + return getAPIURL(ctx, "prerecorded", host, version, path, options, args...) } diff --git a/pkg/api/version/speak-version.go b/pkg/api/version/speak-version.go index 0f4cda5c..cfcd7cad 100644 --- a/pkg/api/version/speak-version.go +++ b/pkg/api/version/speak-version.go @@ -6,24 +6,8 @@ package version import ( "context" - "fmt" - "net/url" - "regexp" - "strings" - - "github.com/google/go-querystring/query" - klog "k8s.io/klog/v2" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - common "github.com/deepgram/deepgram-go-sdk/pkg/common" -) - -const ( - // SpeakAPIVersion current supported version - SpeakAPIVersion string = "v1" - - // SpeakPath is the current path for prerecorded transcription - SpeakPath string = "speak" ) /* @@ -37,75 +21,6 @@ mechanism for: The return value is the complete URL endpoint to be used for the live transcription */ -func GetSpeakAPI(ctx context.Context, host, version, path string, options interfaces.SpeakOptions, args ...interface{}) (string, error) { - if path == "" { - path = SpeakPath - } - - // handle protocol and host - protocol := APIProtocol - if host == "" { - host = common.DefaultHost - } - - r, err := regexp.Compile("^(https|http)://(.+)$") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match := r.MatchString(host) - klog.V(3).Infof("host decompose... match: %t\n", match) - if match { - matches := r.FindStringSubmatch(host) - for _, match := range matches { - klog.V(5).Infof("match: %s\n", match) - } - protocol = matches[1] - host = matches[2] - - slash := strings.Index(host, "/") - if slash > 0 { - host = host[:slash] - } - } - klog.V(3).Infof("protocol: %s\n", protocol) - klog.V(3).Infof("host: %s\n", host) - - // handle version and path - if version == "" { - version = SpeakAPIVersion - } - - r, err = regexp.Compile("^(v[0-9]+|%%s)/") - if err != nil { - klog.V(1).Infof("regexp.Compile err: %v\n", err) - return "", err - } - - match = r.MatchString(path) - klog.V(3).Infof("path decompose - match: %t\n", match) - if match { - // version = r.FindStringSubmatch(path)[0] - path = r.ReplaceAllString(path, "") - } - - q, err := query.Values(options) - if err != nil { - return "", err - } - - if parameters, ok := ctx.Value(interfaces.ParametersContext{}).(map[string][]string); ok { - for k, vs := range parameters { - for _, v := range vs { - q.Add(k, v) - } - } - } - - fullpath := fmt.Sprintf("%%s/%s", path) - completeFullpath := fmt.Sprintf(fullpath, append([]interface{}{version}, args...)...) - u := url.URL{Scheme: protocol, Host: host, Path: completeFullpath, RawQuery: q.Encode()} - - return u.String(), nil +func GetSpeakAPI(ctx context.Context, host, version, path string, options *interfaces.SpeakOptions, args ...interface{}) (string, error) { + return getAPIURL(ctx, "speak", host, version, path, options, args...) } diff --git a/pkg/api/version/version.go b/pkg/api/version/version.go new file mode 100644 index 00000000..95dfa6df --- /dev/null +++ b/pkg/api/version/version.go @@ -0,0 +1,111 @@ +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +package version + +import ( + "context" + "fmt" + "net/url" + "regexp" + "strings" + + "github.com/gorilla/schema" + klog "k8s.io/klog/v2" + + interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" + common "github.com/deepgram/deepgram-go-sdk/pkg/common" +) + +// getAPIURL constructs the URL for API requests and handles versioning, path resolution, +// host overrides, and query string parameters. +func getAPIURL(ctx context.Context, apiType, host, version, path string, options interface{}, args ...interface{}) (string, error) { + // set the path + if path == "" { + path = APIPathMap[apiType] + } + + // set the protocol + protocol := HTTPProtocol + if apiType == APITypeLive { + protocol = WSProtocol + } + if host == "" { + host = common.DefaultHost + } + + // check if the host has a protocol + r := regexp.MustCompile(`^(https?)://(.+)$`) + if apiType == APITypeLive { + r = regexp.MustCompile(`^(wss?)://(.+)$`) + } + + match := r.MatchString(host) + klog.V(3).Infof("host decompose... match: %t\n", match) + if match { + matches := r.FindStringSubmatch(host) + for _, match := range matches { + klog.V(5).Infof("match: %s\n", match) + } + protocol = matches[1] + host = matches[2] + + if slash := strings.Index(host, "/"); slash > 0 { + host = host[:slash] + } + } + klog.V(3).Infof("protocol: %s\n", protocol) + klog.V(3).Infof("host: %s\n", host) + + // make sure the version is set + if version == "" { + version = DefaultAPIVersion + } + + // remove the version from the path if it exists + r = regexp.MustCompile(`^(v\d+|%%s)/`) + match = r.MatchString(path) + klog.V(3).Infof("path decompose - match: %t\n", match) + if match { + path = r.ReplaceAllString(path, "") + } + + // Construct the query string + // using an options struct + var q url.Values + if options != nil { + q = url.Values{} + + encoder := schema.NewEncoder() + if err := encoder.Encode(options, q); err != nil { + return "", err + } + } + + // using custom parameters + if parameters, ok := ctx.Value(interfaces.ParametersContext{}).(map[string][]string); ok { + for k, vs := range parameters { + for _, v := range vs { + if q == nil { + q = url.Values{} + } + q.Add(k, v) + } + } + } + + // construct the full path and substitute the version and all query parameters + fullpath := fmt.Sprintf("%%s/%s", path) + completeFullpath := fmt.Sprintf(fullpath, append([]interface{}{version}, args...)...) + + // construct the URL + var u url.URL + if q != nil { + u = url.URL{Scheme: protocol, Host: host, Path: completeFullpath, RawQuery: q.Encode()} + } else { + u = url.URL{Scheme: protocol, Host: host, Path: completeFullpath} + } + + return u.String(), nil +} diff --git a/pkg/audio/microphone/constants.go b/pkg/audio/microphone/constants.go index bc7a896e..87d8cc07 100644 --- a/pkg/audio/microphone/constants.go +++ b/pkg/audio/microphone/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/audio/microphone/interfaces/interfaces.go b/pkg/audio/microphone/interfaces/interfaces.go index b4fc47b7..1328e8fd 100644 --- a/pkg/audio/microphone/interfaces/interfaces.go +++ b/pkg/audio/microphone/interfaces/interfaces.go @@ -1,10 +1,8 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT -/* - Microphone defines a interface for a Microphone implementation -*/ +// Microphone defines a interface for a Microphone implementation package interfaces import "io" diff --git a/pkg/audio/microphone/microphone.go b/pkg/audio/microphone/microphone.go index 91d1bff9..ea5d0eb2 100644 --- a/pkg/audio/microphone/microphone.go +++ b/pkg/audio/microphone/microphone.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -51,7 +51,7 @@ func New(cfg AudioConfig) (*Microphone, error) { // housekeeping m.stream = stream - klog.V(3).Infof("OpenDefaultStream succeded\n") + klog.V(3).Infof("OpenDefaultStream succeeded\n") klog.V(6).Infof("Microphone.New LEAVE\n") return m, nil @@ -65,7 +65,7 @@ func (m *Microphone) Start() error { return err } - klog.V(3).Infof("Start() succeded\n") + klog.V(3).Infof("Start() succeeded\n") return nil } diff --git a/pkg/audio/microphone/types.go b/pkg/audio/microphone/types.go index 71a25885..9b0c235c 100644 --- a/pkg/audio/microphone/types.go +++ b/pkg/audio/microphone/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -16,7 +16,7 @@ type AudioConfig struct { SamplingRate float32 } -// Microphone... +// Microphone is a representation of a microphone type Microphone struct { // microphone stream *portaudio.Stream diff --git a/pkg/audio/replay/constants.go b/pkg/audio/replay/constants.go index cf25b9c4..515626d2 100644 --- a/pkg/audio/replay/constants.go +++ b/pkg/audio/replay/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/audio/replay/replay.go b/pkg/audio/replay/replay.go index a3918af1..e3055bc1 100644 --- a/pkg/audio/replay/replay.go +++ b/pkg/audio/replay/replay.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -14,7 +14,7 @@ import ( ) // New creates an audio replay device -func New(opts ReplayOptions) (*Client, error) { +func New(opts Options) (*Client, error) { klog.V(6).Infof("Replay.New ENTER\n") client := &Client{ diff --git a/pkg/audio/replay/types.go b/pkg/audio/replay/types.go index ede43f67..7feb5964 100644 --- a/pkg/audio/replay/types.go +++ b/pkg/audio/replay/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -12,13 +12,13 @@ import ( ) // ReplayOpts defines options for this device -type ReplayOptions struct { +type Options struct { FullFilename string } // Client is a replay device. In this case, an audio stream. type Client struct { - options ReplayOptions + options Options // wav file *os.File diff --git a/pkg/client/analyze/client.go b/pkg/client/analyze/client.go index 3be0d2c9..23fa2874 100644 --- a/pkg/client/analyze/client.go +++ b/pkg/client/analyze/client.go @@ -12,21 +12,24 @@ import ( "context" "encoding/json" "errors" - "fmt" "io" "net/http" "net/url" "os" + "strings" klog "k8s.io/klog/v2" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" + common "github.com/deepgram/deepgram-go-sdk/pkg/client/common" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" ) +type textSource struct { + Text string `json:"text"` +} type urlSource struct { - Url string `json:"url"` + URL string `json:"url"` } /* @@ -36,7 +39,7 @@ Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY */ func NewWithDefaults() *Client { - return New("", interfaces.ClientOptions{}) + return New("", &interfaces.ClientOptions{}) } /* @@ -47,9 +50,9 @@ Input parameters: - apiKey: string containing the Deepgram API key - options: ClientOptions which allows overriding things like hostname, version of the API, etc. */ -func New(apiKey string, options interfaces.ClientOptions) *Client { +func New(apiKey string, options *interfaces.ClientOptions) *Client { if apiKey != "" { - options.ApiKey = apiKey + options.APIKey = apiKey } err := options.Parse() if err != nil { @@ -58,8 +61,7 @@ func New(apiKey string, options interfaces.ClientOptions) *Client { } c := Client{ - Client: rest.New(options), - cOptions: options, + common.New(apiKey, options), } return &c } @@ -75,7 +77,7 @@ Input parameters: Output parameters: - resBody: interface{} which will be populated with the response from the server */ -func (c *Client) DoFile(ctx context.Context, filePath string, req interfaces.AnalyzeOptions, resBody interface{}) error { +func (c *Client) DoFile(ctx context.Context, filePath string, req *interfaces.AnalyzeOptions, resBody interface{}) error { klog.V(6).Infof("analyze.DoFile() ENTER\n") // file? @@ -116,95 +118,64 @@ Input parameters: Output parameters: - resBody: interface{} which will be populated with the response from the server */ -func (c *Client) DoStream(ctx context.Context, src io.Reader, options interfaces.AnalyzeOptions, resBody interface{}) error { +func (c *Client) DoStream(ctx context.Context, src io.Reader, options *interfaces.AnalyzeOptions, resBody interface{}) error { klog.V(6).Infof("analyze.DoStream() ENTER\n") - // obtain URL for the REST API call - URI, err := version.GetAnalyzeAPI(ctx, c.cOptions.Host, c.cOptions.ApiVersion, c.cOptions.Path, options) + byFile := new(strings.Builder) + _, err := io.Copy(byFile, src) if err != nil { - klog.V(1).Infof("version.GetAnalyzeAPI failed. Err: %v\n", err) + klog.V(1).Infof("io.Copy() failed. Err: %v\n", err) klog.V(6).Infof("analyze.DoStream() LEAVE\n") return err } - req, err := http.NewRequestWithContext(ctx, "POST", URI, src) + klog.V(6).Infof("analyze.DoStream() LEAVE\n") + + return c.DoText(ctx, byFile.String(), options, resBody) +} + +func (c *Client) DoText(ctx context.Context, text string, options *interfaces.AnalyzeOptions, resBody interface{}) error { + klog.V(6).Infof("analyze.DoText() LEAVE\n") + + uri, err := version.GetAnalyzeAPI(ctx, c.Options.Host, c.Options.APIVersion, c.Options.Path, options) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("analyze.DoStream() LEAVE\n") + klog.V(1).Infof("GetAnalyzeAPI failed. Err: %v\n", err) + klog.V(6).Infof("analyze.DoText() LEAVE\n") return err } - klog.V(4).Infof("%s %s\n", req.Method, URI) - - if headers, ok := ctx.Value(interfaces.HeadersContext{}).(http.Header); ok { - for k, v := range headers { - for _, v := range v { - klog.V(3).Infof("Custom Header: %s = %s\n", k, v) - req.Header.Add(k, v) - } - } + + var buf bytes.Buffer + err = json.NewEncoder(&buf).Encode(textSource{Text: text}) + if err != nil { + klog.V(1).Infof("json.NewEncoder().Encode() failed. Err: %v\n", err) + klog.V(6).Infof("speak.DoText() LEAVE\n") + return err + } + + req, err := c.SetupRequest(ctx, "POST", uri, strings.NewReader(buf.String())) + if err != nil { + klog.V(1).Infof("SetupRequest failed. Err: %v\n", err) + klog.V(6).Infof("analyze.DoText() LEAVE\n") + return err } - req.Header.Set("Host", c.cOptions.Host) - req.Header.Set("Accept", "application/json") - req.Header.Set("Authorization", "token "+c.cOptions.ApiKey) - req.Header.Set("User-Agent", interfaces.DgAgent) - - err = c.HttpClient.Do(ctx, req, func(res *http.Response) error { - switch res.StatusCode { - case http.StatusOK: - case http.StatusCreated: - case http.StatusNoContent: - case http.StatusBadRequest: - klog.V(4).Infof("HTTP Error Code: %d\n", res.StatusCode) - detail, errBody := io.ReadAll(res.Body) - if err != nil { - klog.V(4).Infof("io.ReadAll failed. Err: %e\n", errBody) - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - return &interfaces.StatusError{res} - } - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - return fmt.Errorf("%s: %s", res.Status, bytes.TrimSpace(detail)) - default: - return &interfaces.StatusError{res} - } - - if resBody == nil { - klog.V(1).Infof("resBody == nil\n") - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - return nil - } - - switch b := resBody.(type) { - case *interfaces.RawResponse: - klog.V(3).Infof("RawResponse\n") - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - return res.Write(b) - case io.Writer: - klog.V(3).Infof("io.Writer\n") - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - _, err := io.Copy(b, res.Body) - return err - default: - d := json.NewDecoder(res.Body) - klog.V(3).Infof("json.NewDecoder\n") - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - return d.Decode(resBody) - } + err = c.HTTPClient.Do(ctx, req, func(res *http.Response) error { + _, err := c.HandleResponse(res, nil, resBody) + return err }) if err != nil { - klog.V(1).Infof("err = c.Client.Do failed. Err: %v\n", err) - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - return err + klog.V(1).Infof("HTTPClient.Do() failed. Err: %v\n", err) + } else { + klog.V(4).Infof("DoText successful\n") } + klog.V(6).Infof("analyze.DoText() LEAVE\n") - klog.V(3).Infof("analyze.DoStream() Succeeded\n") - klog.V(6).Infof("analyze.DoStream() LEAVE\n") - return nil + return err } -// IsUrl returns true if a string is of a URL format -func IsUrl(str string) bool { +// IsURL returns true if a string is of a URL format +func IsURL(str string) bool { u, err := url.Parse(str) return err == nil && u.Scheme != "" && u.Host != "" } @@ -220,55 +191,35 @@ Input parameters: Output parameters: - resBody: interface{} which will be populated with the response from the server */ -func (c *Client) DoURL(ctx context.Context, url string, options interfaces.AnalyzeOptions, resBody interface{}) error { +func (c *Client) DoURL(ctx context.Context, uri string, options *interfaces.AnalyzeOptions, resBody interface{}) error { klog.V(6).Infof("analyze.DoURL() ENTER\n") - klog.V(4).Infof("apiURI: %s\n", url) - // checks - validURL := IsUrl(url) - if !validURL { - klog.V(1).Infof("Invalid URL: %s\n", url) + if !IsURL(uri) { + klog.V(1).Infof("Invalid URL: %s\n", uri) klog.V(6).Infof("analyze.DoURL() LEAVE\n") return ErrInvalidInput } - // obtain URL - URI, err := version.GetAnalyzeAPI(ctx, c.cOptions.Host, c.cOptions.ApiVersion, c.cOptions.Path, options) + uri, err := version.GetAnalyzeAPI(ctx, c.Options.Host, c.Options.APIVersion, c.Options.Path, options) if err != nil { - klog.V(1).Infof("version.GetAnalyzeAPI failed. Err: %v\n", err) + klog.V(1).Infof("GetAnalyzeAPI failed. Err: %v\n", err) klog.V(6).Infof("analyze.DoURL() LEAVE\n") return err } var buf bytes.Buffer - err = json.NewEncoder(&buf).Encode(urlSource{Url: url}) - if err != nil { + if err := json.NewEncoder(&buf).Encode(urlSource{URL: uri}); err != nil { klog.V(1).Infof("json.NewEncoder().Encode() failed. Err: %v\n", err) klog.V(6).Infof("analyze.DoURL() LEAVE\n") return err } - req, err := http.NewRequestWithContext(ctx, "POST", URI, &buf) + req, err := c.SetupRequest(ctx, "POST", uri, &buf) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) + klog.V(1).Infof("SetupRequest failed. Err: %v\n", err) klog.V(6).Infof("analyze.DoURL() LEAVE\n") return err } - klog.V(4).Infof("%s %s\n", req.Method, URI) - - if headers, ok := ctx.Value(interfaces.HeadersContext{}).(http.Header); ok { - for k, v := range headers { - for _, v := range v { - klog.V(3).Infof("Custom Header: %s = %s\n", k, v) - req.Header.Add(k, v) - } - } - } - - req.Header.Set("Host", c.cOptions.Host) - req.Header.Set("Accept", "application/json") - req.Header.Set("Authorization", "token "+c.cOptions.ApiKey) - req.Header.Set("User-Agent", interfaces.DgAgent) switch req.Method { case http.MethodPost, http.MethodPatch, http.MethodPut: @@ -276,56 +227,17 @@ func (c *Client) DoURL(ctx context.Context, url string, options interfaces.Analy req.Header.Set("Content-Type", "application/json") } - err = c.HttpClient.Do(ctx, req, func(res *http.Response) error { - switch res.StatusCode { - case http.StatusOK: - case http.StatusCreated: - case http.StatusNoContent: - case http.StatusBadRequest: - klog.V(4).Infof("HTTP Error Code: %d\n", res.StatusCode) - detail, errBody := io.ReadAll(res.Body) - if err != nil { - klog.V(1).Infof("io.ReadAll failed. Err: %e\n", errBody) - klog.V(6).Infof("analyze.DoURL() LEAVE\n") - return &interfaces.StatusError{res} - } - klog.V(6).Infof("analyze.DoURL() LEAVE\n") - return fmt.Errorf("%s: %s", res.Status, bytes.TrimSpace(detail)) - default: - return &interfaces.StatusError{res} - } - - if resBody == nil { - klog.V(1).Infof("resBody == nil\n") - klog.V(6).Infof("analyze.DoURL() LEAVE\n") - return nil - } - - switch b := resBody.(type) { - case *interfaces.RawResponse: - klog.V(3).Infof("RawResponse\n") - klog.V(6).Infof("analyze.DoURL() LEAVE\n") - return res.Write(b) - case io.Writer: - klog.V(3).Infof("io.Writer\n") - klog.V(6).Infof("analyze.DoURL() LEAVE\n") - _, err := io.Copy(b, res.Body) - return err - default: - d := json.NewDecoder(res.Body) - klog.V(3).Infof("json.NewDecoder\n") - klog.V(6).Infof("analyze.DoURL() LEAVE\n") - return d.Decode(resBody) - } + err = c.HTTPClient.Do(ctx, req, func(res *http.Response) error { + _, err := c.HandleResponse(res, nil, resBody) + return err }) if err != nil { - klog.V(1).Infof("err = c.Client.Do failed. Err: %v\n", err) - klog.V(6).Infof("analyze.DoURL() LEAVE\n") - return err + klog.V(1).Infof("HTTPClient.Do() failed. Err: %v\n", err) + } else { + klog.V(4).Infof("DoURL successful\n") } - - klog.V(3).Infof("analyze.DoURL() Succeeded\n") klog.V(6).Infof("analyze.DoURL() LEAVE\n") - return nil + + return err } diff --git a/pkg/client/analyze/types.go b/pkg/client/analyze/types.go index 9a6f053b..7fb2391c 100644 --- a/pkg/client/analyze/types.go +++ b/pkg/client/analyze/types.go @@ -5,13 +5,10 @@ package analyze import ( - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" + common "github.com/deepgram/deepgram-go-sdk/pkg/client/common" ) // Client implements helper functionality for Prerecorded API type Client struct { - *rest.Client - - cOptions interfaces.ClientOptions + *common.Client } diff --git a/pkg/client/common/common.go b/pkg/client/common/common.go new file mode 100644 index 00000000..cf3ff39b --- /dev/null +++ b/pkg/client/common/common.go @@ -0,0 +1,149 @@ +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +package common + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + klog "k8s.io/klog/v2" + + interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" + rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" +) + +func New(apiKey string, options *interfaces.ClientOptions) *Client { + if apiKey != "" { + options.APIKey = apiKey + } + err := options.Parse() + if err != nil { + klog.V(1).Infof("options.Parse() failed. Err: %v\n", err) + return nil + } + + c := Client{ + rest.New(options), + } + + return &c +} + +// SetupRequest prepares and returns a new HTTP request with common headers set. +func (c *Client) SetupRequest(ctx context.Context, method, uri string, body io.Reader) (*http.Request, error) { + req, err := http.NewRequestWithContext(ctx, method, uri, body) + if err != nil { + klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) + return nil, err + } + klog.V(4).Infof("%s %s\n", req.Method, uri) + + if headers, ok := ctx.Value(interfaces.HeadersContext{}).(http.Header); ok { + for k, v := range headers { + for _, v := range v { + klog.V(3).Infof("Custom Header: %s = %s\n", k, v) + req.Header.Add(k, v) + } + } + } + + req.Header.Set("Host", c.Options.Host) + req.Header.Set("Accept", "application/json") + req.Header.Set("Authorization", "token "+c.Options.APIKey) + req.Header.Set("User-Agent", interfaces.DgAgent) + + return req, nil +} + +// ProcessRequest sends the HTTP request and processes the response. +func (c *Client) ProcessRequest(ctx context.Context, req *http.Request, result interface{}) error { + err := c.Client.Do(ctx, req, result) + if err != nil { + if e, ok := err.(*interfaces.StatusError); ok { + klog.V(1).Infof("HTTP Code: %v\n", e.Resp.StatusCode) + return err + } + klog.V(1).Infof("Platform Supplied Err: %v\n", err) + return err + } + + return nil +} + +// HandleResponse processes the HTTP response for both streaming and URL-based API requests. +func (c *Client) HandleResponse(res *http.Response, keys []string, resBody interface{}) (map[string]string, error) { + klog.V(6).Infof("Handle HTTP response\n") + fmt.Printf("keys: %s\v", keys) + switch res.StatusCode { + case http.StatusOK, http.StatusCreated, http.StatusNoContent: + return decodeResponseBody(res, keys, resBody) + case http.StatusBadRequest: + klog.V(4).Infof("HTTP Error Code: %d\n", res.StatusCode) + detail, err := io.ReadAll(res.Body) + if err != nil { + klog.V(4).Infof("io.ReadAll failed. Err: %v\n", err) + return nil, &interfaces.StatusError{Resp: res} + } + return nil, fmt.Errorf("%s: %s", res.Status, bytes.TrimSpace(detail)) + default: + return nil, &interfaces.StatusError{Resp: res} + } +} + +// decodeResponseBody decodes the HTTP response body into the provided resBody based on its type. +func decodeResponseBody(res *http.Response, keys []string, resBody interface{}) (map[string]string, error) { + fmt.Printf("keys: %s\v", keys) + + retValues := make(map[string]string) + + // return values in header + if len(keys) > 0 { + for _, k := range keys { + fmt.Printf("key: %s\n", k) + value := res.Header.Get(k) + if len(value) > 0 { + klog.V(4).Infof("RetValue Header: %s = %s\n", k, value) + retValues[k] = value + continue + } + value = res.Header.Get("dg-" + k) + if len(value) > 0 { + klog.V(4).Infof("RetValue Header: %s = %s\n", k, value) + retValues[k] = value + continue + } + value = res.Header.Get("x-dg-" + k) + if len(value) > 0 { + klog.V(4).Infof("RetValue Header: %s = %s\n", k, value) + retValues[k] = value + continue + } + } + } + + switch b := resBody.(type) { + case *interfaces.RawResponse: + klog.V(3).Infof("RawResponse\n") + return retValues, res.Write(b) + case io.Writer: + klog.V(3).Infof("io.Writer\n") + _, err := io.Copy(b, res.Body) + return retValues, err + default: + klog.V(3).Infof("*io.ReadCloser\n") + resultStr, err := io.ReadAll(res.Body) + if err != nil { + klog.V(1).Infof("io.ReadAll failed. Err: %v\n", err) + return nil, err + } + klog.V(5).Infof("json.NewDecoder Raw:\n\n%s\n\n", resultStr) + return retValues, json.NewDecoder(strings.NewReader(string(resultStr))).Decode(resBody) + } +} diff --git a/pkg/client/common/types.go b/pkg/client/common/types.go new file mode 100644 index 00000000..136ac5e7 --- /dev/null +++ b/pkg/client/common/types.go @@ -0,0 +1,14 @@ +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +package common + +import ( + rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" +) + +// Client implements helper functionality for Prerecorded API +type Client struct { + *rest.Client +} diff --git a/pkg/client/interfaces/constants.go b/pkg/client/interfaces/constants.go index 92c451c6..474efd80 100644 --- a/pkg/client/interfaces/constants.go +++ b/pkg/client/interfaces/constants.go @@ -10,6 +10,6 @@ import ( // errors var ( - // ErrNoApiKey no api key found - ErrNoApiKey = errors.New("no api key found") + // ErrNoAPIKey no api key found + ErrNoAPIKey = errors.New("no api key found") ) diff --git a/pkg/client/interfaces/docs.go b/pkg/client/interfaces/docs.go index 50e37173..f911a557 100644 --- a/pkg/client/interfaces/docs.go +++ b/pkg/client/interfaces/docs.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/interfaces/options.go b/pkg/client/interfaces/options.go index 327cde1c..9778f786 100644 --- a/pkg/client/interfaces/options.go +++ b/pkg/client/interfaces/options.go @@ -13,10 +13,10 @@ import ( func (o *ClientOptions) Parse() error { // general - if o.ApiKey == "" { + if o.APIKey == "" { if v := os.Getenv("DEEPGRAM_API_KEY"); v != "" { klog.V(3).Infof("DEEPGRAM_API_KEY found") - o.ApiKey = v + o.APIKey = v } } if v := os.Getenv("DEEPGRAM_HOST"); v != "" { @@ -25,7 +25,7 @@ func (o *ClientOptions) Parse() error { } if v := os.Getenv("DEEPGRAM_API_VERSION"); v != "" { klog.V(3).Infof("DEEPGRAM_API_VERSION found") - o.ApiVersion = v + o.APIVersion = v } if v := os.Getenv("DEEPGRAM_API_PATH"); v != "" { klog.V(3).Infof("DEEPGRAM_API_PATH found") @@ -37,9 +37,9 @@ func (o *ClientOptions) Parse() error { } // checks - if !o.OnPrem && o.ApiKey == "" { + if !o.OnPrem && o.APIKey == "" { klog.V(1).Infof("DEEPGRAM_API_KEY not set") - return ErrNoApiKey + return ErrNoAPIKey } // shared diff --git a/pkg/client/interfaces/types-analyze.go b/pkg/client/interfaces/types-analyze.go index 880c29e8..69128d72 100644 --- a/pkg/client/interfaces/types-analyze.go +++ b/pkg/client/interfaces/types-analyze.go @@ -13,15 +13,15 @@ https://developers.deepgram.com/reference/text-intelligence-apis */ type AnalyzeOptions struct { - Callback string `json:"callback,omitempty" url:"callback,omitempty"` - CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` - CustomIntent []string `json:"custom_intent,omitempty" url:"custom_intent,omitempty"` - CustomIntentMode string `json:"custom_intent_mode,omitempty" url:"custom_intent_mode,omitempty"` - CustomTopic []string `json:"custom_topic,omitempty" url:"custom_topic,omitempty"` - CustomTopicMode string `json:"custom_topic_mode,omitempty" url:"custom_topic_mode,omitempty"` - Intents bool `json:"intents,omitempty" url:"intents,omitempty"` - Language string `json:"language,omitempty" url:"language,omitempty"` - Summarize bool `json:"summarize,omitempty" url:"summarize,omitempty"` - Sentiment bool `json:"sentiment,omitempty" url:"sentiment,omitempty"` - Topics bool `json:"topics,omitempty" url:"topics,omitempty"` + Callback string `json:"callback,omitempty" schema:"callback,omitempty"` + CallbackMethod string `json:"callback_method,omitempty" schema:"callback_method,omitempty"` + CustomIntent []string `json:"custom_intent,omitempty" schema:"custom_intent,omitempty"` + CustomIntentMode string `json:"custom_intent_mode,omitempty" schema:"custom_intent_mode,omitempty"` + CustomTopic []string `json:"custom_topic,omitempty" schema:"custom_topic,omitempty"` + CustomTopicMode string `json:"custom_topic_mode,omitempty" schema:"custom_topic_mode,omitempty"` + Intents bool `json:"intents,omitempty" schema:"intents,omitempty"` + Language string `json:"language,omitempty" schema:"language,omitempty"` + Summarize bool `json:"summarize,omitempty" schema:"summarize,omitempty"` + Sentiment bool `json:"sentiment,omitempty" schema:"sentiment,omitempty"` + Topics bool `json:"topics,omitempty" schema:"topics,omitempty"` } diff --git a/pkg/client/interfaces/types-client.go b/pkg/client/interfaces/types-client.go index 7dbbecd6..29f2aaf6 100644 --- a/pkg/client/interfaces/types-client.go +++ b/pkg/client/interfaces/types-client.go @@ -6,9 +6,9 @@ package interfaces // ClientOptions defines any options for the client type ClientOptions struct { - ApiKey string + APIKey string Host string // override for the host endpoint - ApiVersion string // override for the version used + APIVersion string // override for the version used Path string // override for the endpoint path usually or OnPrem bool // set to true if using on-prem diff --git a/pkg/client/interfaces/types-prerecorded.go b/pkg/client/interfaces/types-prerecorded.go index de2fffc6..d0525f6f 100644 --- a/pkg/client/interfaces/types-prerecorded.go +++ b/pkg/client/interfaces/types-prerecorded.go @@ -12,43 +12,43 @@ Please see the prerecorded audio documentation for more details: https://developers.deepgram.com/reference/pre-recorded */ type PreRecordedTranscriptionOptions struct { - Alternatives int `json:"alternatives,omitempty" url:"alternatives,omitempty"` - Callback string `json:"callback,omitempty" url:"callback,omitempty"` - CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` - Channels int `json:"channels,omitempty" url:"channels,omitempty"` - CustomIntent []string `json:"custom_intent,omitempty" url:"custom_intent,omitempty"` - CustomIntentMode string `json:"custom_intent_mode,omitempty" url:"custom_intent_mode,omitempty"` - CustomTopic []string `json:"custom_topic,omitempty" url:"custom_topic,omitempty"` - CustomTopicMode string `json:"custom_topic_mode,omitempty" url:"custom_topic_mode,omitempty"` - DetectEntities bool `json:"detect_entities,omitempty" url:"detect_entities,omitempty"` - DetectLanguage bool `json:"detect_language,omitempty" url:"detect_language,omitempty"` - DetectTopics bool `json:"detect_topics,omitempty" url:"detect_topics,omitempty"` - Diarize bool `json:"diarize,omitempty" url:"diarize,omitempty"` - DiarizeVersion string `json:"diarize_version,omitempty" url:"diarize_version,omitempty"` - Dictation bool `json:"dictation,omitempty" url:"dictation,omitempty"` - Encoding string `json:"encoding,omitempty" url:"encoding,omitempty"` - Extra []string `json:"extra,omitempty" url:"extra,omitempty"` - FillerWords bool `json:"filler_words,omitempty" url:"filler_words,omitempty"` - Intents bool `json:"intents,omitempty" url:"intents,omitempty"` - Keywords []string `json:"keywords,omitempty" url:"keywords,omitempty"` - Language string `json:"language,omitempty" url:"language,omitempty"` - Measurements bool `json:"measurements,omitempty" url:"measurements,omitempty"` - Model string `json:"model,omitempty" url:"model,omitempty"` - Multichannel bool `json:"multichannel,omitempty" url:"multichannel,omitempty"` - Numerals bool `json:"numerals,omitempty" url:"numerals,omitempty"` - Paragraphs bool `json:"paragraphs,omitempty" url:"paragraphs,omitempty"` - ProfanityFilter bool `json:"profanity_filter,omitempty" url:"profanity_filter,omitempty"` - Punctuate bool `json:"punctuate,omitempty" url:"punctuate,omitempty"` - Redact []string `json:"redact,omitempty" url:"redact,omitempty"` - Replace []string `json:"replace,omitempty" url:"replace,omitempty"` - SampleRate int `json:"sample_rate,omitempty" url:"sample_rate,omitempty"` - Search []string `json:"search,omitempty" url:"search,omitempty"` - Sentiment bool `json:"sentiment,omitempty" url:"sentiment,omitempty"` - SmartFormat bool `json:"smart_format,omitempty" url:"smart_format,omitempty"` - Summarize string `json:"summarize,omitempty" url:"summarize,omitempty"` - Tag []string `json:"tag,omitempty" url:"tag,omitempty"` - Topics bool `json:"topics,omitempty" url:"topics,omitempty"` - UttSplit float64 `json:"utt_split,omitempty" url:"utt_split,omitempty"` - Utterances bool `json:"utterances,omitempty" url:"utterances,omitempty"` - Version string `json:"version,omitempty" url:"version,omitempty"` + Alternatives int `json:"alternatives,omitempty" schema:"alternatives,omitempty"` + Callback string `json:"callback,omitempty" schema:"callback,omitempty"` + CallbackMethod string `json:"callback_method,omitempty" schema:"callback_method,omitempty"` + Channels int `json:"channels,omitempty" schema:"channels,omitempty"` + CustomIntent []string `json:"custom_intent,omitempty" schema:"custom_intent,omitempty"` + CustomIntentMode string `json:"custom_intent_mode,omitempty" schema:"custom_intent_mode,omitempty"` + CustomTopic []string `json:"custom_topic,omitempty" schema:"custom_topic,omitempty"` + CustomTopicMode string `json:"custom_topic_mode,omitempty" schema:"custom_topic_mode,omitempty"` + DetectEntities bool `json:"detect_entities,omitempty" schema:"detect_entities,omitempty"` + DetectLanguage bool `json:"detect_language,omitempty" schema:"detect_language,omitempty"` + DetectTopics bool `json:"detect_topics,omitempty" schema:"detect_topics,omitempty"` + Diarize bool `json:"diarize,omitempty" schema:"diarize,omitempty"` + DiarizeVersion string `json:"diarize_version,omitempty" schema:"diarize_version,omitempty"` + Dictation bool `json:"dictation,omitempty" schema:"dictation,omitempty"` + Encoding string `json:"encoding,omitempty" schema:"encoding,omitempty"` + Extra []string `json:"extra,omitempty" schema:"extra,omitempty"` + FillerWords bool `json:"filler_words,omitempty" schema:"filler_words,omitempty"` + Intents bool `json:"intents,omitempty" schema:"intents,omitempty"` + Keywords []string `json:"keywords,omitempty" schema:"keywords,omitempty"` + Language string `json:"language,omitempty" schema:"language,omitempty"` + Measurements bool `json:"measurements,omitempty" schema:"measurements,omitempty"` + Model string `json:"model,omitempty" schema:"model,omitempty"` + Multichannel bool `json:"multichannel,omitempty" schema:"multichannel,omitempty"` + Numerals bool `json:"numerals,omitempty" schema:"numerals,omitempty"` + Paragraphs bool `json:"paragraphs,omitempty" schema:"paragraphs,omitempty"` + ProfanityFilter bool `json:"profanity_filter,omitempty" schema:"profanity_filter,omitempty"` + Punctuate bool `json:"punctuate,omitempty" schema:"punctuate,omitempty"` + Redact []string `json:"redact,omitempty" schema:"redact,omitempty"` + Replace []string `json:"replace,omitempty" schema:"replace,omitempty"` + SampleRate int `json:"sample_rate,omitempty" schema:"sample_rate,omitempty"` + Search []string `json:"search,omitempty" schema:"search,omitempty"` + Sentiment bool `json:"sentiment,omitempty" schema:"sentiment,omitempty"` + SmartFormat bool `json:"smart_format,omitempty" schema:"smart_format,omitempty"` + Summarize string `json:"summarize,omitempty" schema:"summarize,omitempty"` + Tag []string `json:"tag,omitempty" schema:"tag,omitempty"` + Topics bool `json:"topics,omitempty" schema:"topics,omitempty"` + UttSplit float64 `json:"utt_split,omitempty" schema:"utt_split,omitempty"` + Utterances bool `json:"utterances,omitempty" schema:"utterances,omitempty"` + Version string `json:"version,omitempty" schema:"version,omitempty"` } diff --git a/pkg/client/interfaces/types-speak.go b/pkg/client/interfaces/types-speak.go index 8a1cfec7..7ad2e21d 100644 --- a/pkg/client/interfaces/types-speak.go +++ b/pkg/client/interfaces/types-speak.go @@ -12,9 +12,9 @@ Please see the text-to-speech documentation for more details: https://developers.deepgram.com/reference/text-to-speech-preview-api */ type SpeakOptions struct { - Model string `json:"model,omitempty" url:"model,omitempty"` - Encoding string `json:"encoding,omitempty" url:"encoding,omitempty"` - Container string `json:"container,omitempty" url:"container,omitempty"` - SampleRate int `json:"sample_rate,omitempty" url:"sample_rate,omitempty"` - BitRate int `json:"bit_rate,omitempty" url:"bit_rate,omitempty"` + Model string `json:"model,omitempty" schema:"model,omitempty"` + Encoding string `json:"encoding,omitempty" schema:"encoding,omitempty"` + Container string `json:"container,omitempty" schema:"container,omitempty"` + SampleRate int `json:"sample_rate,omitempty" schema:"sample_rate,omitempty"` + BitRate int `json:"bit_rate,omitempty" schema:"bit_rate,omitempty"` } diff --git a/pkg/client/interfaces/types-stream.go b/pkg/client/interfaces/types-stream.go index 63f9a1eb..32550c83 100644 --- a/pkg/client/interfaces/types-stream.go +++ b/pkg/client/interfaces/types-stream.go @@ -12,31 +12,31 @@ Please see the live/streaming documentation for more details: https://developers.deepgram.com/reference/streaming */ type LiveTranscriptionOptions struct { - Alternatives int `json:"alternatives,omitempty" url:"alternatives,omitempty"` - Callback string `json:"callback,omitempty" url:"callback,omitempty"` - CallbackMethod string `json:"callback_method,omitempty" url:"callback_method,omitempty"` - Channels int `json:"channels,omitempty" url:"channels,omitempty"` - Diarize bool `json:"diarize,omitempty" url:"diarize,omitempty"` - DiarizeVersion string `json:"diarize_version,omitempty" url:"diarize_version,omitempty"` - Encoding string `json:"encoding,omitempty" url:"encoding,omitempty"` - Endpointing string `json:"endpointing,omitempty" url:"endpointing,omitempty"` - Extra []string `json:"extra,omitempty" url:"extra,omitempty"` - FillerWords bool `json:"filler_words,omitempty" url:"filler_words,omitempty"` - InterimResults bool `json:"interim_results,omitempty" url:"interim_results,omitempty"` - Keywords []string `json:"keywords,omitempty" url:"keywords,omitempty"` - Language string `json:"language,omitempty" url:"language,omitempty"` - Model string `json:"model,omitempty" url:"model,omitempty"` - Multichannel bool `json:"multichannel,omitempty" url:"multichannel,omitempty"` - Numerals bool `json:"numerals,omitempty" url:"numerals,omitempty"` - ProfanityFilter bool `json:"profanity_filter,omitempty" url:"profanity_filter,omitempty"` - Punctuate bool `json:"punctuate,omitempty" url:"punctuate,omitempty"` - Redact []string `json:"redact,omitempty" url:"redact,omitempty"` - Replace []string `json:"replace,omitempty" url:"replace,omitempty"` - SampleRate int `json:"sample_rate,omitempty" url:"sample_rate,omitempty"` - Search []string `json:"search,omitempty" url:"search,omitempty"` - SmartFormat bool `json:"smart_format,omitempty" url:"smart_format,omitempty"` - Tag []string `json:"tag,omitempty" url:"tag,omitempty"` - UtteranceEndMs string `json:"utterance_end_ms,omitempty" url:"utterance_end_ms,omitempty"` - VadEvents bool `json:"vad_events,omitempty" url:"vad_events,omitempty"` - Version string `json:"version,omitempty" url:"version,omitempty"` + Alternatives int `json:"alternatives,omitempty" schema:"alternatives,omitempty"` + Callback string `json:"callback,omitempty" schema:"callback,omitempty"` + CallbackMethod string `json:"callback_method,omitempty" schema:"callback_method,omitempty"` + Channels int `json:"channels,omitempty" schema:"channels,omitempty"` + Diarize bool `json:"diarize,omitempty" schema:"diarize,omitempty"` + DiarizeVersion string `json:"diarize_version,omitempty" schema:"diarize_version,omitempty"` + Encoding string `json:"encoding,omitempty" schema:"encoding,omitempty"` + Endpointing string `json:"endpointing,omitempty" schema:"endpointing,omitempty"` + Extra []string `json:"extra,omitempty" schema:"extra,omitempty"` + FillerWords bool `json:"filler_words,omitempty" schema:"filler_words,omitempty"` + InterimResults bool `json:"interim_results,omitempty" schema:"interim_results,omitempty"` + Keywords []string `json:"keywords,omitempty" schema:"keywords,omitempty"` + Language string `json:"language,omitempty" schema:"language,omitempty"` + Model string `json:"model,omitempty" schema:"model,omitempty"` + Multichannel bool `json:"multichannel,omitempty" schema:"multichannel,omitempty"` + Numerals bool `json:"numerals,omitempty" schema:"numerals,omitempty"` + ProfanityFilter bool `json:"profanity_filter,omitempty" schema:"profanity_filter,omitempty"` + Punctuate bool `json:"punctuate,omitempty" schema:"punctuate,omitempty"` + Redact []string `json:"redact,omitempty" schema:"redact,omitempty"` + Replace []string `json:"replace,omitempty" schema:"replace,omitempty"` + SampleRate int `json:"sample_rate,omitempty" schema:"sample_rate,omitempty"` + Search []string `json:"search,omitempty" schema:"search,omitempty"` + SmartFormat bool `json:"smart_format,omitempty" schema:"smart_format,omitempty"` + Tag []string `json:"tag,omitempty" schema:"tag,omitempty"` + UtteranceEndMs string `json:"utterance_end_ms,omitempty" schema:"utterance_end_ms,omitempty"` + VadEvents bool `json:"vad_events,omitempty" schema:"vad_events,omitempty"` + Version string `json:"version,omitempty" schema:"version,omitempty"` } diff --git a/pkg/client/interfaces/utils.go b/pkg/client/interfaces/utils.go index 943e3351..daa7cf7a 100644 --- a/pkg/client/interfaces/utils.go +++ b/pkg/client/interfaces/utils.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -18,7 +18,7 @@ const ( sdkVersion string = "v1.2.0" ) -// connection agent +// DgAgent is the user agent string for the SDK var DgAgent string = "@deepgram/sdk/" + sdkVersion + " go/" + goVersion() func goVersion() string { diff --git a/pkg/client/live/client.go b/pkg/client/live/client.go index 39eaf351..0bcb412c 100644 --- a/pkg/client/live/client.go +++ b/pkg/client/live/client.go @@ -30,8 +30,8 @@ NewForDemo creates a new websocket connection with all default options Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY */ -func NewForDemo(ctx context.Context, options interfaces.LiveTranscriptionOptions) (*Client, error) { - return New(ctx, "", interfaces.ClientOptions{}, options, nil) +func NewForDemo(ctx context.Context, options *interfaces.LiveTranscriptionOptions) (*Client, error) { + return New(ctx, "", &interfaces.ClientOptions{}, options, nil) } /* @@ -41,8 +41,8 @@ Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY - The callback handler is set to the default handler which just prints all messages to the console */ -func NewWithDefaults(ctx context.Context, options interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*Client, error) { - return New(ctx, "", interfaces.ClientOptions{}, options, callback) +func NewWithDefaults(ctx context.Context, options *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*Client, error) { + return New(ctx, "", &interfaces.ClientOptions{}, options, callback) } /* @@ -55,11 +55,11 @@ Input parameters: - tOptions: LiveTranscriptionOptions which allows overriding things like language, model, etc. - callback: LiveMessageCallback which is a callback that allows you to perform actions based on the transcription */ -func New(ctx context.Context, apiKey string, cOptions interfaces.ClientOptions, tOptions interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*Client, error) { +func New(ctx context.Context, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*Client, error) { klog.V(6).Infof("live.New() ENTER\n") if apiKey != "" { - cOptions.ApiKey = apiKey + cOptions.APIKey = apiKey } err := cOptions.Parse() if err != nil { @@ -133,9 +133,10 @@ func (c *Client) ConnectWithRetry(retries int64) *websocket.Conn { dialer := websocket.Dialer{ HandshakeTimeout: 45 * time.Second, - TLSClientConfig: &tls.Config{InsecureSkipVerify: c.cOptions.SkipServerAuth}, - RedirectService: c.cOptions.RedirectService, - SkipServerAuth: c.cOptions.SkipServerAuth, + /* #nosec G402 */ + TLSClientConfig: &tls.Config{InsecureSkipVerify: c.cOptions.SkipServerAuth}, + RedirectService: c.cOptions.RedirectService, + SkipServerAuth: c.cOptions.SkipServerAuth, } // set websocket headers @@ -153,7 +154,7 @@ func (c *Client) ConnectWithRetry(retries int64) *websocket.Conn { // sets the API key myHeader.Set("Host", c.cOptions.Host) - myHeader.Set("Authorization", "token "+c.cOptions.ApiKey) + myHeader.Set("Authorization", "token "+c.cOptions.APIKey) myHeader.Set("User-Agent", interfaces.DgAgent) // attempt to establish connection @@ -173,7 +174,7 @@ func (c *Client) ConnectWithRetry(retries int64) *websocket.Conn { i++ // create new connection - url, err := version.GetLiveAPI(c.org, c.cOptions.Host, c.cOptions.ApiVersion, c.cOptions.Path, c.tOptions) + url, err := version.GetLiveAPI(c.org, c.cOptions.Host, c.cOptions.APIVersion, c.cOptions.Path, c.tOptions) if err != nil { klog.V(1).Infof("version.GetLiveAPI failed. Err: %v\n", err) klog.V(7).Infof("live.ConnectWithRetry() LEAVE\n") @@ -182,7 +183,11 @@ func (c *Client) ConnectWithRetry(retries int64) *websocket.Conn { klog.V(5).Infof("Connecting to %s\n", url) // perform the websocket connection - ws, _, err := dialer.DialContext(c.ctx, url, myHeader) + ws, res, err := dialer.DialContext(c.ctx, url, myHeader) + if res != nil { + klog.V(3).Infof("HTTP Response: %s\n", res.Status) + res.Body.Close() + } if err != nil { klog.V(1).Infof("Cannot connect to websocket: %s\n", c.cOptions.Host) continue @@ -260,7 +265,7 @@ func (c *Client) listen() { func (c *Client) Stream(r io.Reader) error { klog.V(6).Infof("live.Stream() ENTER\n") - chunk := make([]byte, CHUNK_SIZE) + chunk := make([]byte, ChunkSize) for { select { @@ -408,7 +413,7 @@ func (c *Client) closeWs() { } else if errDg != nil { klog.V(1).Infof("Failed to send CloseNormalClosure. Err: %v\n", errDg) } - time.Sleep(TERMINATION_SLEEP) // allow time for server to register closure + time.Sleep(TerminationSleep) // allow time for server to register closure // fire off close connection err := c.router.CloseHelper(&msginterfaces.CloseResponse{ @@ -425,7 +430,7 @@ func (c *Client) closeWs() { } else if errProto != nil { klog.V(1).Infof("Failed to send CloseNormalClosure. Err: %v\n", errProto) } - time.Sleep(TERMINATION_SLEEP) // allow time for server to register closure + time.Sleep(TerminationSleep) // allow time for server to register closure c.wsconn.Close() } diff --git a/pkg/client/live/constants.go b/pkg/client/live/constants.go index eddb75d4..6a4cc14b 100644 --- a/pkg/client/live/constants.go +++ b/pkg/client/live/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -18,8 +18,8 @@ const ( defaultConnectRetry int64 = 3 defaultDelayBetweenRetry int64 = 2 - CHUNK_SIZE = 1024 * 2 - TERMINATION_SLEEP = 100 * time.Millisecond + ChunkSize = 1024 * 2 + TerminationSleep = 100 * time.Millisecond ) // errors diff --git a/pkg/client/live/init.go b/pkg/client/live/init.go index a790c3d0..e6771fd1 100644 --- a/pkg/client/live/init.go +++ b/pkg/client/live/init.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/live/types.go b/pkg/client/live/types.go index 12b4dff2..34d2e85f 100644 --- a/pkg/client/live/types.go +++ b/pkg/client/live/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -17,8 +17,8 @@ import ( // Client is a struct representing the websocket client connection type Client struct { - cOptions interfaces.ClientOptions - tOptions interfaces.LiveTranscriptionOptions + cOptions *interfaces.ClientOptions + tOptions *interfaces.LiveTranscriptionOptions sendBuf chan []byte org context.Context diff --git a/pkg/client/prerecorded/client.go b/pkg/client/prerecorded/client.go index ec385e6f..0017f12d 100644 --- a/pkg/client/prerecorded/client.go +++ b/pkg/client/prerecorded/client.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -12,22 +12,20 @@ import ( "context" "encoding/json" "errors" - "fmt" "io" "net/http" "net/url" "os" - "strings" klog "k8s.io/klog/v2" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" + common "github.com/deepgram/deepgram-go-sdk/pkg/client/common" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" ) type urlSource struct { - Url string `json:"url"` + URL string `json:"url"` } /* @@ -37,7 +35,7 @@ Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY */ func NewWithDefaults() *Client { - return New("", interfaces.ClientOptions{}) + return New("", &interfaces.ClientOptions{}) } /* @@ -48,9 +46,9 @@ Input parameters: - apiKey: string containing the Deepgram API key - options: ClientOptions which allows overriding things like hostname, version of the API, etc. */ -func New(apiKey string, options interfaces.ClientOptions) *Client { +func New(apiKey string, options *interfaces.ClientOptions) *Client { if apiKey != "" { - options.ApiKey = apiKey + options.APIKey = apiKey } err := options.Parse() if err != nil { @@ -59,8 +57,7 @@ func New(apiKey string, options interfaces.ClientOptions) *Client { } c := Client{ - Client: rest.New(options), - cOptions: options, + common.New(apiKey, options), } return &c } @@ -75,7 +72,7 @@ Input parameters: Output parameters: - resBody: interface{} which will be populated with the response from the server */ -func (c *Client) DoFile(ctx context.Context, filePath string, req interfaces.PreRecordedTranscriptionOptions, resBody interface{}) error { +func (c *Client) DoFile(ctx context.Context, filePath string, req *interfaces.PreRecordedTranscriptionOptions, resBody interface{}) error { klog.V(6).Infof("prerecorded.DoFile() ENTER\n") // file? @@ -115,102 +112,41 @@ Input parameters: Output parameters: - resBody: interface{} which will be populated with the response from the server */ -func (c *Client) DoStream(ctx context.Context, src io.Reader, options interfaces.PreRecordedTranscriptionOptions, resBody interface{}) error { +// DoStream initiates a streaming API request. +func (c *Client) DoStream(ctx context.Context, src io.Reader, options *interfaces.PreRecordedTranscriptionOptions, resBody interface{}) error { klog.V(6).Infof("prerecorded.DoStream() ENTER\n") - // obtain URL for the REST API call - URI, err := version.GetPrerecordedAPI(ctx, c.cOptions.Host, c.cOptions.ApiVersion, c.cOptions.Path, options) + uri, err := version.GetPrerecordedAPI(ctx, c.Options.Host, c.Options.APIVersion, c.Options.Path, options) if err != nil { - klog.V(1).Infof("version.GetPrerecordedAPI failed. Err: %v\n", err) + klog.V(1).Infof("GetPrerecordedAPI failed. Err: %v\n", err) klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") return err } - req, err := http.NewRequestWithContext(ctx, "POST", URI, src) + req, err := c.SetupRequest(ctx, "POST", uri, src) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) + klog.V(1).Infof("SetupRequest failed. Err: %v\n", err) klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") return err } - klog.V(4).Infof("%s %s\n", req.Method, URI) - - if headers, ok := ctx.Value(interfaces.HeadersContext{}).(http.Header); ok { - for k, v := range headers { - for _, v := range v { - klog.V(3).Infof("Custom Header: %s = %s\n", k, v) - req.Header.Add(k, v) - } - } - } - req.Header.Set("Host", c.cOptions.Host) - req.Header.Set("Accept", "application/json") - req.Header.Set("Authorization", "token "+c.cOptions.ApiKey) - req.Header.Set("User-Agent", interfaces.DgAgent) - - err = c.HttpClient.Do(ctx, req, func(res *http.Response) error { - switch res.StatusCode { - case http.StatusOK: - case http.StatusCreated: - case http.StatusNoContent: - case http.StatusBadRequest: - klog.V(4).Infof("HTTP Error Code: %d\n", res.StatusCode) - detail, errBody := io.ReadAll(res.Body) - if err != nil { - klog.V(4).Infof("io.ReadAll failed. Err: %e\n", errBody) - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return &interfaces.StatusError{res} - } - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return fmt.Errorf("%s: %s", res.Status, bytes.TrimSpace(detail)) - default: - return &interfaces.StatusError{res} - } - - if resBody == nil { - klog.V(1).Infof("resBody == nil\n") - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return nil - } - - switch b := resBody.(type) { - case *interfaces.RawResponse: - klog.V(3).Infof("RawResponse\n") - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return res.Write(b) - case io.Writer: - klog.V(3).Infof("io.Writer\n") - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - _, err := io.Copy(b, res.Body) - return err - default: - resultStr, errRead := io.ReadAll(res.Body) - if errRead != nil { - klog.V(1).Infof("io.ReadAll failed. Err: %v\n", errRead) - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return errRead - } - klog.V(5).Infof("json.NewDecoder Raw:\n\n%s\n\n", resultStr) - d := json.NewDecoder(strings.NewReader(string(resultStr))) - klog.V(3).Infof("json.NewDecoder\n") - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return d.Decode(resBody) - } + err = c.HTTPClient.Do(ctx, req, func(res *http.Response) error { + _, err := c.HandleResponse(res, nil, resBody) + return err }) if err != nil { - klog.V(1).Infof("err = c.Client.Do failed. Err: %v\n", err) - klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return err + klog.V(1).Infof("HTTPClient.Do() failed. Err: %v\n", err) + } else { + klog.V(4).Infof("DoStream successful\n") } - - klog.V(3).Infof("prerecorded.DoStream() Succeeded\n") klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - return nil + + return err } -// IsUrl returns true if a string is of a URL format -func IsUrl(str string) bool { +// IsURL returns true if a string is of a URL format +func IsURL(str string) bool { u, err := url.Parse(str) return err == nil && u.Scheme != "" && u.Host != "" } @@ -225,55 +161,35 @@ Input parameters: Output parameters: - resBody: interface{} which will be populated with the response from the server */ -func (c *Client) DoURL(ctx context.Context, url string, options interfaces.PreRecordedTranscriptionOptions, resBody interface{}) error { +func (c *Client) DoURL(ctx context.Context, audioUrl string, options *interfaces.PreRecordedTranscriptionOptions, resBody interface{}) error { klog.V(6).Infof("prerecorded.DoURL() ENTER\n") - klog.V(4).Infof("apiURI: %s\n", url) - // checks - validURL := IsUrl(url) - if !validURL { - klog.V(1).Infof("Invalid URL: %s\n", url) + if !IsURL(audioUrl) { + klog.V(1).Infof("Invalid URL: %s\n", audioUrl) klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") return ErrInvalidInput } - // obtain URL - URI, err := version.GetPrerecordedAPI(ctx, c.cOptions.Host, c.cOptions.ApiVersion, c.cOptions.Path, options) + uri, err := version.GetPrerecordedAPI(ctx, c.Options.Host, c.Options.APIVersion, c.Options.Path, options) if err != nil { - klog.V(1).Infof("version.GetPrerecordedAPI failed. Err: %v\n", err) + klog.V(1).Infof("GetPrerecordedAPI failed. Err: %v\n", err) klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") return err } var buf bytes.Buffer - err = json.NewEncoder(&buf).Encode(urlSource{Url: url}) - if err != nil { + if err := json.NewEncoder(&buf).Encode(urlSource{URL: audioUrl}); err != nil { klog.V(1).Infof("json.NewEncoder().Encode() failed. Err: %v\n", err) klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") return err } - req, err := http.NewRequestWithContext(ctx, "POST", URI, &buf) + req, err := c.SetupRequest(ctx, "POST", uri, &buf) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) + klog.V(1).Infof("SetupRequest failed. Err: %v\n", err) klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") return err } - klog.V(4).Infof("%s %s\n", req.Method, URI) - - if headers, ok := ctx.Value(interfaces.HeadersContext{}).(http.Header); ok { - for k, v := range headers { - for _, v := range v { - klog.V(3).Infof("Custom Header: %s = %s\n", k, v) - req.Header.Add(k, v) - } - } - } - - req.Header.Set("Host", c.cOptions.Host) - req.Header.Set("Accept", "application/json") - req.Header.Set("Authorization", "token "+c.cOptions.ApiKey) - req.Header.Set("User-Agent", interfaces.DgAgent) switch req.Method { case http.MethodPost, http.MethodPatch, http.MethodPut: @@ -281,63 +197,17 @@ func (c *Client) DoURL(ctx context.Context, url string, options interfaces.PreRe req.Header.Set("Content-Type", "application/json") } - err = c.HttpClient.Do(ctx, req, func(res *http.Response) error { - switch res.StatusCode { - case http.StatusOK: - case http.StatusCreated: - case http.StatusNoContent: - case http.StatusBadRequest: - klog.V(4).Infof("HTTP Error Code: %d\n", res.StatusCode) - detail, errBody := io.ReadAll(res.Body) - if err != nil { - klog.V(1).Infof("io.ReadAll failed. Err: %e\n", errBody) - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return &interfaces.StatusError{res} - } - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return fmt.Errorf("%s: %s", res.Status, bytes.TrimSpace(detail)) - default: - return &interfaces.StatusError{res} - } - - if resBody == nil { - klog.V(1).Infof("resBody == nil\n") - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return nil - } - - switch b := resBody.(type) { - case *interfaces.RawResponse: - klog.V(3).Infof("RawResponse\n") - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return res.Write(b) - case io.Writer: - klog.V(3).Infof("io.Writer\n") - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - _, err := io.Copy(b, res.Body) - return err - default: - resultStr, errRead := io.ReadAll(res.Body) - if errRead != nil { - klog.V(1).Infof("io.ReadAll failed. Err: %v\n", errRead) - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return errRead - } - klog.V(5).Infof("json.NewDecoder Raw:\n\n%s\n\n", resultStr) - d := json.NewDecoder(strings.NewReader(string(resultStr))) - klog.V(3).Infof("json.NewDecoder\n") - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return d.Decode(resBody) - } + err = c.HTTPClient.Do(ctx, req, func(res *http.Response) error { + _, err := c.HandleResponse(res, nil, resBody) + return err }) if err != nil { - klog.V(1).Infof("err = c.Client.Do failed. Err: %v\n", err) - klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return err + klog.V(1).Infof("HTTPClient.Do() failed. Err: %v\n", err) + } else { + klog.V(4).Infof("DoURL successful\n") } - - klog.V(3).Infof("prerecorded.DoURL() Succeeded\n") klog.V(6).Infof("prerecorded.DoURL() LEAVE\n") - return nil + + return err } diff --git a/pkg/client/prerecorded/constants.go b/pkg/client/prerecorded/constants.go index 4e78d934..381139d0 100644 --- a/pkg/client/prerecorded/constants.go +++ b/pkg/client/prerecorded/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/prerecorded/init.go b/pkg/client/prerecorded/init.go index b9563d4a..369ed3f8 100644 --- a/pkg/client/prerecorded/init.go +++ b/pkg/client/prerecorded/init.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/prerecorded/types.go b/pkg/client/prerecorded/types.go index cc51b574..5f344e06 100644 --- a/pkg/client/prerecorded/types.go +++ b/pkg/client/prerecorded/types.go @@ -1,17 +1,14 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT package prerecorded import ( - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" + common "github.com/deepgram/deepgram-go-sdk/pkg/client/common" ) // Client implements helper functionality for Prerecorded API type Client struct { - *rest.Client - - cOptions interfaces.ClientOptions + *common.Client } diff --git a/pkg/client/rest/debug.go b/pkg/client/rest/debug.go index fd2daa97..94f1604a 100644 --- a/pkg/client/rest/debug.go +++ b/pkg/client/rest/debug.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -68,7 +68,7 @@ func (d *debugRoundTrip) debugRequest(req *http.Request) string { } // Capture headers - var wc io.WriteCloser = d.newFile("req.headers") + wc := d.newFile("req.headers") b, _ := httputil.DumpRequest(req, false) _, err := wc.Write(b) if err != nil { @@ -95,7 +95,7 @@ func (d *debugRoundTrip) debugResponse(res *http.Response, ext string) { } // Capture headers - var wc io.WriteCloser = d.newFile("res.headers") + wc := d.newFile("res.headers") b, _ := httputil.DumpResponse(res, false) _, err := wc.Write(b) if err != nil { diff --git a/pkg/client/rest/debug/debug.go b/pkg/client/rest/debug/debug.go index 58671238..c1b82248 100644 --- a/pkg/client/rest/debug/debug.go +++ b/pkg/client/rest/debug/debug.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/rest/debug/file.go b/pkg/client/rest/debug/file.go index 780f7c0a..3738217d 100644 --- a/pkg/client/rest/debug/file.go +++ b/pkg/client/rest/debug/file.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/rest/debug/log.go b/pkg/client/rest/debug/log.go index 308d222f..3399b740 100644 --- a/pkg/client/rest/debug/log.go +++ b/pkg/client/rest/debug/log.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/rest/http.go b/pkg/client/rest/http.go index 2ef2567e..f9c6e5a1 100644 --- a/pkg/client/rest/http.go +++ b/pkg/client/rest/http.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -15,12 +15,13 @@ import ( ) // New allocated a Simple HTTP client -func NewHTTPClient(options interfaces.ClientOptions) *HttpClient { +func NewHTTPClient(options *interfaces.ClientOptions) *HTTPClient { + /* #nosec G402 */ tr := &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: options.SkipServerAuth}, } - c := HttpClient{ + c := HTTPClient{ Client: http.Client{ Transport: tr, }, @@ -32,12 +33,7 @@ func NewHTTPClient(options interfaces.ClientOptions) *HttpClient { } // Do performs a simple HTTP-style call -func (c *HttpClient) Do(ctx context.Context, req *http.Request, f func(*http.Response) error) error { - // checks - if ctx == nil { - ctx = context.Background() - } - +func (c *HTTPClient) Do(ctx context.Context, req *http.Request, f func(*http.Response) error) error { // Create debugging context for this round trip d := c.d.newRoundTrip() if d.enabled() { diff --git a/pkg/client/rest/init.go b/pkg/client/rest/init.go index 542792d1..25bc0ca7 100644 --- a/pkg/client/rest/init.go +++ b/pkg/client/rest/init.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/client/rest/rest.go b/pkg/client/rest/rest.go index 14bb992d..73860db8 100644 --- a/pkg/client/rest/rest.go +++ b/pkg/client/rest/rest.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -23,11 +23,11 @@ import ( // NewWithDefaults creates a REST client with default options func NewWithDefaults() *Client { - return New(interfaces.ClientOptions{}) + return New(&interfaces.ClientOptions{}) } // New REST client -func New(options interfaces.ClientOptions) *Client { +func New(options *interfaces.ClientOptions) *Client { err := options.Parse() if err != nil { klog.V(1).Infof("options.Parse failed. Err: %v\n", err) @@ -35,7 +35,7 @@ func New(options interfaces.ClientOptions) *Client { } c := Client{ - HttpClient: NewHTTPClient(options), + HTTPClient: NewHTTPClient(options), Options: options, } return &c @@ -56,7 +56,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{}) req.Header.Set("Host", c.Options.Host) req.Header.Set("Accept", "application/json") - req.Header.Set("Authorization", "token "+c.Options.ApiKey) + req.Header.Set("Authorization", "token "+c.Options.APIKey) req.Header.Set("User-Agent", interfaces.DgAgent) switch req.Method { @@ -67,7 +67,7 @@ func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{}) klog.V(4).Infof("%s %s\n", req.Method, req.URL.String()) - err := c.HttpClient.Do(ctx, req, func(res *http.Response) error { + err := c.HTTPClient.Do(ctx, req, func(res *http.Response) error { switch res.StatusCode { case http.StatusOK: case http.StatusCreated: @@ -78,12 +78,12 @@ func (c *Client) Do(ctx context.Context, req *http.Request, resBody interface{}) if errBody != nil { klog.V(1).Infof("io.ReadAll failed. Err: %e\n", errBody) klog.V(6).Infof("rest.Do() LEAVE\n") - return &interfaces.StatusError{res} + return &interfaces.StatusError{Resp: res} } klog.V(6).Infof("rest.Do() LEAVE\n") return fmt.Errorf("%s: %s", res.Status, bytes.TrimSpace(detail)) default: - return &interfaces.StatusError{res} + return &interfaces.StatusError{Resp: res} } if resBody == nil { diff --git a/pkg/client/rest/types.go b/pkg/client/rest/types.go index a3fcd464..1456aaa2 100644 --- a/pkg/client/rest/types.go +++ b/pkg/client/rest/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -10,19 +10,19 @@ import ( interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" ) -// HttpClient which extends HTTP client -type HttpClient struct { +// HTTPClient which extends HTTP client +type HTTPClient struct { http.Client d *debugContainer UserAgent string - options interfaces.ClientOptions + options *interfaces.ClientOptions } -// Client which extends HttpClient to support REST +// Client which extends HTTPClient to support REST type Client struct { - *HttpClient + *HTTPClient - Options interfaces.ClientOptions + Options *interfaces.ClientOptions } diff --git a/pkg/client/speak/client.go b/pkg/client/speak/client.go index 644092b0..32909281 100644 --- a/pkg/client/speak/client.go +++ b/pkg/client/speak/client.go @@ -11,15 +11,14 @@ import ( "bytes" "context" "encoding/json" - "fmt" - "io" "net/http" + "strings" klog "k8s.io/klog/v2" version "github.com/deepgram/deepgram-go-sdk/pkg/api/version" + common "github.com/deepgram/deepgram-go-sdk/pkg/client/common" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" ) type textSource struct { @@ -33,7 +32,7 @@ Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY */ func NewWithDefaults() *Client { - return New("", interfaces.ClientOptions{}) + return New("", &interfaces.ClientOptions{}) } /* @@ -44,9 +43,9 @@ Input parameters: - apiKey: string containing the Deepgram API key - options: ClientOptions which allows overriding things like hostname, version of the API, etc. */ -func New(apiKey string, options interfaces.ClientOptions) *Client { +func New(apiKey string, options *interfaces.ClientOptions) *Client { if apiKey != "" { - options.ApiKey = apiKey + options.APIKey = apiKey } err := options.Parse() if err != nil { @@ -55,8 +54,7 @@ func New(apiKey string, options interfaces.ClientOptions) *Client { } c := Client{ - Client: rest.New(options), - cOptions: options, + common.New(apiKey, options), } return &c } @@ -72,15 +70,15 @@ Input parameters: Output parameters: - resBody: interface{} which will be populated with the response from the server */ -func (c *Client) DoText(ctx context.Context, text string, options interfaces.SpeakOptions, retValues *map[string]string, resBody interface{}) error { +func (c *Client) DoText(ctx context.Context, text string, options *interfaces.SpeakOptions, keys []string, resBody interface{}) (map[string]string, error) { klog.V(6).Infof("speak.DoText() ENTER\n") // obtain URL for the REST API call - URI, err := version.GetSpeakAPI(ctx, c.cOptions.Host, c.cOptions.ApiVersion, c.cOptions.Path, options) + uri, err := version.GetSpeakAPI(ctx, c.Options.Host, c.Options.APIVersion, c.Options.Path, options) if err != nil { klog.V(1).Infof("version.GetSpeakAPI failed. Err: %v\n", err) klog.V(6).Infof("speak.DoText() LEAVE\n") - return err + return nil, err } var buf bytes.Buffer @@ -88,113 +86,28 @@ func (c *Client) DoText(ctx context.Context, text string, options interfaces.Spe if err != nil { klog.V(1).Infof("json.NewEncoder().Encode() failed. Err: %v\n", err) klog.V(6).Infof("speak.DoURL() LEAVE\n") - return err + return nil, err } - req, err := http.NewRequestWithContext(ctx, "POST", URI, &buf) + req, err := c.SetupRequest(ctx, "POST", uri, strings.NewReader(buf.String())) if err != nil { - klog.V(1).Infof("http.NewRequestWithContext failed. Err: %v\n", err) - klog.V(6).Infof("speak.DoText() LEAVE\n") - return err - } - klog.V(4).Infof("%s %s\n", req.Method, URI) - - if headers, ok := ctx.Value(interfaces.HeadersContext{}).(http.Header); ok { - for k, v := range headers { - for _, v := range v { - klog.V(3).Infof("Custom Header: %s = %s\n", k, v) - req.Header.Add(k, v) - } - } + klog.V(1).Infof("SetupRequest failed. Err: %v\n", err) + klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") + return nil, err } - req.Header.Set("Host", c.cOptions.Host) - req.Header.Set("Accept", "application/json") - req.Header.Set("Authorization", "token "+c.cOptions.ApiKey) - req.Header.Set("User-Agent", interfaces.DgAgent) - - switch req.Method { - case http.MethodPost, http.MethodPatch, http.MethodPut: - klog.V(3).Infof("Content-Type = application/json\n") - req.Header.Set("Content-Type", "application/json") - } - - err = c.HttpClient.Do(ctx, req, func(res *http.Response) error { - switch res.StatusCode { - case http.StatusOK: - case http.StatusCreated: - case http.StatusNoContent: - case http.StatusBadRequest: - klog.V(4).Infof("HTTP Error Code: %d\n", res.StatusCode) - detail, errBody := io.ReadAll(res.Body) - if err != nil { - klog.V(4).Infof("io.ReadAll failed. Err: %e\n", errBody) - klog.V(6).Infof("speak.DoText() LEAVE\n") - return &interfaces.StatusError{res} - } - klog.V(6).Infof("speak.DoText() LEAVE\n") - return fmt.Errorf("%s: %s", res.Status, bytes.TrimSpace(detail)) - default: - return &interfaces.StatusError{res} - } - - if resBody == nil { - klog.V(1).Infof("resBody == nil\n") - klog.V(6).Infof("speak.DoText() LEAVE\n") - return nil - } - - // return values in header - if retValues == nil { - *retValues = make(map[string]string) - } - for k := range *retValues { - value := res.Header.Get(k) - if len(value) > 0 { - klog.V(4).Infof("RetValue Header: %s = %s\n", k, value) - (*retValues)[k] = value - continue - } - value = res.Header.Get("dg-" + k) - if len(value) > 0 { - klog.V(4).Infof("RetValue Header: %s = %s\n", k, value) - (*retValues)[k] = value - continue - } - value = res.Header.Get("x-dg-" + k) - if len(value) > 0 { - klog.V(4).Infof("RetValue Header: %s = %s\n", k, value) - (*retValues)[k] = value - continue - } - } - - switch b := resBody.(type) { - case *interfaces.RawResponse: - klog.V(3).Infof("RawResponse\n") - klog.V(6).Infof("speak.DoText() LEAVE\n") - _, err := io.Copy(b, res.Body) - return err - case io.Writer: - klog.V(3).Infof("io.Writer\n") - klog.V(6).Infof("speak.DoText() LEAVE\n") - _, err := io.Copy(b, res.Body) - return err - default: - klog.V(3).Infof("*io.ReadCloser\n") - klog.V(6).Infof("speak.DoText() LEAVE\n") - _, err := io.Copy(b.(*bytes.Buffer), res.Body) - return err - } + var kv map[string]string + err = c.HTTPClient.Do(ctx, req, func(res *http.Response) error { + kv, err = c.HandleResponse(res, keys, resBody) + return err }) if err != nil { - klog.V(1).Infof("err = c.Client.Do failed. Err: %v\n", err) - klog.V(6).Infof("speak.DoText() LEAVE\n") - return err + klog.V(1).Infof("HTTPClient.Do() failed. Err: %v\n", err) + } else { + klog.V(4).Infof("DoStream successful\n") } + klog.V(6).Infof("prerecorded.DoStream() LEAVE\n") - klog.V(3).Infof("speak.DoText() Succeeded\n") - klog.V(6).Infof("speak.DoText() LEAVE\n") - return nil + return kv, nil } diff --git a/pkg/client/speak/types.go b/pkg/client/speak/types.go index 9219e28f..a406e5f9 100644 --- a/pkg/client/speak/types.go +++ b/pkg/client/speak/types.go @@ -5,13 +5,10 @@ package speak import ( - interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" - rest "github.com/deepgram/deepgram-go-sdk/pkg/client/rest" + common "github.com/deepgram/deepgram-go-sdk/pkg/client/common" ) // Client implements helper functionality for Prerecorded API type Client struct { - *rest.Client - - cOptions interfaces.ClientOptions + *common.Client } diff --git a/pkg/common/constants.go b/pkg/common/constants.go index 8ace653d..4e5a9dba 100644 --- a/pkg/common/constants.go +++ b/pkg/common/constants.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/common/init.go b/pkg/common/init.go index c0cfcd5c..bcfeb546 100644 --- a/pkg/common/init.go +++ b/pkg/common/init.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/pkg/common/interfaces.go b/pkg/common/interfaces.go index e4af3f8e..99b4813a 100644 --- a/pkg/common/interfaces.go +++ b/pkg/common/interfaces.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -10,8 +10,8 @@ type Config interface { // Getters GetHost() string - GetApiKey() string - GetApiVersion() string + GetAPIKey() string + GetAPIVersion() string GetPath() string GetOnPrem() bool diff --git a/pkg/common/types.go b/pkg/common/types.go index 356cd926..f1481acb 100644 --- a/pkg/common/types.go +++ b/pkg/common/types.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT diff --git a/tests/daily_test/prerecorded_test.go b/tests/daily_test/prerecorded_test.go new file mode 100644 index 00000000..1d5f474b --- /dev/null +++ b/tests/daily_test/prerecorded_test.go @@ -0,0 +1,173 @@ +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +package daily_test + +import ( + "context" + "crypto/sha256" + "encoding/json" + "fmt" + "os" + "path" + "runtime" + "strings" + "testing" + + prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1" + interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" + client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded" + + utils "github.com/deepgram/deepgram-go-sdk/tests/utils" +) + +const ( + model string = "2-general-nova" + + url string = "https://static.deepgram.com/examples/Bueller-Life-moves-pretty-fast.wav" +) + +const ( + FromURLSmartFormat = "Yep. I said it before and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it." + FromURLSummarize = "Yep. I said it before, and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it." +) + +func init() { + _, filename, _, _ := runtime.Caller(0) + dir := path.Join(path.Dir(filename), "../..") // change to suit test file location + err := os.Chdir(dir) + if err != nil { + panic(err) + } +} + +func TestDaily_Prerecorded(t *testing.T) { + t.Run("FromURL-SmartFormat", func(t *testing.T) { + // context + ctx := context.Background() + + // send stream to Deepgram + options := &interfaces.PreRecordedTranscriptionOptions{ + Model: "nova-2", + SmartFormat: true, + } + + // create a Deepgram client + c := client.NewWithDefaults() + dg := prerecorded.New(c) + + // send the URL to Deepgram + res, err := dg.FromURL(ctx, url, options) + if err != nil { + t.Errorf("FromURL(%v) Err: %v", options, err) + } + + // save the options + data, err := json.Marshal(options) + if err != nil { + t.Errorf("json.Marshal Err: %v", err) + } + + sha256sum := fmt.Sprintf("%x", sha256.Sum256(data)) + filename := fmt.Sprintf("tests/response_data/%s.cmd", strings.ReplaceAll(t.Name(), "/", "_")) + err = utils.SaveMetadataString(filename, sha256sum) + if err != nil { + t.Errorf("dataFile.WriteString Err: %v", err) + } + + filename = fmt.Sprintf("tests/response_data/%s-options.json", sha256sum) + err = utils.SaveMetadataBytes(filename, data) + if err != nil { + t.Errorf("dataFile.WriteString Err: %v", err) + } + + // save the response + data, err = json.Marshal(res) + if err != nil { + t.Errorf("json.Marshal Err: %v", err) + } + + filename = fmt.Sprintf("tests/response_data/%s-response.json", sha256sum) + err = utils.SaveMetadataBytes(filename, data) + if err != nil { + t.Errorf("dataFile.WriteString Err: %v", err) + } + + // check the response + for _, value := range res.Metadata.ModelInfo { + if strings.Compare(model, value.Name) != 0 { + t.Errorf("%s: %s != %s", t.Name(), model, value.Name) + } + } + transcript := res.Results.Channels[0].Alternatives[0].Transcript + if strings.Compare(FromURLSmartFormat, transcript) != 0 { + t.Errorf("%s: %s != %s", t.Name(), FromURLSmartFormat, transcript) + } + }) +} + +func TestDaily_Prerecorded_summary(t *testing.T) { + t.Run("FromURL-Summarize", func(t *testing.T) { + // context + ctx := context.Background() + + // send stream to Deepgram + options := &interfaces.PreRecordedTranscriptionOptions{ + Model: "nova-2", + Summarize: "v2", + } + + // create a Deepgram client + c := client.NewWithDefaults() + dg := prerecorded.New(c) + + // send the URL to Deepgram + res, err := dg.FromURL(ctx, url, options) + if err != nil { + t.Errorf("FromURL(%v) Err: %v", options, err) + } + + // save the options + data, err := json.Marshal(options) + if err != nil { + t.Errorf("json.Marshal Err: %v", err) + } + + sha256sum := fmt.Sprintf("%x", sha256.Sum256(data)) + filename := fmt.Sprintf("tests/response_data/%s.cmd", strings.ReplaceAll(t.Name(), "/", "_")) + err = utils.SaveMetadataString(filename, sha256sum) + if err != nil { + t.Errorf("dataFile.WriteString Err: %v", err) + } + + filename = fmt.Sprintf("tests/response_data/%s-options.json", sha256sum) + err = utils.SaveMetadataBytes(filename, data) + if err != nil { + t.Errorf("dataFile.WriteString Err: %v", err) + } + + // save the response + data, err = json.Marshal(res) + if err != nil { + t.Errorf("json.Marshal Err: %v", err) + } + + filename = fmt.Sprintf("tests/response_data/%s-response.json", sha256sum) + err = utils.SaveMetadataBytes(filename, data) + if err != nil { + t.Errorf("dataFile.WriteString Err: %v", err) + } + + // check the response + for _, value := range res.Metadata.ModelInfo { + if strings.Compare(model, value.Name) != 0 { + t.Errorf("%s: %s != %s", t.Name(), model, value.Name) + } + } + summary := res.Results.Summary.Short + if strings.Compare(FromURLSummarize, summary) != 0 { + t.Errorf("%s: %s != %s", t.Name(), FromURLSummarize, summary) + } + }) +} diff --git a/tests/edge_cases/keepalive/main.go b/tests/edge_cases/keepalive/main.go index fc9a380a..9e002c9a 100644 --- a/tests/edge_cases/keepalive/main.go +++ b/tests/edge_cases/keepalive/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -22,13 +22,13 @@ func main() { ctx := context.Background() // set the Transcription options - tOptions := interfaces.LiveTranscriptionOptions{ + tOptions := &interfaces.LiveTranscriptionOptions{ Language: "en-US", Punctuate: true, } // create a Deepgram client - cOptions := interfaces.ClientOptions{ + cOptions := &interfaces.ClientOptions{ EnableKeepAlive: true, } diff --git a/tests/edge_cases/timeout/main.go b/tests/edge_cases/timeout/main.go index 40328d8c..3390a939 100644 --- a/tests/edge_cases/timeout/main.go +++ b/tests/edge_cases/timeout/main.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -22,7 +22,7 @@ func main() { ctx := context.Background() // set the Transcription options - tOptions := interfaces.LiveTranscriptionOptions{ + tOptions := &interfaces.LiveTranscriptionOptions{ Language: "en-US", Punctuate: true, } diff --git a/tests/response_data/642c86c60eedbc4af873632b86d68164149599cf97131d81a63a2711f0563d37-options.json b/tests/response_data/642c86c60eedbc4af873632b86d68164149599cf97131d81a63a2711f0563d37-options.json new file mode 100755 index 00000000..a1d7c79f --- /dev/null +++ b/tests/response_data/642c86c60eedbc4af873632b86d68164149599cf97131d81a63a2711f0563d37-options.json @@ -0,0 +1 @@ +{"model":"nova-2","summarize":"v2"} \ No newline at end of file diff --git a/tests/response_data/642c86c60eedbc4af873632b86d68164149599cf97131d81a63a2711f0563d37-response.json b/tests/response_data/642c86c60eedbc4af873632b86d68164149599cf97131d81a63a2711f0563d37-response.json new file mode 100755 index 00000000..4aab9149 --- /dev/null +++ b/tests/response_data/642c86c60eedbc4af873632b86d68164149599cf97131d81a63a2711f0563d37-response.json @@ -0,0 +1 @@ +{"metadata":{"transaction_key":"deprecated","request_id":"7644cc73-0901-4363-a99d-2fcbf9486ef4","sha256":"5324da68ede209a16ac69a38e8cd29cee4d754434a041166cda3a1f5e0b24566","created":"2024-05-10T19:39:37.077Z","duration":17.566313,"channels":1,"models":["1abfe86b-e047-4eed-858a-35e5625b41ee"],"model_info":{"1abfe86b-e047-4eed-858a-35e5625b41ee":{"name":"2-general-nova","version":"2024-01-06.5664","arch":"nova-2"}},"summary_info":{"model_uuid":"67875a7f-c9c4-48a0-aa55-5bdb8a91c34a"}},"results":{"channels":[{"alternatives":[{"transcript":"Yep. I said it before, and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it.","confidence":0.9993993,"words":[{"word":"yep","start":5.52,"end":6.02,"confidence":0.9983343,"punctuated_word":"Yep."},{"word":"i","start":7.095,"end":7.2549996,"confidence":0.86866945,"punctuated_word":"I"},{"word":"said","start":7.2549996,"end":7.415,"confidence":0.9355344,"punctuated_word":"said"},{"word":"it","start":7.415,"end":7.495,"confidence":0.9991001,"punctuated_word":"it"},{"word":"before","start":7.495,"end":7.975,"confidence":0.75923455,"punctuated_word":"before,"},{"word":"and","start":7.975,"end":8.135,"confidence":0.9998159,"punctuated_word":"and"},{"word":"i'll","start":8.135,"end":8.295,"confidence":0.9995924,"punctuated_word":"I'll"},{"word":"say","start":8.295,"end":8.455,"confidence":0.9993993,"punctuated_word":"say"},{"word":"it","start":8.455,"end":8.615,"confidence":0.9994319,"punctuated_word":"it"},{"word":"again","start":8.615,"end":9.115,"confidence":0.9314046,"punctuated_word":"again."},{"word":"life","start":9.975,"end":10.375,"confidence":0.99926835,"punctuated_word":"Life"},{"word":"moves","start":10.375,"end":10.695,"confidence":0.99976486,"punctuated_word":"moves"},{"word":"pretty","start":10.695,"end":11.014999,"confidence":0.9997489,"punctuated_word":"pretty"},{"word":"fast","start":11.014999,"end":11.514999,"confidence":0.9996352,"punctuated_word":"fast."},{"word":"you","start":11.975,"end":12.215,"confidence":0.957061,"punctuated_word":"You"},{"word":"don't","start":12.215,"end":12.455,"confidence":0.99992,"punctuated_word":"don't"},{"word":"stop","start":12.455,"end":12.695,"confidence":0.99986804,"punctuated_word":"stop"},{"word":"and","start":12.695,"end":12.855,"confidence":0.9994267,"punctuated_word":"and"},{"word":"look","start":12.855,"end":13.014999,"confidence":0.9998821,"punctuated_word":"look"},{"word":"around","start":13.014999,"end":13.334999,"confidence":0.9997942,"punctuated_word":"around"},{"word":"once","start":13.334999,"end":13.575,"confidence":0.9990452,"punctuated_word":"once"},{"word":"in","start":13.575,"end":13.735,"confidence":0.9969682,"punctuated_word":"in"},{"word":"a","start":13.735,"end":13.815,"confidence":0.9727506,"punctuated_word":"a"},{"word":"while","start":13.815,"end":14.315,"confidence":0.95074844,"punctuated_word":"while,"},{"word":"you","start":14.561313,"end":14.7213125,"confidence":0.99757296,"punctuated_word":"you"},{"word":"could","start":14.7213125,"end":14.961312,"confidence":0.99941814,"punctuated_word":"could"},{"word":"miss","start":14.961312,"end":15.461312,"confidence":0.99948657,"punctuated_word":"miss"},{"word":"it","start":17.281313,"end":17.566313,"confidence":0.99636185,"punctuated_word":"it."}]}]}],"summary":{"short":"Yep. I said it before, and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it.","result":"success"}}} \ No newline at end of file diff --git a/tests/response_data/TestDaily_Prerecorded_FromURL-SmartFormat.cmd b/tests/response_data/TestDaily_Prerecorded_FromURL-SmartFormat.cmd new file mode 100755 index 00000000..4ffe91e6 --- /dev/null +++ b/tests/response_data/TestDaily_Prerecorded_FromURL-SmartFormat.cmd @@ -0,0 +1 @@ +bfae00d50d521f470ff9d1943f32225fcfeffe51eff47984886930b71fae0929 \ No newline at end of file diff --git a/tests/response_data/TestDaily_Prerecorded_summary_FromURL-Summarize.cmd b/tests/response_data/TestDaily_Prerecorded_summary_FromURL-Summarize.cmd new file mode 100755 index 00000000..f2f26623 --- /dev/null +++ b/tests/response_data/TestDaily_Prerecorded_summary_FromURL-Summarize.cmd @@ -0,0 +1 @@ +642c86c60eedbc4af873632b86d68164149599cf97131d81a63a2711f0563d37 \ No newline at end of file diff --git a/tests/response_data/bfae00d50d521f470ff9d1943f32225fcfeffe51eff47984886930b71fae0929-options.json b/tests/response_data/bfae00d50d521f470ff9d1943f32225fcfeffe51eff47984886930b71fae0929-options.json new file mode 100755 index 00000000..4fc4baa3 --- /dev/null +++ b/tests/response_data/bfae00d50d521f470ff9d1943f32225fcfeffe51eff47984886930b71fae0929-options.json @@ -0,0 +1 @@ +{"model":"nova-2","smart_format":true} \ No newline at end of file diff --git a/tests/response_data/bfae00d50d521f470ff9d1943f32225fcfeffe51eff47984886930b71fae0929-response.json b/tests/response_data/bfae00d50d521f470ff9d1943f32225fcfeffe51eff47984886930b71fae0929-response.json new file mode 100755 index 00000000..0c05fb56 --- /dev/null +++ b/tests/response_data/bfae00d50d521f470ff9d1943f32225fcfeffe51eff47984886930b71fae0929-response.json @@ -0,0 +1 @@ +{"metadata":{"transaction_key":"deprecated","request_id":"af3c350b-e0b4-45dd-91cc-78bf43694cab","sha256":"5324da68ede209a16ac69a38e8cd29cee4d754434a041166cda3a1f5e0b24566","created":"2024-05-10T19:39:36.327Z","duration":17.566313,"channels":1,"models":["30089e05-99d1-4376-b32e-c263170674af"],"model_info":{"30089e05-99d1-4376-b32e-c263170674af":{"name":"2-general-nova","version":"2024-01-09.29447","arch":"nova-2"}}},"results":{"channels":[{"alternatives":[{"transcript":"Yep. I said it before and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it.","confidence":0.998215,"words":[{"word":"yep","start":5.52,"end":6.02,"confidence":0.99847394,"punctuated_word":"Yep."},{"word":"i","start":7.095,"end":7.2549996,"confidence":0.84308124,"punctuated_word":"I"},{"word":"said","start":7.2549996,"end":7.415,"confidence":0.9382116,"punctuated_word":"said"},{"word":"it","start":7.415,"end":7.495,"confidence":0.9984346,"punctuated_word":"it"},{"word":"before","start":7.495,"end":7.975,"confidence":0.9997732,"punctuated_word":"before"},{"word":"and","start":7.975,"end":8.135,"confidence":0.5573371,"punctuated_word":"and"},{"word":"i'll","start":8.135,"end":8.295,"confidence":0.998215,"punctuated_word":"I'll"},{"word":"say","start":8.295,"end":8.455,"confidence":0.9986902,"punctuated_word":"say"},{"word":"it","start":8.455,"end":8.615,"confidence":0.99852645,"punctuated_word":"it"},{"word":"again","start":8.615,"end":9.115,"confidence":0.8480171,"punctuated_word":"again."},{"word":"life","start":9.975,"end":10.295,"confidence":0.99577326,"punctuated_word":"Life"},{"word":"moves","start":10.295,"end":10.695,"confidence":0.99854964,"punctuated_word":"moves"},{"word":"pretty","start":10.695,"end":11.014999,"confidence":0.99935335,"punctuated_word":"pretty"},{"word":"fast","start":11.014999,"end":11.514999,"confidence":0.99927515,"punctuated_word":"fast."},{"word":"you","start":11.975,"end":12.215,"confidence":0.9485283,"punctuated_word":"You"},{"word":"don't","start":12.215,"end":12.455,"confidence":0.99980193,"punctuated_word":"don't"},{"word":"stop","start":12.455,"end":12.695,"confidence":0.9998211,"punctuated_word":"stop"},{"word":"and","start":12.695,"end":12.855,"confidence":0.99849033,"punctuated_word":"and"},{"word":"look","start":12.855,"end":13.094999,"confidence":0.99972147,"punctuated_word":"look"},{"word":"around","start":13.094999,"end":13.334999,"confidence":0.99948287,"punctuated_word":"around"},{"word":"once","start":13.334999,"end":13.575,"confidence":0.9980332,"punctuated_word":"once"},{"word":"in","start":13.575,"end":13.735,"confidence":0.9971307,"punctuated_word":"in"},{"word":"a","start":13.735,"end":13.815,"confidence":0.9540613,"punctuated_word":"a"},{"word":"while","start":13.815,"end":14.315,"confidence":0.97138655,"punctuated_word":"while,"},{"word":"you","start":14.561313,"end":14.7213125,"confidence":0.98991334,"punctuated_word":"you"},{"word":"could","start":14.7213125,"end":14.961312,"confidence":0.99663407,"punctuated_word":"could"},{"word":"miss","start":14.961312,"end":15.461312,"confidence":0.99736553,"punctuated_word":"miss"},{"word":"it","start":17.281313,"end":17.566313,"confidence":0.989954,"punctuated_word":"it."}],"paragraphs":{"transcript":"\nYep. I said it before and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it.","paragraphs":[{"sentences":[{"text":"Yep.","start":5.52,"end":6.02},{"text":"I said it before and I'll say it again.","start":7.095,"end":9.115},{"text":"Life moves pretty fast.","start":9.975,"end":11.514999},{"text":"You don't stop and look around once in a while, you could miss it.","start":11.975,"end":17.566313}],"num_words":28,"start":5.52,"end":17.566313}]}}]}]}} \ No newline at end of file diff --git a/tests/legacy/mocks.go b/tests/unit_test/mocks.go similarity index 99% rename from tests/legacy/mocks.go rename to tests/unit_test/mocks.go index 3aa0d17d..c9196577 100644 --- a/tests/legacy/mocks.go +++ b/tests/unit_test/mocks.go @@ -1,11 +1,12 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT package deepgram_test +/* #nosec G101 */ const MockAPIKey = "m0ckap1k3y0bbc125dac7f40ed3eb0ed232a2ff8" -const MockRequestId = "44617f75-5053-4fb1-a30d-7714eee9d414" +const MockRequestID = "44617f75-5053-4fb1-a30d-7714eee9d414" const MockAudioURL = "https://fake.deepgram.test.mockaudio.wav" var MockBasicPreRecordedResponse = `{ diff --git a/tests/legacy/prerecorded_test.go b/tests/unit_test/prerecorded_test.go similarity index 54% rename from tests/legacy/prerecorded_test.go rename to tests/unit_test/prerecorded_test.go index b960c3b6..381ebf04 100644 --- a/tests/legacy/prerecorded_test.go +++ b/tests/unit_test/prerecorded_test.go @@ -1,4 +1,4 @@ -// Copyright 2023 Deepgram SDK contributors. All Rights Reserved. +// Copyright 2023-2024 Deepgram SDK contributors. All Rights Reserved. // Use of this source code is governed by a MIT license that can be found in the LICENSE file. // SPDX-License-Identifier: MIT @@ -6,29 +6,55 @@ package deepgram_test import ( "context" + "crypto/sha256" "encoding/json" "fmt" "net/http" + "os" + "path" + "runtime" + "strings" "testing" + "github.com/gorilla/schema" "github.com/jarcoal/httpmock" prerecorded "github.com/deepgram/deepgram-go-sdk/pkg/api/prerecorded/v1" interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" client "github.com/deepgram/deepgram-go-sdk/pkg/client/prerecorded" + + utils "github.com/deepgram/deepgram-go-sdk/tests/utils" +) + +const ( + model string = "2-general-nova" +) + +const ( + FromURLSmartFormat = "Yep. I said it before and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it." + FromURLSummarize = "Yep. I said it before, and I'll say it again. Life moves pretty fast. You don't stop and look around once in a while, you could miss it." ) -func TestPrerecordedFromURL(t *testing.T) { +func init() { + _, filename, _, _ := runtime.Caller(0) + dir := path.Join(path.Dir(filename), "../..") // change to suit test file location + err := os.Chdir(dir) + if err != nil { + panic(err) + } +} + +func Test_PrerecordedFromURL(t *testing.T) { httpmock.Activate() defer httpmock.DeactivateAndReset() const preRecordedEndPoint = "https://api.deepgram.com/v1/listen" - const betaEndPoint = "https://beta.api.deepgram.com/v1/listen" + // const betaEndPoint = "https://beta.api.deepgram.com/v1/listen" // Specify query params that are acceptable. A nil means no check var acceptParams = map[string][]string{ "model": nil, - "tier": {"nova", "enhanced", "base"}, + "tier": {"2-general-nova", "nova-2", "nova", "enhanced", "base"}, "version": nil, "language": {"da", "en", "en-AU", "en-GB", "en-IN", "en-NZ", "en-US", "es", "es-419", "fr", "fr-CA", "hi", "hi-Latn", "id", @@ -68,7 +94,7 @@ func TestPrerecordedFromURL(t *testing.T) { return httpmock.NewJsonResponse(401, map[string]any{ "err_code": "INVALID_AUTH", "err_msg": "Invalid credentials.", - "request_id": MockRequestId}) + "request_id": MockRequestID}) } // Content checking @@ -78,7 +104,7 @@ func TestPrerecordedFromURL(t *testing.T) { return httpmock.NewJsonResponse(400, map[string]any{ "err_code": "Bad Request", "err_msg": "Content-type was application/json, but we could not process the JSON payload.", - "request_id": MockRequestId}) + "request_id": MockRequestID}) } // Param checking @@ -106,65 +132,93 @@ func TestPrerecordedFromURL(t *testing.T) { } // Based on query parameters, send Mock responses - var resp *http.Response - if options.Get("summarize") == "v2" { - resp = httpmock.NewStringResponse(200, MockSummarizeV2Response) - } else if options.Get("summarize") == "true" { - resp = httpmock.NewStringResponse(200, MockSummarizeV1Response) - } else { - resp = httpmock.NewStringResponse(200, MockBasicPreRecordedResponse) + var optionStruct interfaces.PreRecordedTranscriptionOptions + + decoder := schema.NewDecoder() + err = decoder.Decode(&optionStruct, r.URL.Query()) + if err != nil { + t.Errorf("error decoding options: %s", err) + } + + // save the options + data, err := json.Marshal(optionStruct) + if err != nil { + t.Errorf("json.Marshal Err: %v", err) } - return resp, nil + sha256sum := fmt.Sprintf("%x", sha256.Sum256(data)) + filename := fmt.Sprintf("tests/response_data/%s-response.json", sha256sum) + + // Check if the file exists + if _, err := os.Stat(filename); !os.IsNotExist(err) { + result, err := utils.ReadMetadataString(filename) + if err == nil { + resp := httpmock.NewStringResponse(200, result) + return resp, nil + } else { + t.Errorf("error reading response file: %s", err) + } + } + + return httpmock.NewStringResponse(404, ""), nil } // Register Handlers to endpoints httpmock.RegisterResponder("POST", preRecordedEndPoint, preRecordedFromURLHandler) - httpmock.RegisterResponder("POST", betaEndPoint, preRecordedFromURLHandler) + // httpmock.RegisterResponder("POST", betaEndPoint, preRecordedFromURLHandler) t.Run("Test Basic PreRecordedFromURL", func(t *testing.T) { - c := client.New(MockAPIKey, interfaces.ClientOptions{}) - httpmock.ActivateNonDefault(&c.Client.HttpClient.Client) + c := client.New(MockAPIKey, &interfaces.ClientOptions{}) + httpmock.ActivateNonDefault(&c.Client.HTTPClient.Client) dg := prerecorded.New(c) - _, err := dg.FromURL( + + res, err := dg.FromURL( context.Background(), MockAudioURL, - interfaces.PreRecordedTranscriptionOptions{}) - + &interfaces.PreRecordedTranscriptionOptions{ + Model: "nova-2", + SmartFormat: true, + }) if err != nil { t.Errorf("should succeed, but got %s", err) } - }) - - t.Run("Test PreRecordedFromURL with summarize v1", func(t *testing.T) { - c := client.New(MockAPIKey, interfaces.ClientOptions{}) - httpmock.ActivateNonDefault(&c.Client.HttpClient.Client) - dg := prerecorded.New(c) - _, err := dg.FromURL( - context.Background(), - MockAudioURL, - interfaces.PreRecordedTranscriptionOptions{ - Summarize: "true", - }) - if err != nil { - t.Errorf("Summarize v1 should succeed, but got %s", err) + // check the response + for _, value := range res.Metadata.ModelInfo { + if strings.Compare(model, value.Name) != 0 { + t.Errorf("%s: %s != %s", t.Name(), model, value.Name) + } + } + transcript := res.Results.Channels[0].Alternatives[0].Transcript + if strings.Compare(FromURLSmartFormat, transcript) != 0 { + t.Errorf("%s: %s != %s", t.Name(), FromURLSmartFormat, transcript) } }) t.Run("Test PreRecordedFromURL with summarize v2", func(t *testing.T) { - c := client.New(MockAPIKey, interfaces.ClientOptions{}) - httpmock.ActivateNonDefault(&c.Client.HttpClient.Client) + c := client.New(MockAPIKey, &interfaces.ClientOptions{}) + httpmock.ActivateNonDefault(&c.Client.HTTPClient.Client) dg := prerecorded.New(c) - _, err := dg.FromURL( + res, err := dg.FromURL( context.Background(), MockAudioURL, - interfaces.PreRecordedTranscriptionOptions{ + &interfaces.PreRecordedTranscriptionOptions{ + Model: "nova-2", Summarize: "v2", }) - if err != nil { t.Errorf("Summarize v2 should succeed, but got %s", err) } + + // check the response + for _, value := range res.Metadata.ModelInfo { + if strings.Compare(model, value.Name) != 0 { + t.Errorf("%s: %s != %s", t.Name(), model, value.Name) + } + } + summary := res.Results.Summary.Short + if strings.Compare(FromURLSummarize, summary) != 0 { + t.Errorf("%s: %s != %s", t.Name(), FromURLSummarize, summary) + } }) } diff --git a/tests/utils/utils.go b/tests/utils/utils.go new file mode 100644 index 00000000..095fac85 --- /dev/null +++ b/tests/utils/utils.go @@ -0,0 +1,103 @@ +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +package utils + +import ( + "errors" + "fmt" + "os" + "path/filepath" + "strings" +) + +func GetQueryParams(url string) string { + pos := strings.Index(url, "?") + if pos == -1 { + return "" + } + return url[pos+1:] +} + +func CreateDirs(fullpath string) error { + basedir := filepath.Dir(fullpath) + return os.MkdirAll(basedir, 0o700) +} + +func SaveMetadataBytes(filename string, data []byte) error { + return SaveMetadataString(filename, string(data)) +} + +func SaveMetadataString(filename, data string) error { + // create directory + err := CreateDirs(filename) + if err != nil { + return err + } + + // save metadata + dataFile, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o700) + if err != nil { + return err + } + _, err = dataFile.WriteString(data) + if err != nil { + return err + } + dataFile.Close() + + return err +} + +func ReadMetadataString(filename string) (string, error) { + byData, err := os.ReadFile(filename) + if err != nil { + return "", err + } + return string(byData), err +} + +func ReadMetadataBytes(filename string) ([]byte, error) { + return os.ReadFile(filename) +} + +func StringMatchFailure(expected, actual string) error { + if len(expected) != len(actual) { + return errors.New("string lengths don't match") + } + + found := -1 + for i := 0; i < len(expected); i++ { + expectedPos := expected[i:1] + actualPos := actual[i:1] + if expectedPos != actualPos { + found = i + break + } + } + + // expected + for i := 0; i < len(expected); i++ { + expectedPos := expected[i:1] + if i == found { + fmt.Fprintf(os.Stdout, "\033[0;31m %s", expectedPos) + } else { + fmt.Fprintf(os.Stdout, "\033[0m %s", expectedPos) + } + } + fmt.Printf("\n") + + // actual + for i := 0; i < len(expected); i++ { + actualPos := actual[i:1] + if i == found { + fmt.Fprintf(os.Stdout, "\033[0;31m %s", actualPos) + } else { + fmt.Fprintf(os.Stdout, "\033[0m %s", actualPos) + } + } + fmt.Printf("\n") + + return nil +}