From e5fc2e264fac557cce25898597277b1bf6e54b25 Mon Sep 17 00:00:00 2001 From: pjdufour Date: Tue, 8 Mar 2022 11:57:12 -0700 Subject: [PATCH 01/10] update to go 1.17 --- .circleci/config.yml | 116 ++-- .eslintignore | 10 - .eslintrc | 35 -- .gitignore | 18 +- LICENSE | 2 +- Makefile | 105 ++-- README.md | 105 ++-- SECURITY.md | 3 + cmd/gss.global.js/main.go | 49 -- cmd/gss.mod.js/main.go | 49 -- cmd/gss/main.go | 18 +- examples/js/index.global.js | 58 -- examples/js/index.mod.js | 57 -- go.mod | 45 ++ go.sum | 820 ++++++++++++++++++++++++++++ js/gss.test.js | 310 ----------- package.json | 40 -- pkg/bson/Unmarshal.go | 5 +- pkg/bson/UnmarshalType.go | 8 +- pkg/bson/bson.go | 3 +- pkg/cli/CheckConfig.go | 7 +- pkg/cli/formats/NewCommand.go | 7 +- pkg/cli/input/CheckInputConfig.go | 11 +- pkg/cli/input/input.go | 2 +- pkg/cli/output/CheckOutputConfig.go | 12 +- pkg/cli/output/output.go | 2 +- pkg/fmt/Writer.go | 11 +- pkg/gob/Write.go | 9 +- pkg/gob/Writer.go | 13 +- pkg/gob/gob.go | 2 +- pkg/gss/Convert.go | 7 +- pkg/gss/DeserializeBytes.go | 13 +- pkg/gss/DeserializeReader.go | 13 +- pkg/gss/GetType.go | 5 +- pkg/gss/SerializeBytes.go | 4 +- pkg/gss/SerializeBytes_test.go | 3 +- pkg/gss/gss.go | 8 +- pkg/gssjs/Convert.go | 50 -- pkg/gssjs/Deserialize.go | 34 -- pkg/gssjs/Exports.go | 59 -- pkg/gssjs/Serialize.go | 34 -- pkg/gssjs/Serialize_test.go | 166 ------ pkg/gssjs/gssjs.go | 41 -- pkg/iterator/Iterator.go | 10 +- pkg/json/Unmarshal.go | 11 +- pkg/json/UnmarshalType.go | 12 +- pkg/json/json.go | 2 +- pkg/jsonl/Iterator.go | 7 +- pkg/jsonl/Marshal.go | 5 +- pkg/jsonl/Write.go | 9 +- pkg/jsonl/Writer.go | 15 +- pkg/jsonl/jsonl.go | 2 +- pkg/mapper/Marshal.go | 11 +- pkg/mapper/Unmarshal.go | 15 +- pkg/mapper/UnmarshalFieldValue.go | 5 +- pkg/mapper/UnmarshalMap.go | 15 +- pkg/mapper/UnmarshalSlice.go | 15 +- pkg/properties/Read.go | 5 +- pkg/properties/Write.go | 14 +- pkg/properties/properties.go | 2 +- pkg/serializer/Serializer.go | 18 +- pkg/sv/Iterator.go | 10 +- pkg/sv/Read.go | 5 +- pkg/sv/ToRowFromValue.go | 10 +- pkg/sv/Write.go | 28 +- pkg/sv/Writer.go | 20 +- pkg/tagger/KeyValue.go | 4 +- pkg/tagger/Lookup.go | 5 +- pkg/tags/Iterator.go | 9 +- pkg/tags/Marshal.go | 41 +- pkg/tags/Read.go | 5 +- pkg/tags/Write.go | 11 +- pkg/tags/Writer.go | 13 +- pkg/tags/tags.go | 3 +- pkg/toml/Marshal.go | 4 +- pkg/toml/Unmarshal.go | 3 +- pkg/toml/UnmarshalType.go | 3 +- pkg/toml/toml.go | 3 +- pkg/tools/tools.go | 23 + pkg/writer/Writer.go | 3 +- pkg/yaml/Unmarshal.go | 13 +- pkg/yaml/UnmarshalType.go | 21 +- pkg/yaml/yaml.go | 2 +- scripts/build-release | 32 ++ scripts/test.sh | 21 +- testEnvironment.js | 28 - 86 files changed, 1329 insertions(+), 1533 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc create mode 100644 SECURITY.md delete mode 100644 cmd/gss.global.js/main.go delete mode 100644 cmd/gss.mod.js/main.go delete mode 100644 examples/js/index.global.js delete mode 100644 examples/js/index.mod.js create mode 100644 go.mod create mode 100644 go.sum delete mode 100644 js/gss.test.js delete mode 100644 package.json delete mode 100644 pkg/gssjs/Convert.go delete mode 100644 pkg/gssjs/Deserialize.go delete mode 100644 pkg/gssjs/Exports.go delete mode 100644 pkg/gssjs/Serialize.go delete mode 100644 pkg/gssjs/Serialize_test.go delete mode 100644 pkg/gssjs/gssjs.go create mode 100644 pkg/tools/tools.go create mode 100644 scripts/build-release delete mode 100644 testEnvironment.js diff --git a/.circleci/config.yml b/.circleci/config.yml index 356cc6d..a5650cc 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,51 +1,39 @@ -version: 2.1 +# ================================================================= +# +# Copyright (C) 2022 Spatial Current, Inc. - All Rights Reserved +# Released as open source under the MIT License. See LICENSE file. +# +# ================================================================= + +version: "2.1" + executors: - base: + # `main` uses the `cimg/go:1.17` docker image. + main: docker: - - image: circleci/golang:1.12-node - working_directory: /go/src/github.com/spatialcurrent/go-simple-serializer + - image: cimg/go:1.17 + jobs: - pre_deps_golang: - executor: base - steps: - - checkout - - run: make deps_go - - run: sudo chown -R circleci /go/src - - save_cache: - key: v1-go-src-{{ .Branch }}-{{ .Revision }} - paths: - - /go/src + + # `test_go` tests the source code. test_go: - executor: base + executor: main steps: - - run: sudo chown -R circleci /go/src - - restore_cache: - keys: - - v1-go-src-{{ .Branch }}-{{ .Revision }} - - run: make deps_go_test - - run: make test_go + - checkout + - run: make fmt - run: make imports + - run: make test_go - run: git diff --exit-code + + # `test_cli` tests the executable. test_cli: - executor: base + executor: main steps: - - run: sudo chown -R circleci /go/src - - restore_cache: - keys: - - v1-go-src-{{ .Branch }}-{{ .Revision }} - - run: make deps_go_test - - run: make install + - checkout + - run: make tidy + - run: make bin/gss - run: make test_cli - test_javascript: - executor: base - steps: - - run: sudo chown -R circleci /go/src - - restore_cache: - keys: - - v1-go-src-{{ .Branch }}-{{ .Revision }} - - run: make deps_gopherjs - - run: make deps_javascript - - run: npm run test:clean + examples: executor: base steps: @@ -58,32 +46,41 @@ jobs: - run: npm run build:clean - run: make run_example_c - run: make run_example_cpp - - run: make run_example_javascript - run: make run_example_python - build_cli: - executor: base + + # `build` builds the executables + build: + executor: main steps: - - run: sudo chown -R circleci /go/src - - restore_cache: - keys: - - v1-go-src-{{ .Branch }}-{{ .Revision }} - - run: go get github.com/inconshreveable/mousetrap # for windows CLI builds - - run: make build_cli + - checkout + + # Update apt cache + - run: sudo apt-get update + + # Tidy dependencies + - run: make tidy + + # Build Executeables + - run: make build_release + + # Remove gox + - run: rm -f bin/gox + - store_artifacts: path: bin destination: / - build_javascript: - executor: base - steps: - - run: sudo chown -R circleci /go/src - - restore_cache: - keys: - - v1-go-src-{{ .Branch }}-{{ .Revision }} - - run: make deps_gopherjs - - run: make build_javascript - - store_artifacts: - path: dist - destination: / + - persist_to_workspace: + root: bin + paths: + - gss_darwin_amd64 + - gss_darwin_arm64 + - gss_linux_386 + - gss_linux_amd64 + - gss_linux_arm + - gss_linux_arm64 + - gss_windows_386.exe + - gss_windows_amd64.exe + build_so: executor: base steps: @@ -96,6 +93,7 @@ jobs: - store_artifacts: path: bin destination: / + workflows: main: jobs: diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index c9aac35..0000000 --- a/.eslintignore +++ /dev/null @@ -1,10 +0,0 @@ -__mocks__/ -dist/ -bin/ -node_modules/ -webpack/ -.DS_Store -.npm -node_modules -npm-debug.* -package-lock.json diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index d98e117..0000000 --- a/.eslintrc +++ /dev/null @@ -1,35 +0,0 @@ -{ - "parser": "babel-eslint", - "extends": "eslint-config-airbnb", - "rules": { - "arrow-parens": ["error", "as-needed"], - "class-methods-use-this": "off", - "comma-dangle": ["error", { "objects": "always-multiline" }], - "import/no-named-as-default": "off", - "import/no-unresolved": "off", - "no-use-before-define": "off", - "object-curly-newline": "off", - "prefer-destructuring": "off", - "react/destructuring-assignment": "off", - "react/forbid-prop-types": "off", - "react/jsx-filename-extension": "off", - "react/jsx-no-bind": "off", - "react/no-access-state-in-setstate": "off", - "react/prefer-stateless-function": "off", - "react/require-default-props": "off", - "react/sort-comp": ["error", { // Team Preference - "order": [ - "static-methods", - "/constructor/", - "/state/", - "instance-variables", - "lifecycle", - "getters", - "everything-else", - "render" - ] - }], - "sort-keys": "error", - "space-before-function-paren": ["error", "always"] - } -} diff --git a/.gitignore b/.gitignore index f027100..0f46872 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,14 @@ +# compiled binaries bin -dist + +# direnv +.envrc.local + +# secrets +secret/ + +# miscellaneous +.DS_Store temp -vendor -Gopkg.lock *.so *.h -.DS_Store -.npm -node_modules -npm-debug.* -package-lock.json diff --git a/LICENSE b/LICENSE index 8c64b7e..fb918c8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 Spatial Current, Inc. +Copyright (c) 2022 Spatial Current, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index a353f99..6dd6660 100644 --- a/Makefile +++ b/Makefile @@ -26,78 +26,75 @@ help: ## Print the help documentation # Dependencies # -deps_go: ## Install Go dependencies - go get -d -t ./... - -.PHONY: deps_go_test -deps_go_test: ## Download Go dependencies for tests - go get golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow # download shadow - go install golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow # install shadow - go get -u github.com/kisielk/errcheck # download and install errcheck - go get -u github.com/client9/misspell/cmd/misspell # download and install misspell - go get -u github.com/gordonklaus/ineffassign # download and install ineffassign - go get -u honnef.co/go/tools/cmd/staticcheck # download and instal staticcheck - go get -u golang.org/x/tools/cmd/goimports # download and install goimports - deps_arm: ## Install dependencies to cross-compile to ARM # ARMv7 apt-get install -y libc6-armel-cross libc6-dev-armel-cross binutils-arm-linux-gnueabi libncurses5-dev gcc-arm-linux-gnueabi g++-arm-linux-gnueabi # ARMv8 apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -deps_gopherjs: ## Install GopherJS - go get -u github.com/gopherjs/gopherjs - -deps_javascript: ## Install dependencies for JavaScript tests - npm install . - # # Go building, formatting, testing, and installing # -.PHONY: fmt fmt: ## Format Go source code go fmt $$(go list ./... ) .PHONY: imports -imports: ## Update imports in Go source code - # If missing, install goimports with: go get golang.org/x/tools/cmd/goimports - goimports -w -local github.com/spatialcurrent/go-simple-serializer,github.com/spatialcurrent/ $$(find . -iname '*.go') +imports: bin/goimports ## Update imports in Go source code + bin/goimports -w -local github.com/spatialcurrent/go-simple-serializer,github.com/spatialcurrent $$(find . -iname '*.go') -.PHONY: vet vet: ## Vet Go source code - go vet $$(go list ./...) + go vet github.com/spatialcurrent/go-simple-serializer/pkg/... # vet packages + go vet github.com/spatialcurrent/go-simple-serializer/cmd/... # vet commands + +tidy: ## Tidy Go source code + go mod tidy .PHONY: test_go -test_go: ## Run Go tests +test_go: bin/errcheck bin/misspell bin/staticcheck bin/shadow ## Run Go tests bash scripts/test.sh - + .PHONY: test_cli -test_cli: ## Run CLI tests +test_cli: bin/gss ## Run CLI tests bash scripts/test-cli.sh -build: build_cli build_javascript build_so build_android ## Build CLI, Shared Objects (.so), JavaScript, and Android - -install: ## Install GSS CLI on current platform - go install -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" github.com/spatialcurrent/go-simple-serializer/cmd/gss +install: ## Install the CLI on current platform + go install github.com/spatialcurrent/go-simple-serializer/cmd/gss # # Command line Programs # -bin/gss_darwin_amd64: ## Build GSS CLI for Darwin / amd64 - GOOS=darwin GOARCH=amd64 go build -o $(DEST)/gss_darwin_amd64 -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" github.com/spatialcurrent/go-simple-serializer/cmd/gss +bin/errcheck: + go build -o bin/errcheck github.com/kisielk/errcheck + +bin/goimports: + go build -o bin/goimports golang.org/x/tools/cmd/goimports + +bin/gox: + go build -o bin/gox github.com/mitchellh/gox + +bin/misspell: + go build -o bin/misspell github.com/client9/misspell/cmd/misspell + +bin/staticcheck: + go build -o bin/staticcheck honnef.co/go/tools/cmd/staticcheck + +bin/shadow: + go build -o bin/shadow golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow -bin/gss_linux_amd64: ## Build GSS CLI for Linux / amd64 - GOOS=linux GOARCH=amd64 go build -o $(DEST)/gss_linux_amd64 -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" github.com/spatialcurrent/go-simple-serializer/cmd/gss +bin/gss: ## Build CLI for Darwin / amd64 + go build -o bin/gss github.com/spatialcurrent/go-simple-serializer/cmd/gss -bin/gss_windows_amd64.exe: ## Build GSS CLI for Windows / amd64 - GOOS=windows GOARCH=amd64 go build -o $(DEST)/gss_windows_amd64.exe -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" github.com/spatialcurrent/go-simple-serializer/cmd/gss +bin/gss_linux_amd64: bin/gox ## Build CLI for Darwin / amd64 + scripts/build-release linux amd64 -bin/gss_linux_arm64: ## Build GSS CLI for Linux / arm64 - GOOS=linux GOARCH=arm64 go build -o $(DEST)/gss_linux_arm64 -gcflags="$(GCFLAGS)" -ldflags="$(LDFLAGS)" github.com/spatialcurrent/go-simple-serializer/cmd/gss +.PHONY: build +build: bin/gss -build_cli: bin/gss_darwin_amd64 bin/gss_linux_amd64 bin/gss_windows_amd64.exe bin/gss_linux_arm64 ## Build command line programs +.PHONY: build_release +build_release: bin/gox + scripts/build-release # # Shared Objects @@ -139,30 +136,6 @@ bin/gss.aar: ## Build Android Archive Library build_android: bin/gss.arr ## Build artifacts for Android -# -# JavaScript -# - -dist/gss.mod.js: ## Build JavaScript module - gopherjs build -o dist/gss.mod.js github.com/spatialcurrent/go-simple-serializer/cmd/gss.mod.js - -dist/gss.mod.min.js: ## Build minified JavaScript module - gopherjs build -m -o dist/gss.mod.min.js github.com/spatialcurrent/go-simple-serializer/cmd/gss.mod.js - -dist/gss.global.js: ## Build JavaScript library that attaches to global or window. - gopherjs build -o dist/gss.global.js github.com/spatialcurrent/go-simple-serializer/cmd/gss.global.js - -dist/gss.global.min.js: ## Build minified JavaScript library that attaches to global or window. - gopherjs build -m -o dist/gss.global.min.js github.com/spatialcurrent/go-simple-serializer/cmd/gss.global.js - -build_javascript: dist/gss.mod.js dist/gss.mod.min.js dist/gss.global.js dist/gss.global.min.js ## Build artifacts for JavaScript - -test_javascript: ## Run JavaScript tests - npm run test - -lint: ## Lint JavaScript source code - npm run lint - # # Examples # @@ -182,8 +155,6 @@ run_example_cpp: bin/gss.so bin/gss_example_cpp ## Run C++ example run_example_python: bin/gss.so ## Run Python example LD_LIBRARY_PATH=bin python examples/python/test.py -run_example_javascript: dist/gss.mod.min.js ## Run JavaScript module example - node examples/js/index.mod.js ## Clean diff --git a/README.md b/README.md index bf69eaa..ec5778a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -[![CircleCI](https://circleci.com/gh/spatialcurrent/go-simple-serializer/tree/master.svg?style=svg)](https://circleci.com/gh/spatialcurrent/go-simple-serializer/tree/master) [![Go Report Card](https://goreportcard.com/badge/spatialcurrent/go-simple-serializer)](https://goreportcard.com/report/spatialcurrent/go-simple-serializer) [![GoDoc](https://godoc.org/github.com/spatialcurrent/go-simple-serializer?status.svg)](https://godoc.org/github.com/spatialcurrent/go-simple-serializer) [![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://github.com/spatialcurrent/go-simple-serializer/blob/master/LICENSE) +[![CircleCI](https://circleci.com/gh/spatialcurrent/spatialcurrent/go-simple-serializer/tree/main.svg?style=svg)](https://circleci.com/gh/spatialcurrent/spatialcurrent/go-simple-serializer/tree/main) +[![Go Report Card](https://goreportcard.com/badge/spatialcurrent/spatialcurrent/go-simple-serializer?style=flat-square)](https://goreportcard.com/report/github.com/spatialcurrent/spatialcurrent/go-simple-serializer) +[![PkgGoDev](https://pkg.go.dev/badge/mod/github.com/spatialcurrent/spatialcurrent/go-simple-serializer)](https://pkg.go.dev/github.com/spatialcurrent/spatialcurrent/go-simple-serializer) +[![License](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://github.com/spatialcurrent/spatialcurrent/go-simple-serializer/blob/master/LICENSE) # go-simple-serializer @@ -6,7 +9,7 @@ **go-simple-serializer** (aka GSS) is a simple library to easily convert data between formats that aims to decrease the burden on developers to support multiple serialization formats in their applications. GSS supports a variety of operating systems, architectures, and use cases. A CLI is released for Microsoft Windows, Linux distributions, and [Darwin](https://en.wikipedia.org/wiki/Darwin_%28operating_system%29) platforms. -Using cross compilers, this library can also be called by other languages, including `C`, `C++`, `Python`, and `JavaScript`. This library is cross compiled into a Shared Object file (`*.so`), which can be called by `C`, `C++`, and `Python` on Linux machines. This library is also compiled to pure `JavaScript` using [GopherJS](https://github.com/gopherjs/gopherjs), which can be called by [Node.js](https://nodejs.org) and loaded in the browser. See the examples folder for patterns that you can use. +Using cross compilers, this library can also be called by other languages, including `C`, `C++`, and `Python`. This library is cross compiled into a Shared Object file (`*.so`), which can be called by `C`, `C++`, and `Python` on Linux machines. See the examples folder for patterns that you can use. **Formats** @@ -16,43 +19,48 @@ GSS supports many common formats, including CSV, JSON, and YAML. Pull requests The main public api for GSS is in the `gss` package. However, this library does ship with internal packages under `/pkg/...` that can be imported and used directly. -# Usage +## Platforms -**CLI** +The following platforms are supported. Pull requests to support other platforms are welcome! -The command line tool, `gss`, can be used to easily convert data between formats. We currently support the following platforms. +| GOOS | 386 | amd64 | arm | arm64 | +| ---- | --- | ----- | --- | ----- | +| darwin | - | ✓ | - | - | +| freebsd | ✓ | ✓ | ✓ | - | +| linux | ✓ | ✓ | ✓ | ✓ | +| openbsd | ✓ | ✓ | - | - | +| solaris | - | ✓ | - | - | +| windows | ✓ | ✓ | - | - | -| GOOS | GOARCH | -| ---- | ------ | -| darwin | amd64 | -| linux | amd64 | -| windows | amd64 | -| linux | arm64 | +## Releases -Pull requests to support other platforms are welcome! See the [CLI.md](docs/CLI.md) document for detailed usage and examples. +Find releases for the supported platforms at [https://github.com/spatialcurrent/go-simple-serializer/releases](https://github.com/spatialcurrent/go-simple-serializer/releases). See the **Building** section below to build for another platform from source. -**Go** +# Usage -You can install the go-simple-serializer packages with. +**CLI** +See the [CLI.md](docs/CLI.md) document for detailed usage and examples. -```shell -go get -u -d github.com/spatialcurrent/go-simple-serializer/... -``` - -You can then import the main public API with `import "github.com/spatialcurrent/go-simple-serializer/pkg/gss"` or one of the underlying packages, e.g., `import "github.com/spatialcurrent/go-simple-serializer/pkg/tags"`. +**Go** -See [go-simple-serializer](https://godoc.org/github.com/spatialcurrent/go-simple-serializer) in GoDoc for API documentation and examples. +You can import the public *gss** package with: -**Node** +```go +import ( + "github.com/spatialcurrent/go-simple-serializer/pkg/gss" +) +``` -GSS is built as a module. In modern JavaScript, the module can be imported using [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment). +You can also import one of the internal packages such as **tags** with: -```javascript -const { serialize, deserialize, convert, formats } = require('./dist/gss.mod.min.js'); +```go +import ( + "github.com/spatialcurrent/go-simple-serializer/pkg/tags" +) ``` -In legacy JavaScript, you can use the `gss.global.js` file that simply adds `gss` to the global scope. +See [gss](https://pkg.go.dev/github.com/spatialcurrent/go-simple-serializer/pkg/gss) in the docs for information on how to use Go API. **Android** @@ -69,33 +77,6 @@ import com.spatialcurrent.gss.Gss; A variant of the `Convert` function is exported in a Shared Object file (`*.so`), which can be called by `C`, `C++`, and `Python` programs on Linux machines. For complete patterns for `C`, `C++`, and `Python`, see the `examples` folder in this repo. -# Releases - -**go-simple-serializer** is currently in **alpha**. See releases at https://github.com/spatialcurrent/go-simple-serializer/releases. See the **Building** section below to build from scratch. - -**JavaScript** - -- `gss.global.js`, `gss.global.js.map` - JavaScript global build with source map -- `gss.global.min.js`, `gss.global.min.js.map` - Minified JavaScript global build with source map -- `gss.mod.js`, `gss.mod.js.map` - JavaScript module build with source map -- `gss.mod.min.js`, `gss.mod.min.js.map` - Minified JavaScript module with source map - -**Darwin** - -- `gss_darwin_amd64` - CLI for Darwin on amd64 (includes `macOS` and `iOS` platforms) - -**Linux** - -- `gss_linux_amd64` - CLI for Linux on amd64 -- `gss_linux_amd64` - CLI for Linux on arm64 -- `gss_linux_amd64.h`, `gss_linuxamd64.so` - Shared Object for Linux on amd64 -- `gss_linux_armv7.h`, `gss_linux_armv7.so` - Shared Object for Linux on ARMv7 -- `gss_linux_armv8.h`, `gss_linux_armv8.so` - Shared Object for Linux on ARMv8 - -**Windows** - -- `gss_windows_amd64.exe` - CLI for Windows on amd64 - # Examples **CLI** @@ -120,7 +101,7 @@ find . -name '*.go' | gss -i csv --input-header path -o jsonl **Go** -See the examples in [GoDoc](https://godoc.org/github.com/spatialcurrent/go-simple-serializer). +See the examples in the [docs](https://godoc.org/github.com/spatialcurrent/go-simple-serializer). **C** @@ -134,10 +115,6 @@ See the `examples/cpp/main.cpp` file. You can run the example with `make run_ex See the `examples/python/test.py` file. You can run the example with `make run_example_python`. -**JavaScript** - -See the `examples/js/index.js` file. You can run the example with `make run_example_javascript`. - # Building Use `make help` to see help information for each target. @@ -146,10 +123,6 @@ Use `make help` to see help information for each target. The `make build_cli` script is used to build executables for Linux and Windows. -**JavaScript** - -You can compile GSS to pure JavaScript with the `make build_javascript` script. - **Android** The `make build_android` script is used to build an [Android Archive](https://developer.android.com/studio/projects/android-library) (AAR) file and associated Javadocs. @@ -166,7 +139,7 @@ The default destination for build artifacts is `go-simple-serializer/bin`, but y **CLI** -To run CLI testes use `make test_cli`, which uses [shUnit2](https://github.com/kward/shunit2). If you recive a `shunit2:FATAL Please declare TMPDIR with path on partition with exec permission.` error, you can modify the `TMPDIR` environment variable in line or with `export TMPDIR=`. For example: +To run CLI tests use `make test_cli`, which uses [shUnit2](https://github.com/kward/shunit2). If you recive a `shunit2:FATAL Please declare TMPDIR with path on partition with exec permission.` error, you can modify the `TMPDIR` environment variable in line or with `export TMPDIR=`. For example: ``` TMPDIR="/usr/local/tmp" make test_cli @@ -174,15 +147,11 @@ TMPDIR="/usr/local/tmp" make test_cli **Go** -To run Go tests use `make test_go` (or `bash scripts/test.sh`), which runs unit tests, `go vet`, `go vet with shadow`, [errcheck](https://github.com/kisielk/errcheck), [ineffassign](https://github.com/gordonklaus/ineffassign), [staticcheck](https://staticcheck.io/), and [misspell](https://github.com/client9/misspell). - -**JavaScript** - -To run JavaScript tests, first install [Jest](https://jestjs.io/) using `make deps_javascript`, use [Yarn](https://yarnpkg.com/en/), or another method. Then, build the JavaScript module with `make build_javascript`. To run tests, use `make test_javascript`. You can also use the scripts in the `package.json`. +To run Go tests using `make test_go` or (`bash scripts/test.sh`), which runs unit tests, `go vet`, `go vet with shadow`, [errcheck](https://github.com/kisielk/errcheck), [staticcheck](https://staticcheck.io/), and [misspell](https://github.com/client9/misspell). # Contributing -[Spatial Current, Inc.](https://spatialcurrent.io) is currently accepting pull requests for this repository. We'd love to have your contributions! Please see [Contributing.md](https://github.com/spatialcurrent/go-simple-serializer/blob/master/CONTRIBUTING.md) for how to get started. +[Spatial Current, Inc.](https://spatialcurrent.io) is currently accepting pull requests for this repository. We'd love to have your contributions! Please see [Contributing.md](https://github.com/spatialcurrent/spatialcurrent/go-simple-serializer/blob/main/CONTRIBUTING.md) for how to get started. # License diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..5549de9 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,3 @@ +# Security + +Please submit security issues directly to Spatial Current, Inc. at [security@spatialcurrent.io](mailto:security@spatialcurrent.io). diff --git a/cmd/gss.global.js/main.go b/cmd/gss.global.js/main.go deleted file mode 100644 index 398fcbe..0000000 --- a/cmd/gss.global.js/main.go +++ /dev/null @@ -1,49 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -// gss.global.js is the package for go-simple-serializer (GSS) that adds GSS functions to the global scope under the "gss" variable. -// -// In Node, depending on where require is called and the build system used, the functions may need to be required at the top of each module file. -// In a web browser, gss can be made available to the entire web page. -// The functions are defined in the Exports variable in the gssjs package. -// -// Usage -// // Below is a simple set of examples of how to use this package in a JavaScript application. -// -// // load functions into global scope -// // require('./dist/gss.global.min.js); -// -// // Serialize an object to a string. -// // Returns an object, which can be destructured to the formatted string and error as a string. -// // If there is no error, then err will be null. -// var { str, err } = gss.serialize(object, format, options); -// -// // Deserialize a formatted string to an object. -// // Returns an object, which can be destructured to the object and error as a string. -// // If there is no error, then err will be null. -// var { obj, err } = gss.deserialize(str, format, options); -// -// // Convert a formatted string to a new format. -// // Returns an object, which can be destructured to the string and error as a string. -// // If there is no error, then err will be null. -// var { str, err } = gss.convert(str, inputFormat, ouputFormat, inputOptions, outputOptions); -// -// References -// - https://godoc.org/pkg/github.com/spatialcurrent/go-simple-serializer/pkg/gssjs/ -// - https://nodejs.org/api/globals.html#globals_global_objects -// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects -package main - -import ( - "github.com/gopherjs/gopherjs/js" - - "github.com/spatialcurrent/go-simple-serializer/pkg/gssjs" -) - -func main() { - js.Global.Set("gss", gssjs.Exports) -} diff --git a/cmd/gss.mod.js/main.go b/cmd/gss.mod.js/main.go deleted file mode 100644 index 1abfe64..0000000 --- a/cmd/gss.mod.js/main.go +++ /dev/null @@ -1,49 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -// gss.mod.js is the package for go-simple-serializer (GSS) that is built as a JavaScript module. -// In modern JavaScript, the module can be imported using destructuring assignment. -// The functions are defined in the Exports variable in the gssjs package. -// -// Usage -// // Below is a simple set of examples of how to use this package in a JavaScript application. -// -// // load functions into current scope -// const { serialize, deserialize, convert, formats } = require('./dist/gss.global.min.js); -// -// // Serialize an object to a string. -// // Returns an object, which can be destructured to the formatted string and error as a string. -// // If there is no error, then err will be null. -// var { str, err } = serialize(object, format, options); -// -// // Deserialize a formatted string to an object. -// // Returns an object, which can be destructured to the object and error as a string. -// // If there is no error, then err will be null. -// var { obj, err } = deserialize(str, format, options); -// -// // Convert a formatted string to a new format. -// // Returns an object, which can be destructured to the string and error as a string. -// // If there is no error, then err will be null. -// var { str, err } = convert(str, inputFormat, ouputFormat, inputOptions, outputOptions); -// -// References -// - https://godoc.org/pkg/github.com/spatialcurrent/go-simple-serializer/pkg/gssjs/ -// - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment -package main - -import ( - "github.com/gopherjs/gopherjs/js" - - "github.com/spatialcurrent/go-simple-serializer/pkg/gssjs" -) - -func main() { - jsModuleExports := js.Module.Get("exports") - for name, value := range gssjs.Exports { - jsModuleExports.Set(name, value) - } -} diff --git a/cmd/gss/main.go b/cmd/gss/main.go index 29ccf1c..946161d 100644 --- a/cmd/gss/main.go +++ b/cmd/gss/main.go @@ -26,13 +26,13 @@ package main import ( + "errors" "fmt" "io/ioutil" "os" "reflect" "strings" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -141,14 +141,14 @@ Supports the following file formats: ` + strings.Join(gss.Formats, ", "), EscapeNewLine: true, }) if err != nil { - return errors.Wrap(err, "error writing viper settings") + return fmt.Errorf("error writing viper settings: %w", err) } fmt.Println("") } fi, err := os.Stdin.Stat() if err != nil { - return errors.Wrap(err, "error stating stdin") + return fmt.Errorf("error stating stdin: %w", err) } if fi.Mode()&os.ModeNamedPipe == 0 { @@ -191,10 +191,10 @@ Supports the following file formats: ` + strings.Join(gss.Formats, ", "), DropCR: v.GetBool(cli.FlagInputDropCR), }) if errorIterator != nil { - return errors.Wrap(errorIterator, "error creating input iterator: %w") + return fmt.Errorf("error creating input iterator: %w", errorIterator) } if it == nil { - return errors.New(fmt.Sprintf("error building input iterator with format %q", inputFormat)) + return fmt.Errorf("error building input iterator with format %q", inputFormat) } p = p.Input(it) @@ -217,7 +217,7 @@ Supports the following file formats: ` + strings.Join(gss.Formats, ", "), Reversed: outputReversed, }) if errWriter != nil { - return errors.Wrap(errWriter, "error building output writer") + return fmt.Errorf("error building output writer: %w", errWriter) } p = p.Output(w) @@ -226,14 +226,14 @@ Supports the following file formats: ` + strings.Join(gss.Formats, ", "), } if errRun := p.Run(); errRun != nil { - return errors.Wrap(errRun, "error piping data") + return fmt.Errorf("error piping data: %w", errRun) } return nil } inputBytes, err := ioutil.ReadAll(os.Stdin) if err != nil { - return errors.Wrap(err, "error reading from stdin") + return fmt.Errorf("error reading from stdin: %w", err) } var inputType reflect.Type @@ -278,7 +278,7 @@ Supports the following file formats: ` + strings.Join(gss.Formats, ", "), OutputEscapeEqual: v.GetBool(cli.FlagOutputEscapeEqual), }) if err != nil { - return errors.Wrap(err, "error converting") + return fmt.Errorf("error converting: %w", err) } switch outputFormat { case serializer.FormatCSV, serializer.FormatJSONL, serializer.FormatProperties, serializer.FormatTags, serializer.FormatTOML, serializer.FormatTSV, serializer.FormatYAML: diff --git a/examples/js/index.global.js b/examples/js/index.global.js deleted file mode 100644 index de50d18..0000000 --- a/examples/js/index.global.js +++ /dev/null @@ -1,58 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -require('./../../dist/gss.global.min.js'); -const { serialize, deserialize, convert, formats } = global.gss; -console.log('Formats:', formats); -console.log(); -console.log("************************************"); -console.log(); - -const obj = { - "a": "1", - "b": "c", - "x": ["foo", "bar"] -} - -const arr = [ - { - "a": "x", - "b": "y", - "c": "z" - }, - { - "d": "g", - "e": "h", - "f": "i" - } -]; - -console.log('Input:'); -console.log(obj); -console.log(); -// Destructure return value -var { str, err } = serialize(arr, "json", {"pretty": true}); -console.log('Output:'); -console.log(str); -console.log(); -console.log('Error:'); -console.log(err); -console.log(); -console.log("************************************"); -console.log(); - -console.log('Input:'); -console.log(obj); -console.log(); -// Destructure return value -var { str, err } = serialize(obj, "blah"); -console.log('Output:'); -console.log(str); -console.log(); -console.log('Error:'); -console.log(err); -console.log(); diff --git a/examples/js/index.mod.js b/examples/js/index.mod.js deleted file mode 100644 index 62c0c43..0000000 --- a/examples/js/index.mod.js +++ /dev/null @@ -1,57 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -const { serialize, deserialize, convert, formats } = require('./../../dist/gss.mod.min.js'); -console.log('Formats:', formats); -console.log(); -console.log("************************************"); -console.log(); - -const obj = { - "a": "1", - "b": "c", - "x": ["foo", "bar"] -} - -const arr = [ - { - "a": "x", - "b": "y", - "c": "z" - }, - { - "d": "g", - "e": "h", - "f": "i" - } -]; - -console.log('Input:'); -console.log(obj); -console.log(); -// Destructure return value -var { str, err } = serialize(arr, "json", {"pretty": true}); -console.log('Output:'); -console.log(str); -console.log(); -console.log('Error:'); -console.log(err); -console.log(); -console.log("************************************"); -console.log(); - -console.log('Input:'); -console.log(obj); -console.log(); -// Destructure return value -var { str, err } = serialize(obj, "blah"); -console.log('Output:'); -console.log(str); -console.log(); -console.log('Error:'); -console.log(err); -console.log(); diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..62939f9 --- /dev/null +++ b/go.mod @@ -0,0 +1,45 @@ +module github.com/spatialcurrent/go-simple-serializer + +go 1.17 + +require ( + github.com/BurntSushi/toml v1.0.0 + github.com/client9/misspell v0.3.4 + github.com/hashicorp/hcl v1.0.0 + github.com/kisielk/errcheck v1.6.0 + github.com/mitchellh/gox v1.0.1 + github.com/pkg/errors v0.9.1 + github.com/spatialcurrent/go-fit v0.0.0-20220308154842-0eadb7a509c2 + github.com/spatialcurrent/go-pipe v0.0.0-20211121224133-8c3e90fc2b6a + github.com/spatialcurrent/go-stringify v0.0.0-20220308153339-0abf902cfee4 + github.com/spf13/cobra v1.3.0 + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.10.1 + github.com/stretchr/testify v1.7.0 + golang.org/x/tools v0.1.9 + gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 + gopkg.in/yaml.v2 v2.4.0 + honnef.co/go/tools v0.2.2 +) + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/hashicorp/go-version v1.0.0 // indirect + github.com/inconshreveable/mousetrap v1.0.0 // indirect + github.com/magiconair/properties v1.8.5 // indirect + github.com/mitchellh/iochan v1.0.0 // indirect + github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/pelletier/go-toml v1.9.4 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/spf13/afero v1.6.0 // indirect + github.com/spf13/cast v1.4.1 // indirect + github.com/spf13/jwalterweatherman v1.1.0 // indirect + github.com/subosito/gotenv v1.2.0 // indirect + golang.org/x/mod v0.5.1 // indirect + golang.org/x/sys v0.0.0-20211210111614-af8b64212486 // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect + gopkg.in/ini.v1 v1.66.2 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..07f3117 --- /dev/null +++ b/go.sum @@ -0,0 +1,820 @@ +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.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.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.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= +cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= +cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= +cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= +cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= +cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= +cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= +cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= +cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= +cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= +cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= +cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +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/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= +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/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= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.0.0 h1:dtDWrepsVPfW9H/4y7dDgFc2MBUSeJhlaDtK13CxFlU= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +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/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +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/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= +github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= +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/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +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/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/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= +github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +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-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-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +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/groupcache v0.0.0-20210331224755-41bb18bfe9da/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/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +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.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +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/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.3/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/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/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= +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-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-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/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/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= +github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= +github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= +github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8= +github.com/hashicorp/go-version v1.0.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/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= +github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= +github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= +github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= +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/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/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/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/errcheck v1.6.0 h1:YTDO4pNy7AUN/021p+JGHycQyYNIyMoenM1YDVK6RlY= +github.com/kisielk/errcheck v1.6.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +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/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.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= +github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= +github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +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.6/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/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-isatty v0.0.3/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.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= +github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= +github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +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/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= +github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +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.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +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.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +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/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +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.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +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/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= +github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +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/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spatialcurrent/go-fit v0.0.0-20220308154842-0eadb7a509c2 h1:h0LKU5QSd7UprPijdsytzlU+FdSvOYyYKXK/oG+Lh6Q= +github.com/spatialcurrent/go-fit v0.0.0-20220308154842-0eadb7a509c2/go.mod h1:FIg59wDFeql/vUaax+llHA2tDfSWHpqxig/nvV6cXDg= +github.com/spatialcurrent/go-pipe v0.0.0-20211121224133-8c3e90fc2b6a h1:wqR56ICm3a2RpcOonB2qVH8FXU9ygh1Lg87Q7NyCpp8= +github.com/spatialcurrent/go-pipe v0.0.0-20211121224133-8c3e90fc2b6a/go.mod h1:Lq/brpH++gKrSYVzimS8cBqldqdZyZPRhAj06ZEl5S0= +github.com/spatialcurrent/go-stringify v0.0.0-20220308153339-0abf902cfee4 h1:9Pg1iV1PATa6xYxQAlSGsRYwHh1OEnp7Lphaf+MV6bs= +github.com/spatialcurrent/go-stringify v0.0.0-20220308153339-0abf902cfee4/go.mod h1:QOkIEQRq/x7eI60dZf97Z1kCCICTXEoRCcHPbtq0kIQ= +github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= +github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= +github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= +github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0= +github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= +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.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= +github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= +github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= +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/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 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +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.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= +go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= +go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= +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.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/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-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= +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-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +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/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.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= +golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= +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-20181023162649-9b4f9f5ad519/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-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-20190923162816-aa69164e4478/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-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-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-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +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-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/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-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/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +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-20181026203630-95b1ffbd15a5/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-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-20190922100055-0a153f010e69/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-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-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-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-20200124204421-9fbb57f87de9/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-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-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-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/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-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603125802-9665404d3644/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-20210616094352-59db8d763f22/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-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/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-20211007075335-d3039528d8ac/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-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486 h1:5hpz5aRr+W1erYCL5JRhSUBJRph7l9XkNveoExlrKYk= +golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +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.5/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-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/tools v0.0.0-20180917221912-90fa682c2a6e/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-20190311212946-11955173bddd/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-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-20190907020128-2ca718005c18/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-20191012152004-8de300cfc20a/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-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-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-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +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-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +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-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= +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-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.9 h1:j9KsMiaP1c3B0OTQGth0/k+miLGTgLsAFUCrF2vLcF8= +golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +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 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= +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.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/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= +google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= +google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= +google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= +google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= +google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= +google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= +google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= +google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= +google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= +google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= +google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= +google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +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.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-20180817151627-c66870c02cf8/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-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-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-20200513103714-09dca8ec2884/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-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-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= +google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= +google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= +google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= +google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= +google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +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.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.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.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +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/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +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.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +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 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= +gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= +gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +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.8/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 h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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.2.2 h1:MNh1AVMyVX23VUHE2O27jm6lNj3vjO5DexS4A1xvnzk= +honnef.co/go/tools v0.2.2/go.mod h1:lPVVZ2BS5TfnjLyizF7o7hv7j9/L+8cZY2hLyjP9cGY= +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= diff --git a/js/gss.test.js b/js/gss.test.js deleted file mode 100644 index 21d1c82..0000000 --- a/js/gss.test.js +++ /dev/null @@ -1,310 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -const { serialize, serializeArray, deserialize, convert, formats } = global.gss; - -const testObject = { - "a": "x", - "b": "y", - "c": "z" -}; - -const testArray = [ - { - "a": "x", - "b": "y", - "c": "z" - }, - { - "b": "g", - "c": "h", - "d": "i" - } -]; - -function log(str) { - console.log(str.replace(/\n/g, "\\n").replace(/\t/g, "\\t").replace(/"/g, "\\\"")); -} - -describe('gss', () => { - - it('checks the available formats', () => { - expect(formats).toEqual(["bson", "csv", "fmt", "go", "gob", "hcl", "json", "jsonl", "properties", "tags", "toml", "tsv", "yaml"]); - }); - -}); - -describe('serialize : object', () => { - - it('serializes an object to csv', () => { - var { str, err } = serialize(testObject, "csv", {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a,b,c\nx,y,z\n"); - }); - - it('serializes an object to go', () => { - var { str, err } = serialize(testObject, "go"); - expect(err).toBeNull(); - expect(str).toEqual("map[string]interface {}{\"a\":\"x\", \"b\":\"y\", \"c\":\"z\"}"); - }); - - it('serializes an object to json', () => { - var { str, err } = serialize(testObject, "json"); - expect(err).toBeNull(); - expect(str).toEqual("{\"a\":\"x\",\"b\":\"y\",\"c\":\"z\"}"); - }); - - it('serializes an object to json (pretty)', () => { - var { str, err } = serialize(testObject, "json", {"pretty": true}); - expect(err).toBeNull(); - expect(str).toEqual("{\n \"a\": \"x\",\n \"b\": \"y\",\n \"c\": \"z\"\n}"); - }); - - it('serializes an object to jsonl', () => { - var { str, err } = serialize(testObject, "jsonl"); - expect(err).toBeNull(); - expect(str).toEqual("{\"a\":\"x\",\"b\":\"y\",\"c\":\"z\"}\n"); - }); - - it('serializes an object to properties', () => { - var { str, err } = serialize(testObject, "properties"); - expect(err).toBeNull(); - expect(str).toEqual("a=x\nb=y\nc=z"); - }); - - it('serializes an object to tags', () => { - var { str, err } = serialize(testObject, "tags"); - expect(err).toBeNull(); - expect(str).toEqual("a=x b=y c=z"); - }); - - it('serializes an object to toml', () => { - var { str, err } = serialize(testObject, "toml"); - expect(err).toBeNull(); - expect(str).toEqual("a = \"x\"\nb = \"y\"\nc = \"z\"\n"); - }); - - it('serializes an object to tsv', () => { - var { str, err } = serialize(testObject, "tsv"); - expect(err).toBeNull(); - expect(str).toEqual("a\tb\tc\nx\ty\tz\n"); - }); - - it('serializes an object to yaml', () => { - var { str, err } = serialize(testObject, "yaml"); - expect(err).toBeNull(); - expect(str).toEqual("a: x\nb: \"y\"\nc: z\n"); - }); - -}); - -describe('serialize : array', () => { - - it('serializes an array to csv', () => { - var { str, err } = serialize(testArray, "csv", {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a,b,c\nx,y,z\n,g,h\n"); - }); - - it('serializes an array to csv (reversed)', () => { - var { str, err } = serialize(testArray, "csv", {"sorted": true, "reversed": true}); - expect(err).toBeNull(); - expect(str).toEqual("c,b,a\nz,y,x\nh,g,\n"); - }); - - it('serializes an array to csv (expand header)', () => { - var { str, err } = serialize(testArray, "csv", {"sorted": true, "expandHeader": true}); - expect(err).toBeNull(); - expect(str).toEqual("a,b,c,d\nx,y,z,\n,g,h,i\n"); - }); - - it('serializes an array to go', () => { - var { str, err } = serialize(testArray, "go"); - expect(err).toBeNull(); - expect(str).not.toBeNull(); // hard to test, since not sorted. - }); - - it('serializes an array to json', () => { - var { str, err } = serialize(testArray, "json"); - expect(err).toBeNull(); - expect(str).toEqual("[{\"a\":\"x\",\"b\":\"y\",\"c\":\"z\"},{\"b\":\"g\",\"c\":\"h\",\"d\":\"i\"}]"); - }); - - it('serializes an array to json (pretty)', () => { - var { str, err } = serialize(testArray, "json", {"pretty": true}); - //console.error(str.replace(/\n/g, "\\n").replace(/"/g, "\\\"")); - expect(err).toBeNull(); - expect(str).toEqual("[\n {\n \"a\": \"x\",\n \"b\": \"y\",\n \"c\": \"z\"\n },\n {\n \"b\": \"g\",\n \"c\": \"h\",\n \"d\": \"i\"\n }\n]"); - }); - - it('serializes an array to jsonl', () => { - var { str, err } = serialize(testArray, "jsonl"); - expect(err).toBeNull(); - expect(str).toEqual("{\"a\":\"x\",\"b\":\"y\",\"c\":\"z\"}\n{\"b\":\"g\",\"c\":\"h\",\"d\":\"i\"}\n"); - }); - - it('serializes an array to properties (error)', () => { - var { str, err } = serialize(testArray, "properties", {"sorted": true}); - expect(err).toEqual("error serializing input object: error serializing: error writing properties: type \"[]interface {}\" is of invalid kind, expecting one of [\"map\" \"struct\"]"); - expect(str).toBeNull(); - }); - - it('serializes an array to tags', () => { - var { str, err } = serialize(testArray, "tags", {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a=x b=y c=z\nb=g c=h d=i\n"); - }); - - it('serializes an array to toml (error)', () => { - var { str, err } = serialize(testArray, "toml"); - expect(err).toEqual("error serializing input object: error serializing: error marshaling TOML bytes: toml: top-level values must be Go maps or structs"); - expect(str).toBeNull(); - }); - - it('serializes an array to tsv', () => { - var { str, err } = serialize(testArray, "tsv"); - expect(err).toBeNull(); - expect(str).toEqual("a\tb\tc\nx\ty\tz\n\tg\th\n"); - }); - - it('serializes an array to yaml', () => { - var { str, err } = serialize(testArray, "yaml"); - expect(err).toBeNull(); - expect(str).toEqual("- a: x\n b: \"y\"\n c: z\n- b: g\n c: h\n d: i\n"); - }); - -}); - -describe('deserialize : object', () => { - - it('deserializes an object from csv', () => { - var { obj, err } = deserialize("a,b,c\nx,y,z\n", "csv", {}); - expect(err).toBeNull(); - expect(obj).toEqual([{"a": "x", "b": "y", "c": "z"}]); - }); - - /* - - it('serializes an object from go', () => { - var { str, err } = serialize(testObject, "go"); - expect(err).toBeNull(); - expect(str).toEqual("map[string]interface {}{\"a\":\"x\", \"b\":\"y\", \"c\":\"z\"}"); - }); - - */ - - it('deserializes an object from json', () => { - var { obj, err } = deserialize("{\"a\":\"x\",\"b\":\"y\",\"c\":\"z\"}", "json"); - expect(err).toBeNull(); - expect(obj).toEqual(testObject); - }); - - it('deserializes an object from jsonl', () => { - var { obj, err } = deserialize("{\"a\":\"x\",\"b\":\"y\",\"c\":\"z\"}", "jsonl"); - expect(err).toBeNull(); - expect(obj).toEqual([testObject]); - }); - - it('deserializes an object from properties', () => { - var { obj, err } = deserialize("a=x\nb=y\nc=z", "properties"); - expect(err).toBeNull(); - expect(obj).toEqual(testObject); - }); - - it('deserializes an object from tags', () => { - var { obj, err } = deserialize("a=x b=y c=z", "tags"); - expect(err).toBeNull(); - expect(obj).toEqual([testObject]); - }); - - it('deserializes an object from toml', () => { - var { obj, err } = deserialize("a = \"x\"\nb = \"y\"\nc = \"z\"\n", "toml"); - expect(err).toBeNull(); - expect(obj).toEqual(testObject); - }); - - it('deserializes an object from tsv', () => { - var { obj, err } = deserialize("a\tb\tc\nx\ty\tz\n", "tsv"); - expect(err).toBeNull(); - expect(obj).toEqual([testObject]); - }); - - it('deserializes an object to yaml', () => { - var { obj, err } = deserialize("a: x\nb: \"y\"\nc: z\n", "yaml"); - expect(err).toBeNull(); - expect(obj).toEqual(testObject); - }); - -}); - -describe('convert : object', () => { - - it('convert an object from csv to json', () => { - var { str, err } = convert("a,b,c\nx,y,z\n", "csv", "json", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("[{\"a\":\"x\",\"b\":\"y\",\"c\":\"z\"}]"); - }); - - it('convert an object from csv to tsv', () => { - var { str, err } = convert("a,b,c\nx,y,z\n", "csv", "tsv", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a\tb\tc\nx\ty\tz\n"); - }); - - it('convert an object from csv to yaml', () => { - var { str, err } = convert("a,b,c\nx,y,z\n", "csv", "yaml", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("- a: x\n b: \"y\"\n c: z\n"); - }); - - it('convert an object from json to bson and back', () => { - var { str, err } = convert(JSON.stringify(testObject), "json", "bson"); - expect(err).toBeNull(); - // TODO: hex or base64 encode string so we can test - //expect(Buffer.to(str, 'hex')).toEqual("a=x\nb=y\nc=z"); - var { str, err } = convert(str, "bson", "json"); - expect(err).toBeNull(); - expect(str).toEqual(JSON.stringify(testObject)); - }); - - it('convert an object from json to properties and back', () => { - var { str, err } = convert(JSON.stringify(testObject), "json", "properties", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a=x\nb=y\nc=z"); - var { str, err } = convert(str, "properties", "json", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual(JSON.stringify(testObject)); - }); - - it('convert an object from json to tags and back', () => { - var { str, err } = convert(JSON.stringify(testObject), "json", "tags", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a=x b=y c=z"); - var { str, err } = convert(str, "tags", "json", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual(JSON.stringify([testObject])); // to support streaming, deserializing tags returns an array - }); - - it('convert an object from json to toml and back', () => { - var { str, err } = convert(JSON.stringify(testObject), "json", "toml", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a = \"x\"\nb = \"y\"\nc = \"z\"\n"); - var { str, err } = convert(str, "toml", "json", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual(JSON.stringify(testObject)); - }); - - it('convert an object from json to yaml and back', () => { - var { str, err } = convert(JSON.stringify(testObject), "json", "yaml", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual("a: x\nb: \"y\"\nc: z\n"); - var { str, err } = convert(str, "yaml", "json", undefined, {"sorted": true}); - expect(err).toBeNull(); - expect(str).toEqual(JSON.stringify(testObject)); - }); - -}); diff --git a/package.json b/package.json deleted file mode 100644 index a266dce..0000000 --- a/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "go-simple-serializer", - "version": "0.0.8", - "description": "Simple library and command line program for converting between JSON, YAML, TOML, and many other serialization formats.", - "main": "bin/gss.js", - "scripts": { - "lint": "eslint js", - "clean": "rm -fr dist/gss.mod.min.js", - "build": "make dist/gss.mod.min.js", - "build:clean": "npm run clean && npm run build", - "test": "./node_modules/.bin/jest", - "test:clean": "npm run clean && npm run build && npm run test" - }, - "sideEffects": false, - "repository": { - "type": "git", - "url": "git+https://github.com/spatialcurrent/go-simple-serializer.git" - }, - "author": "", - "license": "ISC", - "bugs": { - "url": "https://github.com/spatialcurrent/go-simple-serializer/issues" - }, - "homepage": "https://github.com/spatialcurrent/go-simple-serializer#readme", - "devDependencies": { - "jest": "^23.6.0", - "jest-cli": "^23.6.0" - }, - "dependencies": {}, - "jest": { - "roots": [ - "js" - ], - "moduleFileExtensions": [ - "js", - "json" - ], - "testEnvironment": "./testEnvironment" - } -} diff --git a/pkg/bson/Unmarshal.go b/pkg/bson/Unmarshal.go index be5f72b..a1c1c07 100644 --- a/pkg/bson/Unmarshal.go +++ b/pkg/bson/Unmarshal.go @@ -9,8 +9,7 @@ package bson import ( "fmt" - // import the mgo bson library - "github.com/pkg/errors" + mgobson "gopkg.in/mgo.v2/bson" ) @@ -27,7 +26,7 @@ func Unmarshal(b []byte) (interface{}, error) { obj := map[string]interface{}{} err := mgobson.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling BSON %q", string(b))) + return nil, fmt.Errorf("error unmarshaling BSON %q: %w", string(b), err) } return obj, nil diff --git a/pkg/bson/UnmarshalType.go b/pkg/bson/UnmarshalType.go index e8eede7..60dd1d4 100644 --- a/pkg/bson/UnmarshalType.go +++ b/pkg/bson/UnmarshalType.go @@ -9,10 +9,8 @@ package bson import ( "fmt" - // import the mgo bson library "reflect" - "github.com/pkg/errors" mgobson "gopkg.in/mgo.v2/bson" ) @@ -34,7 +32,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(outputType)) err := mgobson.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling BSON %q", string(b))) + return nil, fmt.Errorf("error unmarshaling BSON %q: %w", string(b), err) } return ptr.Elem().Interface(), nil } @@ -43,7 +41,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr := reflect.New(outputType) err := mgobson.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling BSON %q", string(b))) + return nil, fmt.Errorf("error unmarshaling BSON %q: %w", string(b), err) } return ptr.Elem().Interface(), nil } @@ -53,7 +51,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(outputType)) err := mgobson.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling BSON %q", string(b))) + return nil, fmt.Errorf("error unmarshaling BSON %q: %w", string(b), err) } return ptr.Elem().Interface(), nil } diff --git a/pkg/bson/bson.go b/pkg/bson/bson.go index 50bdb74..a779244 100644 --- a/pkg/bson/bson.go +++ b/pkg/bson/bson.go @@ -10,9 +10,8 @@ package bson import ( + "errors" "reflect" - - "github.com/pkg/errors" ) var ( diff --git a/pkg/cli/CheckConfig.go b/pkg/cli/CheckConfig.go index 10e824c..50127d6 100644 --- a/pkg/cli/CheckConfig.go +++ b/pkg/cli/CheckConfig.go @@ -8,7 +8,8 @@ package cli import ( - "github.com/pkg/errors" + "fmt" + "github.com/spf13/viper" "github.com/spatialcurrent/go-simple-serializer/pkg/cli/input" @@ -19,11 +20,11 @@ import ( func CheckConfig(v *viper.Viper, formats []string) error { err := input.CheckInputConfig(v, formats) if err != nil { - return errors.Wrap(err, "error with input configuration") + return fmt.Errorf("error with input configuration: %w", err) } err = output.CheckOutputConfig(v, formats) if err != nil { - return errors.Wrap(err, "error with output configuration") + return fmt.Errorf("error with output configuration: %w", err) } return nil } diff --git a/pkg/cli/formats/NewCommand.go b/pkg/cli/formats/NewCommand.go index a2eb3e5..d4b834f 100644 --- a/pkg/cli/formats/NewCommand.go +++ b/pkg/cli/formats/NewCommand.go @@ -11,7 +11,6 @@ import ( "fmt" "strings" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -30,21 +29,21 @@ func NewCommand() *cobra.Command { err := v.BindPFlags(cmd.Flags()) if err != nil { - return errors.Wrap(err, "error binding flags") + return fmt.Errorf("error binding flags: %w", err) } v.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) v.AutomaticEnv() // set environment variables to overwrite config err = CheckFormatsConfig(v) if err != nil { - return errors.Wrap(err, "error with configuration") + return fmt.Errorf("error with configuration: %w", err) } f := v.GetString(FlagFormat) b, err := serializer.New(f).LineSeparator("\n").Serialize(gss.Formats) if err != nil { - return errors.Wrapf(err, "error serializing formats with format %q", f) + return fmt.Errorf("error serializing formats with format %q: %w", f, err) } fmt.Print(string(b)) diff --git a/pkg/cli/input/CheckInputConfig.go b/pkg/cli/input/CheckInputConfig.go index 89f0f3c..e81d5fe 100644 --- a/pkg/cli/input/CheckInputConfig.go +++ b/pkg/cli/input/CheckInputConfig.go @@ -8,7 +8,8 @@ package input import ( - "github.com/pkg/errors" + "fmt" + "github.com/spf13/viper" ) @@ -37,16 +38,16 @@ func CheckInputConfig(v *viper.Viper, formats []string) error { } if len(v.GetString(FlagInputEscapePrefix)) == 0 { if v.GetBool(FlagInputUnescapeColon) { - return errors.Wrap(ErrMissingInputEscapePrefix, "unescaping colon requires an escape prefix") + return fmt.Errorf("unescaping colon requires an escape prefix: %w", ErrMissingInputEscapePrefix) } if v.GetBool(FlagInputUnescapeEqual) { - return errors.Wrap(ErrMissingInputEscapePrefix, "unescaping equal requires an escape prefix") + return fmt.Errorf("unescaping equal requires an escape prefix: %w", ErrMissingInputEscapePrefix) } if v.GetBool(FlagInputUnescapeSpace) { - return errors.Wrap(ErrMissingInputEscapePrefix, "unescaping space requires an escape prefix") + return fmt.Errorf("unescaping space requires an escape prefix: %w", ErrMissingInputEscapePrefix) } if v.GetBool(FlagInputUnescapeNewLine) { - return errors.Wrap(ErrMissingInputEscapePrefix, "unescaping new line requires an escape prefix") + return fmt.Errorf("unescaping new line requires an escape prefix: %w", ErrMissingInputEscapePrefix) } } inputComment := v.GetString(FlagInputComment) diff --git a/pkg/cli/input/input.go b/pkg/cli/input/input.go index 3def5fb..bcebb4a 100644 --- a/pkg/cli/input/input.go +++ b/pkg/cli/input/input.go @@ -9,7 +9,7 @@ package input import ( - "github.com/pkg/errors" + "errors" ) const ( diff --git a/pkg/cli/output/CheckOutputConfig.go b/pkg/cli/output/CheckOutputConfig.go index 496f8e1..7f2c7e0 100644 --- a/pkg/cli/output/CheckOutputConfig.go +++ b/pkg/cli/output/CheckOutputConfig.go @@ -8,7 +8,9 @@ package output import ( - "github.com/pkg/errors" + "errors" + "fmt" + "github.com/spf13/viper" ) @@ -37,16 +39,16 @@ func CheckOutputConfig(v *viper.Viper, formats []string) error { } if len(v.GetString(FlagOutputEscapePrefix)) == 0 { if v.GetBool(FlagOutputEscapeColon) { - return errors.Wrap(ErrMissingOutputEscapePrefix, "escaping colon requires an escape prefix") + return fmt.Errorf("escaping colon requires an escape prefix: %w", ErrMissingOutputEscapePrefix) } if v.GetBool(FlagOutputEscapeEqual) { - return errors.Wrap(ErrMissingOutputEscapePrefix, "escaping equal requires an escape prefix") + return fmt.Errorf("escaping equal requires an escape prefix: %w", ErrMissingOutputEscapePrefix) } if v.GetBool(FlagOutputEscapeSpace) { - return errors.Wrap(ErrMissingOutputEscapePrefix, "escaping space requires an escape prefix") + return fmt.Errorf("escaping space requires an escape prefix: %w", ErrMissingOutputEscapePrefix) } if v.GetBool(FlagOutputEscapeNewLine) { - return errors.Wrap(ErrMissingOutputEscapePrefix, "escaping new line requires an escape prefix") + return fmt.Errorf("escaping new line requires an escape prefix: %w", ErrMissingOutputEscapePrefix) } } if v.GetBool(FlagOutputKeyLower) && v.GetBool(FlagOutputKeyUpper) { diff --git a/pkg/cli/output/output.go b/pkg/cli/output/output.go index e5d95a1..d34b4ea 100644 --- a/pkg/cli/output/output.go +++ b/pkg/cli/output/output.go @@ -9,7 +9,7 @@ package output import ( - "github.com/pkg/errors" + "errors" ) const ( diff --git a/pkg/fmt/Writer.go b/pkg/fmt/Writer.go index 5e2b8b7..a7aaa3d 100644 --- a/pkg/fmt/Writer.go +++ b/pkg/fmt/Writer.go @@ -8,10 +8,9 @@ package fmt import ( + "fmt" "io" "reflect" - - "github.com/pkg/errors" ) // Writer formats and writes objects to the underlying writer as formatted lines. @@ -39,7 +38,7 @@ func (w *Writer) WriteObject(obj interface{}) error { } _, err := Fprintf(w.writer, format, obj) if err != nil { - return errors.Wrap(err, "error writing to underlying writer") + return fmt.Errorf("error writing to underlying writer: %w", err) } return nil } @@ -57,7 +56,7 @@ func (w *Writer) WriteObjects(objects interface{}) error { for i := 0; i < value.Len(); i++ { err := w.WriteObject(value.Index(i).Interface()) if err != nil { - return errors.Wrap(err, "error writing object") + return fmt.Errorf("error writing object: %w", err) } } } @@ -70,7 +69,7 @@ func (w *Writer) Flush() error { if flusher, ok := w.writer.(interface{ Flush() error }); ok { err := flusher.Flush() if err != nil { - return errors.Wrap(err, "error flushing underlying writer") + return fmt.Errorf("error flushing underlying writer: %w", err) } } return nil @@ -81,7 +80,7 @@ func (w *Writer) Close() error { if closer, ok := w.writer.(io.Closer); ok { err := closer.Close() if err != nil { - return errors.Wrap(err, "error closing underlying writer") + return fmt.Errorf("error closing underlying writer: %w", err) } } return nil diff --git a/pkg/gob/Write.go b/pkg/gob/Write.go index 6133cb4..9f811cf 100644 --- a/pkg/gob/Write.go +++ b/pkg/gob/Write.go @@ -8,11 +8,10 @@ package gob import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" ) @@ -39,20 +38,20 @@ func Write(input *WriteInput) error { if inputObjectKind == reflect.Array || inputObjectKind == reflect.Slice { it, errorIterator := pipe.NewSliceIterator(inputObject) if errorIterator != nil { - return errors.Wrap(errorIterator, "error creating slice iterator") + return fmt.Errorf("error creating slice iterator: %w", errorIterator) } p = p.Input(it) } else { it, errorIterator := pipe.NewSliceIterator([]interface{}{inputObject}) if errorIterator != nil { - return errors.Wrap(errorIterator, "error creating slice iterator") + return fmt.Errorf("error creating slice iterator: %w", errorIterator) } p = p.Input(it) } w := NewWriter(input.Writer, input.Fit) errorRun := p.Output(w).Run() if errorRun != nil { - return errors.Wrap(errorRun, "error serializing gob") + return fmt.Errorf("error serializing gob: %w", errorRun) } return nil } diff --git a/pkg/gob/Writer.go b/pkg/gob/Writer.go index 098b826..9f29530 100644 --- a/pkg/gob/Writer.go +++ b/pkg/gob/Writer.go @@ -8,11 +8,10 @@ package gob import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - pkgfit "github.com/spatialcurrent/go-fit/pkg/fit" ) @@ -37,13 +36,13 @@ func (w *Writer) WriteObject(obj interface{}) error { if w.fit { err := w.encoder.EncodeValue(pkgfit.FitValue(reflect.ValueOf(obj))) if err != nil { - return errors.Wrap(err, "error writing to underlying writer") + return fmt.Errorf("error writing to underlying writer: %w", err) } return nil } err := w.encoder.EncodeValue(reflect.ValueOf(obj)) if err != nil { - return errors.Wrap(err, "error writing to underlying writer") + return fmt.Errorf("error writing to underlying writer: %w", err) } return nil } @@ -60,7 +59,7 @@ func (w *Writer) WriteObjects(objects interface{}) error { for i := 0; i < value.Len(); i++ { err := w.WriteObject(value.Index(i).Interface()) if err != nil { - return errors.Wrap(err, "error writing object") + return fmt.Errorf("error writing object: %w", err) } } } @@ -73,7 +72,7 @@ func (w *Writer) Flush() error { if flusher, ok := w.writer.(interface{ Flush() error }); ok { err := flusher.Flush() if err != nil { - return errors.Wrap(err, "error flushing underlying writer") + return fmt.Errorf("error flushing underlying writer: %w", err) } } return nil @@ -84,7 +83,7 @@ func (w *Writer) Close() error { if closer, ok := w.writer.(io.Closer); ok { err := closer.Close() if err != nil { - return errors.Wrap(err, "error closing underlying writer") + return fmt.Errorf("error closing underlying writer: %w", err) } } return nil diff --git a/pkg/gob/gob.go b/pkg/gob/gob.go index 0c28941..89f4901 100644 --- a/pkg/gob/gob.go +++ b/pkg/gob/gob.go @@ -9,7 +9,7 @@ package gob import ( - "github.com/pkg/errors" + "errors" ) var ( diff --git a/pkg/gss/Convert.go b/pkg/gss/Convert.go index 19670f5..f571c41 100644 --- a/pkg/gss/Convert.go +++ b/pkg/gss/Convert.go @@ -8,10 +8,9 @@ package gss import ( + "fmt" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -108,7 +107,7 @@ func Convert(input *ConvertInput) ([]byte, error) { obj, err := in.Deserialize(input.InputBytes) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error deserializing input") + return make([]byte, 0), fmt.Errorf("error deserializing input: %w", err) } out := serializer.New(input.OutputFormat). @@ -130,7 +129,7 @@ func Convert(input *ConvertInput) ([]byte, error) { b, err := out.Serialize(obj) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error serializing output") + return make([]byte, 0), fmt.Errorf("error serializing output: %w", err) } return b, nil diff --git a/pkg/gss/DeserializeBytes.go b/pkg/gss/DeserializeBytes.go index b41cda6..52b19dd 100644 --- a/pkg/gss/DeserializeBytes.go +++ b/pkg/gss/DeserializeBytes.go @@ -10,12 +10,11 @@ package gss import ( "bytes" "encoding/gob" + "fmt" "reflect" "github.com/hashicorp/hcl" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-simple-serializer/pkg/iterator" "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" @@ -66,12 +65,12 @@ func DeserializeBytes(input *DeserializeBytesInput) (interface{}, error) { DropCR: input.DropCR, }) if errorIterator != nil { - return nil, errors.Wrap(errorIterator, "error creating iterator") + return nil, fmt.Errorf("error creating iterator: %w", errorIterator) } w := pipe.NewSliceWriterWithValues(reflect.MakeSlice(input.Type, 0, 0).Interface()) errorRun := pipe.NewBuilder().Input(it).Output(w).Run() if errorRun != nil { - return w.Values(), errors.Wrap(errorRun, "error deserializing") + return w.Values(), fmt.Errorf("error deserializing: %w", errorRun) } return w.Values(), nil case "bson", "json", "properties", "toml", "yaml": @@ -99,13 +98,13 @@ func DeserializeBytes(input *DeserializeBytesInput) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(input.Type)) obj, err := hcl.Parse(string(input.Bytes)) if err != nil { - return nil, errors.Wrap(err, "Error parsing hcl") + return nil, fmt.Errorf("Error parsing hcl: %w", err) } if err := hcl.DecodeObject(ptr.Interface(), obj); err != nil { - return nil, errors.Wrap(err, "Error decoding hcl") + return nil, fmt.Errorf("Error decoding hcl: %w", err) } return ptr.Elem().Interface(), nil } - return nil, errors.Wrap(&ErrUnknownFormat{Name: input.Format}, "could not deserialize bytes") + return nil, fmt.Errorf("could not deserialize bytes: %w", &ErrUnknownFormat{Name: input.Format}) } diff --git a/pkg/gss/DeserializeReader.go b/pkg/gss/DeserializeReader.go index c945a42..26af79b 100644 --- a/pkg/gss/DeserializeReader.go +++ b/pkg/gss/DeserializeReader.go @@ -9,12 +9,11 @@ package gss import ( "encoding/gob" + "fmt" "io" "io/ioutil" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-simple-serializer/pkg/iterator" "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" @@ -69,7 +68,7 @@ func DeserializeReader(input *DeserializeReaderInput) (interface{}, error) { DropCR: input.DropCR, }) if errorIterator != nil { - return nil, errors.Wrap(errorIterator, "error creating iterator") + return nil, fmt.Errorf("error creating iterator: %w", errorIterator) } p := pipe.NewBuilder().Input(it) var w *pipe.SliceWriter @@ -82,7 +81,7 @@ func DeserializeReader(input *DeserializeReaderInput) (interface{}, error) { } errorRun := p.Run() if errorRun != nil { - return w.Values(), errors.Wrap(errorRun, "error deserializing") + return w.Values(), fmt.Errorf("error deserializing: %w", errorRun) } return w.Values(), nil case "gob": @@ -97,7 +96,7 @@ func DeserializeReader(input *DeserializeReaderInput) (interface{}, error) { if err == io.EOF { return nil, io.EOF } - return nil, errors.Wrap(err, "error reading bytes from reader") + return nil, fmt.Errorf("error reading bytes from reader: %w", err) } // Set up Serializer @@ -121,10 +120,10 @@ func DeserializeReader(input *DeserializeReaderInput) (interface{}, error) { // Deserialize bytes into object obj, err := s.Deserialize(b) if err != nil { - return nil, errors.Wrap(err, "error deserializing object") + return nil, fmt.Errorf("error deserializing object: %w", err) } return obj, nil } - return nil, errors.Wrap(&ErrUnknownFormat{Name: input.Format}, "could not deserialize bytes") + return nil, fmt.Errorf("could not deserialize bytes: %w", &ErrUnknownFormat{Name: input.Format}) } diff --git a/pkg/gss/GetType.go b/pkg/gss/GetType.go index 16c8386..94cd525 100644 --- a/pkg/gss/GetType.go +++ b/pkg/gss/GetType.go @@ -8,11 +8,10 @@ package gss import ( + "fmt" "reflect" "strings" "unicode" - - "github.com/pkg/errors" ) // GetType takes in the content of an object as a string and the serialization format. @@ -39,5 +38,5 @@ func GetType(content []byte, format string) (reflect.Type, error) { return reflect.TypeOf([]interface{}{}), nil } - return nil, errors.New("could not get type for format " + format) + return nil, fmt.Errorf("could not get type for format %s", format) } diff --git a/pkg/gss/SerializeBytes.go b/pkg/gss/SerializeBytes.go index e4f8a7a..b177308 100644 --- a/pkg/gss/SerializeBytes.go +++ b/pkg/gss/SerializeBytes.go @@ -11,8 +11,6 @@ import ( "fmt" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" ) @@ -92,5 +90,5 @@ func SerializeBytes(input *SerializeBytesInput) ([]byte, error) { case "hcl", "hcl2": return make([]byte, 0), fmt.Errorf("cannot serialize to format %q", f) } - return make([]byte, 0), errors.Wrap(&ErrUnknownFormat{Name: f}, "could not serialize object") + return make([]byte, 0), fmt.Errorf("could not serialize object: %w", &ErrUnknownFormat{Name: f}) } diff --git a/pkg/gss/SerializeBytes_test.go b/pkg/gss/SerializeBytes_test.go index c37a4fc..24c04ac 100644 --- a/pkg/gss/SerializeBytes_test.go +++ b/pkg/gss/SerializeBytes_test.go @@ -10,7 +10,6 @@ package gss import ( "testing" - "github.com/pkg/errors" "github.com/stretchr/testify/assert" ) @@ -131,7 +130,7 @@ func TestSerializeBytesUnknown(t *testing.T) { Object: []interface{}{"a", "b", "c"}, Format: "foo", }) - assert.IsType(t, &ErrUnknownFormat{}, errors.Cause(err)) + assert.Error(t, err) assert.Equal(t, "could not serialize object: unknown format foo", err.Error()) assert.Equal(t, []byte{}, b) } diff --git a/pkg/gss/gss.go b/pkg/gss/gss.go index d51078a..a77fb86 100644 --- a/pkg/gss/gss.go +++ b/pkg/gss/gss.go @@ -13,13 +13,13 @@ // // inputObject, err := gss.DeserializeString(string(inputBytesPlain), inputFormat, inputHeader, inputComment, inputLazyQuotes, inputLimit, inputType, verbose) // if err != nil { -// fmt.Println(errors.Wrap(err, "error deserializing input using format "+inputFormat)) +// fmt.Println(fmt.Errorf("error deserializing input using format %s: %w", inputFormat, err)) // os.Exit(1) // } // ... // str, err := gss.SerializeString(object, "json", header, -1) // if err != nil { -// return "", errors.Wrap(err, "error serializing object") +// return "", fmt.Errorf("error serializing object: %w", err) // } // // Usage with options @@ -43,7 +43,7 @@ // for inputLine := range inputLines { // inputObject, err := options.DeserializeBytes(inputLine, verbose) // if err != nil { -// errorsChannel <- errors.Wrap(err, "error deserializing input using format "+objectFormat) +// errorsChannel <- fmt.Errorf("error deserializing input using format %s: %w", objectFormat, err) // continue // } // ... @@ -55,7 +55,7 @@ package gss import ( - "github.com/pkg/errors" + "errors" "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" ) diff --git a/pkg/gssjs/Convert.go b/pkg/gssjs/Convert.go deleted file mode 100644 index 004db7f..0000000 --- a/pkg/gssjs/Convert.go +++ /dev/null @@ -1,50 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package gssjs - -import ( - "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" -) - -// Convert is a function provided to gss.js that wraps gss.Convert to support JavaScript. -func Convert(inputString string, inputFormat string, outputFormat string, deserializeOptions map[string]interface{}, serializeOptions map[string]interface{}) (string, error) { - - if len(inputString) == 0 { - return "", ErrMissingInputString - } - - if len(inputFormat) == 0 || inputFormat == "undefined" { - return "", ErrMissingInputFormat - } - - if len(outputFormat) == 0 || outputFormat == "undefined" { - return "", ErrMissingOutputFormat - } - - inputSerializer, err := serializer.NewWithOptions(inputFormat, DeserializeDefaults, deserializeOptions) - if err != nil { - return "", err - } - - object, err := inputSerializer.Deserialize([]byte(inputString)) - if err != nil { - return "", err - } - - outputSerializer, err := serializer.NewWithOptions(outputFormat, SerializeDefaults, serializeOptions) - if err != nil { - return "", err - } - - outputBytes, err := outputSerializer.Serialize(object) - if err != nil { - return "", err - } - - return string(outputBytes), nil -} diff --git a/pkg/gssjs/Deserialize.go b/pkg/gssjs/Deserialize.go deleted file mode 100644 index 4e5daea..0000000 --- a/pkg/gssjs/Deserialize.go +++ /dev/null @@ -1,34 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package gssjs - -import ( - "github.com/pkg/errors" - - "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" -) - -// Deserialize is a function provided to gss.js that wraps gss.Deserialize to support JavaScript. -//func Deserialize(inputString string, inputFormat string, options *js.Object) interface{} { -func Deserialize(inputString string, inputFormat string, options map[string]interface{}) (interface{}, error) { - - if len(inputFormat) == 0 || inputFormat == "undefined" { - return "", ErrMissingInputFormat - } - - s, err := serializer.NewWithOptions(inputFormat, DeserializeDefaults, options) - if err != nil { - return nil, errors.Wrap(err, "error creating serializer") - } - - out, err := s.Deserialize([]byte(inputString)) - if err != nil { - return nil, errors.Wrap(err, "error deserializing") - } - return out, nil -} diff --git a/pkg/gssjs/Exports.go b/pkg/gssjs/Exports.go deleted file mode 100644 index b3a89e8..0000000 --- a/pkg/gssjs/Exports.go +++ /dev/null @@ -1,59 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package gssjs - -import ( - "github.com/gopherjs/gopherjs/js" - "github.com/pkg/errors" - - "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" -) - -func isArray(object *js.Object) bool { - return js.Global.Get("Array").Call("isArray", object).Bool() -} - -func toArray(object *js.Object) []interface{} { - arr := make([]interface{}, 0, object.Length()) - for i := 0; i < object.Length(); i++ { - arr = append(arr, parseObject(object.Index(i))) - } - return arr -} - -func parseObject(object *js.Object) interface{} { - if isArray(object) { - return toArray(object) - } - return object.Interface() -} - -var Exports = map[string]interface{}{ - "formats": serializer.Formats, - "convert": func(inputString string, inputFormat string, outputFormat string, inputOptions map[string]interface{}, outputOptions map[string]interface{}) map[string]interface{} { - str, err := Convert(inputString, inputFormat, outputFormat, inputOptions, outputOptions) - if err != nil { - return map[string]interface{}{"str": nil, "err": errors.Wrap(err, "error converting input string").Error()} - } - return map[string]interface{}{"str": str, "err": nil} - }, - "deserialize": func(inputString string, inputFormat string, options map[string]interface{}) map[string]interface{} { - obj, err := Deserialize(inputString, inputFormat, options) - if err != nil { - return map[string]interface{}{"obj": nil, "err": errors.Wrap(err, "error deserializing input string").Error()} - } - return map[string]interface{}{"obj": obj, "err": nil} - }, - "serialize": func(inputObject *js.Object, outputFormat string, options map[string]interface{}) map[string]interface{} { - str, err := Serialize(parseObject(inputObject), outputFormat, options) - if err != nil { - return map[string]interface{}{"str": nil, "err": errors.Wrap(err, "error serializing input object").Error()} - } - return map[string]interface{}{"str": str, "err": nil} - }, -} diff --git a/pkg/gssjs/Serialize.go b/pkg/gssjs/Serialize.go deleted file mode 100644 index f1afb5d..0000000 --- a/pkg/gssjs/Serialize.go +++ /dev/null @@ -1,34 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package gssjs - -import ( - "github.com/pkg/errors" - - "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" -) - -// Serialize is a function provided to gss.js that wraps gss.Serialize to support JavaScript. -//func Serialize(inputObject interface{}, outputFormat string, options *js.Object) interface{} { -func Serialize(inputObject interface{}, outputFormat string, options map[string]interface{}) (string, error) { - - if len(outputFormat) == 0 || outputFormat == "undefined" { - return "", ErrMissingOutputFormat - } - - s, err := serializer.NewWithOptions(outputFormat, SerializeDefaults, options) - if err != nil { - return "", errors.Wrap(err, "error creating serializer") - } - - outputBytes, err := s.Serialize(inputObject) - if err != nil { - return "", errors.Wrap(err, "error serializing") - } - return string(outputBytes), nil -} diff --git a/pkg/gssjs/Serialize_test.go b/pkg/gssjs/Serialize_test.go deleted file mode 100644 index b9f2f5d..0000000 --- a/pkg/gssjs/Serialize_test.go +++ /dev/null @@ -1,166 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package gssjs - -import ( - "testing" - - "github.com/stretchr/testify/require" -) - -func TestSerializeJsonNil(t *testing.T) { - str, err := Serialize(nil, "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "null", str) -} - -func TestSerializeJsonTrue(t *testing.T) { - str, err := Serialize(true, "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "true", str) -} - -func TestSerializeJsonFalse(t *testing.T) { - str, err := Serialize(false, "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "false", str) -} - -func TestSerializeJsonSlice(t *testing.T) { - str, err := Serialize([]interface{}{"a", "b", "c"}, "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "[\"a\",\"b\",\"c\"]", str) -} - -func TestSerializeJsonSlicePretty(t *testing.T) { - str, err := Serialize([]interface{}{"a", "b", "c"}, "json", map[string]interface{}{ - "pretty": true, - }) - require.NoError(t, err) - require.Equal(t, "[\n \"a\",\n \"b\",\n \"c\"\n]", str) -} - -func TestSerializeJsonMap(t *testing.T) { - str, err := Serialize(map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0}, "json", map[string]interface{}{ - "pretty": false, - }) - require.NoError(t, err) - require.Equal(t, "{\"a\":1,\"b\":2,\"c\":3}", str) -} - -func TestSerializeJsonMapPretty(t *testing.T) { - str, err := Serialize(map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0}, "json", map[string]interface{}{ - "pretty": true, - }) - require.NoError(t, err) - require.Equal(t, "{\n \"a\": 1,\n \"b\": 2,\n \"c\": 3\n}", str) -} - -func TestSerializeJsonString(t *testing.T) { - str, err := Serialize("hello world", "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "\"hello world\"", str) -} - -func TestSerializeJsonStringPtr(t *testing.T) { - in := "hello world" - str, err := Serialize(&in, "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "\"hello world\"", str) -} - -func TestSerializeJsonFloat(t *testing.T) { - str, err := Serialize(123.456, "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "123.456", str) -} - -func TestSerializeJsonStruct(t *testing.T) { - in := struct { - A string - B string - C string - }{ - A: "1", - B: "2", - C: "3", - } - str, err := Serialize(in, "json", map[string]interface{}{}) - require.NoError(t, err) - require.Equal(t, "{\"A\":\"1\",\"B\":\"2\",\"C\":\"3\"}", str) -} - -func TestSerializeBytesTags(t *testing.T) { - in := map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0} - b, err := Serialize(in, "tags", map[string]interface{}{ - "sorted": true, - }) - require.NoError(t, err) - require.Equal(t, "a=1 b=2 c=3", string(b)) -} - -func TestSerializeBytesTagsMultiple(t *testing.T) { - in := []interface{}{ - map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0}, - map[string]interface{}{"a": "x", "b": "y", "c": "z"}, - } - b, err := Serialize(in, "tags", map[string]interface{}{ - "sorted": true, - }) - require.NoError(t, err) - require.Equal(t, "a=1 b=2 c=3\na=x b=y c=z\n", string(b)) -} - -/* - -func TestSerializeBytesUnknown(t *testing.T) { - b, err := SerializeBytes(&SerializeBytesInput{ - Object: []interface{}{"a", "b", "c"}, - Format: "foo", - }) - assert.IsType(t, &ErrUnknownFormat{}, errors.Cause(err)) - assert.Equal(t, "could not serialize object: unknown format foo", err.Error()) - assert.Equal(t, []byte{}, b) -} - -func TestSerializeBytesCsvSlice(t *testing.T) { - b, err := SerializeBytes(&SerializeBytesInput{ - Object: []interface{}{map[string]string{"a": "x", "b": "y", "c": "z"}}, - Format: "csv", - Limit: NoLimit, - Sorted: true, - }) - assert.NoError(t, err) - assert.Equal(t, "a,b,c\nx,y,z\n", string(b)) -} - -func TestSerializeBytesTsvSlice(t *testing.T) { - b, err := SerializeBytes(&SerializeBytesInput{ - Object: []interface{}{map[string]string{"a": "x", "b": "y", "c": "z"}}, - Format: "tsv", - Limit: NoLimit, - Sorted: true, - }) - assert.NoError(t, err) - assert.Equal(t, "a\tb\tc\nx\ty\tz\n", string(b)) -} - - - -func TestSerializeBytesTagsMultiple(t *testing.T) { - b, err := SerializeBytes(&SerializeBytesInput{ - Object: , - Format: "tags", - LineSeparator: "\n", - Sorted: true, - }) - assert.NoError(t, err) - assert.Equal(t, "a=1 b=2 c=3\na=x b=y c=z\n", string(b)) -} - -*/ diff --git a/pkg/gssjs/gssjs.go b/pkg/gssjs/gssjs.go deleted file mode 100644 index 8953e3f..0000000 --- a/pkg/gssjs/gssjs.go +++ /dev/null @@ -1,41 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -// Package gssjs includes functions for the JavaScript build of GSS. -// -package gssjs - -import ( - "github.com/pkg/errors" -) - -const ( - NoLimit = -1 -) - -var ( - ErrMissingInputString = errors.New("missing input string") - ErrMissingInputObject = errors.New("missing input object") - ErrMissingInputFormat = errors.New("missing input format") - ErrMissingOutputFormat = errors.New("missing output format") -) - -var ( - DeserializeDefaults = map[string]interface{}{ - "limit": NoLimit, - "keyValueSeparator": "=", - "lineSeparator": "\n", - "escapePrefix": "\\", - "expandHeader": true, - } - SerializeDefaults = map[string]interface{}{ - "limit": NoLimit, - "keyValueSeparator": "=", - "lineSeparator": "\n", - "escapePrefix": "\\", - } -) diff --git a/pkg/iterator/Iterator.go b/pkg/iterator/Iterator.go index 8ee4d99..edf3ac7 100644 --- a/pkg/iterator/Iterator.go +++ b/pkg/iterator/Iterator.go @@ -13,11 +13,11 @@ package iterator import ( + "errors" + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/gob" "github.com/spatialcurrent/go-simple-serializer/pkg/jsonl" "github.com/spatialcurrent/go-simple-serializer/pkg/sv" @@ -85,7 +85,7 @@ func NewIterator(input *NewIteratorInput) (Iterator, error) { Limit: input.Limit, }) if err != nil { - return it, errors.Wrap(err, "error creating CSV iterator") + return it, fmt.Errorf("error creating CSV iterator: %w", err) } return it, nil case "gob": @@ -124,7 +124,7 @@ func NewIterator(input *NewIteratorInput) (Iterator, error) { Limit: input.Limit, }) if err != nil { - return it, errors.Wrap(err, "error creating tags iterator") + return it, fmt.Errorf("error creating tags iterator: %w", err) } return it, nil case "tsv": @@ -139,7 +139,7 @@ func NewIterator(input *NewIteratorInput) (Iterator, error) { Limit: input.Limit, }) if err != nil { - return it, errors.Wrap(err, "error creating TSV iterator") + return it, fmt.Errorf("error creating TSV iterator: %w", err) } return it, nil } diff --git a/pkg/json/Unmarshal.go b/pkg/json/Unmarshal.go index bef5cf0..04bbb6b 100644 --- a/pkg/json/Unmarshal.go +++ b/pkg/json/Unmarshal.go @@ -12,9 +12,6 @@ import ( stdjson "encoding/json" // import the standard json library as stdjson "fmt" "unicode/utf8" - - "github.com/pkg/errors" - // utf8 is used to decode the first rune in the string ) // Unmarshal parses a slice of bytes into an object using a few simple type inference rules. @@ -58,21 +55,21 @@ func Unmarshal(b []byte) (interface{}, error) { obj := make([]interface{}, 0) err := stdjson.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into %T", string(b), obj)) + return nil, fmt.Errorf("error unmarshaling JSON %q into %T: %w", string(b), obj, err) } return obj, nil case '{': obj := map[string]interface{}{} err := stdjson.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into %T", string(b), obj)) + return nil, fmt.Errorf("error unmarshaling JSON %q into %T: %w", string(b), obj, err) } return obj, nil case '"': obj := "" err := stdjson.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into string", string(b))) + return nil, fmt.Errorf("error unmarshaling JSON %q into string: %w", string(b), err) } return obj, nil } @@ -80,7 +77,7 @@ func Unmarshal(b []byte) (interface{}, error) { obj := 0.0 err := stdjson.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into float", string(b))) + return nil, fmt.Errorf("error unmarshaling JSON %q into float: %w", string(b), err) } return obj, nil } diff --git a/pkg/json/UnmarshalType.go b/pkg/json/UnmarshalType.go index d175770..2bca5d1 100644 --- a/pkg/json/UnmarshalType.go +++ b/pkg/json/UnmarshalType.go @@ -13,8 +13,6 @@ import ( "reflect" "unicode/utf8" - - "github.com/pkg/errors" // utf8 is used to decode the first rune in the string ) // UnmarshalType parses a slice of bytes into an object of a given type. @@ -60,7 +58,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeSlice(outputType, 0, 0)) err := stdjson.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into %T", string(b), ptr.Interface())) + return nil, fmt.Errorf("error unmarshaling JSON %q into %T: %w", string(b), ptr.Interface(), err) } return ptr.Elem().Interface(), nil case '{': @@ -70,14 +68,14 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(outputType)) err := stdjson.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into %T", string(b), ptr.Interface())) + return nil, fmt.Errorf("error unmarshaling JSON %q into %T: %w", string(b), ptr.Interface(), err) } return ptr.Elem().Interface(), nil case reflect.Struct: ptr := reflect.New(outputType) err := stdjson.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into %T", string(b), ptr.Interface())) + return nil, fmt.Errorf("error unmarshaling JSON %q into %T: %w", string(b), ptr.Interface(), err) } return ptr.Elem().Interface(), nil } @@ -89,7 +87,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { obj := "" err := stdjson.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into string", string(b))) + return nil, fmt.Errorf("error unmarshaling JSON %q into string: %w", string(b), err) } return obj, nil } @@ -100,7 +98,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { obj := 0.0 err := stdjson.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling JSON %q into float", string(b))) + return nil, fmt.Errorf("error unmarshaling JSON %q into float: %w", string(b), err) } return obj, nil } diff --git a/pkg/json/json.go b/pkg/json/json.go index 761968c..7c4613a 100644 --- a/pkg/json/json.go +++ b/pkg/json/json.go @@ -10,7 +10,7 @@ package json import ( - "github.com/pkg/errors" + "errors" ) var ( diff --git a/pkg/jsonl/Iterator.go b/pkg/jsonl/Iterator.go index b16986e..289e11b 100644 --- a/pkg/jsonl/Iterator.go +++ b/pkg/jsonl/Iterator.go @@ -10,11 +10,10 @@ package jsonl import ( "bufio" "bytes" + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/json" "github.com/spatialcurrent/go-simple-serializer/pkg/scanner" ) @@ -109,13 +108,13 @@ func (it *Iterator) Next() (interface{}, error) { if it.Type != nil { obj, err := json.UnmarshalType(line, it.Type) if err != nil { - return obj, errors.Wrap(err, "error unmarshaling next JSON object") + return obj, fmt.Errorf("error unmarshaling next JSON object: %w", err) } return obj, nil } obj, err := json.Unmarshal(line) if err != nil { - return obj, errors.Wrap(err, "error unmarshaling next JSON object") + return obj, fmt.Errorf("error unmarshaling next JSON object: %w", err) } return obj, nil } diff --git a/pkg/jsonl/Marshal.go b/pkg/jsonl/Marshal.go index da62928..cbf1782 100644 --- a/pkg/jsonl/Marshal.go +++ b/pkg/jsonl/Marshal.go @@ -9,8 +9,7 @@ package jsonl import ( "bytes" - - "github.com/pkg/errors" + "fmt" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -26,7 +25,7 @@ func Marshal(object interface{}, lineSeparator string, keySerializer stringify.S Limit: limit, }) if err != nil { - return nil, errors.Wrap(err, "error writing json lines") + return nil, fmt.Errorf("error writing json lines: %w", err) } return buf.Bytes(), nil } diff --git a/pkg/jsonl/Write.go b/pkg/jsonl/Write.go index 6d18036..fe5cc90 100644 --- a/pkg/jsonl/Write.go +++ b/pkg/jsonl/Write.go @@ -8,11 +8,10 @@ package jsonl import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -46,20 +45,20 @@ func Write(input *WriteInput) error { } it, errorIterator := pipe.NewSliceIterator(inputObject) if errorIterator != nil { - return errors.Wrap(errorIterator, "error creating slice iterator") + return fmt.Errorf("error creating slice iterator: %w", errorIterator) } p = p.Input(it) } else { it, errorIterator := pipe.NewSliceIterator([]interface{}{inputObject}) if errorIterator != nil { - return errors.Wrap(errorIterator, "error creating slice iterator") + return fmt.Errorf("error creating slice iterator: %w", errorIterator) } p = p.Input(it) } w := NewWriter(input.Writer, input.LineSeparator, input.KeySerializer, input.Pretty) errorRun := p.Output(w).Run() if errorRun != nil { - return errors.Wrap(errorRun, "error serializing jsonl") + return fmt.Errorf("error serializing jsonl: %w", errorRun) } return nil } diff --git a/pkg/jsonl/Writer.go b/pkg/jsonl/Writer.go index 245dfb5..7bf8b58 100644 --- a/pkg/jsonl/Writer.go +++ b/pkg/jsonl/Writer.go @@ -8,11 +8,10 @@ package jsonl import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/json" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -40,18 +39,18 @@ func NewWriter(w io.Writer, separator string, keySerializer stringify.Stringer, func (w *Writer) WriteObject(obj interface{}) error { obj, err := stringify.StringifyMapKeys(obj, w.keySerializer) if err != nil { - return errors.Wrap(err, "error stringify map keys") + return fmt.Errorf("error stringify map keys: %w", err) } b, err := json.Marshal(obj, w.pretty) if err != nil { - return errors.Wrap(err, "error marshaling object") + return fmt.Errorf("error marshaling object: %w", err) } if len(w.separator) > 0 { b = append(b, []byte(w.separator)...) } _, err = w.writer.Write(b) if err != nil { - return errors.Wrap(err, "error writing to underlying writer") + return fmt.Errorf("error writing to underlying writer: %w", err) } return nil } @@ -69,7 +68,7 @@ func (w *Writer) WriteObjects(objects interface{}) error { for i := 0; i < value.Len(); i++ { err := w.WriteObject(value.Index(i).Interface()) if err != nil { - return errors.Wrap(err, "error writing object") + return fmt.Errorf("error writing object: %w", err) } } } @@ -82,7 +81,7 @@ func (w *Writer) Flush() error { if flusher, ok := w.writer.(Flusher); ok { err := flusher.Flush() if err != nil { - return errors.Wrap(err, "error flushing underlying writer") + return fmt.Errorf("error flushing underlying writer: %w", err) } } return nil @@ -93,7 +92,7 @@ func (w *Writer) Close() error { if closer, ok := w.writer.(io.Closer); ok { err := closer.Close() if err != nil { - return errors.Wrap(err, "error closing underlying writer") + return fmt.Errorf("error closing underlying writer: %w", err) } } return nil diff --git a/pkg/jsonl/jsonl.go b/pkg/jsonl/jsonl.go index 79b2db0..891bd39 100644 --- a/pkg/jsonl/jsonl.go +++ b/pkg/jsonl/jsonl.go @@ -14,7 +14,7 @@ package jsonl import ( - "github.com/pkg/errors" + "errors" ) var ( diff --git a/pkg/mapper/Marshal.go b/pkg/mapper/Marshal.go index e50a4cc..f0a4b3f 100644 --- a/pkg/mapper/Marshal.go +++ b/pkg/mapper/Marshal.go @@ -8,10 +8,9 @@ package mapper import ( + "fmt" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/tagger" ) @@ -125,7 +124,7 @@ func Marshal(object interface{}) (interface{}, error) { for i := 0; i < v.Len(); i++ { element, err := Marshal(v.Index(i).Interface()) if err != nil { - return nil, errors.Wrapf(err, "error marshaling %#v", v.Index(i).Interface()) + return nil, fmt.Errorf("error marshaling %#v: %w", v.Index(i).Interface(), err) } out = append(out, element) } @@ -138,7 +137,7 @@ func Marshal(object interface{}) (interface{}, error) { for it := in.MapRange(); it.Next(); { v, err := Marshal(it.Value().Interface()) if err != nil { - return nil, errors.Wrapf(err, "error marshaling %#v", it.Value().Interface()) + return nil, fmt.Errorf("error marshaling %#v: %w", it.Value().Interface(), err) } out.SetMapIndex(it.Key(), reflect.ValueOf(v)) } @@ -155,7 +154,7 @@ func Marshal(object interface{}) (interface{}, error) { tagValue, err := tagger.Lookup(f.Tag, "map") if err != nil { - return nil, errors.Wrapf(err, "error unmarshaling struct tag value %q", f.Tag) + return nil, fmt.Errorf("error unmarshaling struct tag value %q: %w", f.Tag, err) } key := f.Name @@ -192,7 +191,7 @@ func Marshal(object interface{}) (interface{}, error) { // Marshal the underlying value mfv, err := Marshal(fv.Interface()) if err != nil { - return nil, errors.Wrapf(err, "error marshaling value for field %v", f.Name) + return nil, fmt.Errorf("error marshaling value for field %v: %w", f.Name, err) } // If marshaled field value is empty diff --git a/pkg/mapper/Unmarshal.go b/pkg/mapper/Unmarshal.go index 9259dcc..b25733c 100644 --- a/pkg/mapper/Unmarshal.go +++ b/pkg/mapper/Unmarshal.go @@ -8,10 +8,9 @@ package mapper import ( + "fmt" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/tagger" ) @@ -31,11 +30,11 @@ func UnmarshalValue(sourceValue reflect.Value, targetValue reflect.Value) error } if !targetValue.CanAddr() { - return errors.Errorf("target %#v (%v) is not addressable", targetValue.Interface(), targetValue.Type()) + return fmt.Errorf("target %#v (%v) is not addressable", targetValue.Interface(), targetValue.Type()) } if !targetValue.CanSet() { - return errors.Errorf("target %#v (%v) cannot be set", targetValue.Interface(), targetValue.Type()) + return fmt.Errorf("target %#v (%v) cannot be set", targetValue.Interface(), targetValue.Type()) } // If source value is not valid, then set the targetValue to it's zero value. @@ -55,7 +54,7 @@ func UnmarshalValue(sourceValue reflect.Value, targetValue reflect.Value) error if sourceKind == reflect.Interface { if !sourceValue.CanInterface() { - return errors.Errorf("source %v (%v) is of kind interface", sourceValue, sourceValue.Type()) + return fmt.Errorf("source %v (%v) is of kind interface", sourceValue, sourceValue.Type()) } // Re-value the object return UnmarshalValue(reflect.ValueOf(sourceValue.Interface()), targetValue) @@ -89,7 +88,7 @@ func UnmarshalValue(sourceValue reflect.Value, targetValue reflect.Value) error if sourceKind == reflect.Map { if !reflect.TypeOf("").AssignableTo(sourceType.Key()) { - return errors.Errorf("string is not assignable to source map key %q", sourceType.Key()) + return fmt.Errorf("string is not assignable to source map key %q", sourceType.Key()) } // Iterate throught the struct fields @@ -107,7 +106,7 @@ func UnmarshalValue(sourceValue reflect.Value, targetValue reflect.Value) error tagValue, err := tagger.Lookup(f.Tag, "map") if err != nil { - return errors.Wrapf(err, "error unmarshaling struct tag value %q", f.Tag) + return fmt.Errorf("error unmarshaling struct tag value %q: %w", f.Tag, err) } key := f.Name @@ -137,7 +136,7 @@ func UnmarshalValue(sourceValue reflect.Value, targetValue reflect.Value) error // unmarshal the concrete map value into the field err = UnmarshalFieldValue(reflect.ValueOf(mv.Interface()), fv) if err != nil { - return errors.Wrapf(err, "key %q found, but could not assign to field %q", key, f.Name) + return fmt.Errorf("key %q found, but could not assign to field %q: %w", key, f.Name, err) } } return nil diff --git a/pkg/mapper/UnmarshalFieldValue.go b/pkg/mapper/UnmarshalFieldValue.go index 4ca5ee2..f43e576 100644 --- a/pkg/mapper/UnmarshalFieldValue.go +++ b/pkg/mapper/UnmarshalFieldValue.go @@ -8,10 +8,9 @@ package mapper import ( + "fmt" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-fit/pkg/fit" ) @@ -64,5 +63,5 @@ func UnmarshalFieldValue(source reflect.Value, target reflect.Value) error { return nil } - return errors.Errorf("value %#v (%q) not assignable to field type %q", source.Interface(), source.Type(), target.Type()) + return fmt.Errorf("value %#v (%q) not assignable to field type %q", source.Interface(), source.Type(), target.Type()) } diff --git a/pkg/mapper/UnmarshalMap.go b/pkg/mapper/UnmarshalMap.go index 78002ed..89959c2 100644 --- a/pkg/mapper/UnmarshalMap.go +++ b/pkg/mapper/UnmarshalMap.go @@ -8,9 +8,8 @@ package mapper import ( + "fmt" "reflect" - - "github.com/pkg/errors" ) // UnmarshalMap unmarshals the given map into the value, and returns an error, if any. @@ -33,15 +32,15 @@ func UnmarshalMapValue(sourceValue reflect.Value, targetValue reflect.Value) err } if !targetValue.CanAddr() { - return errors.Errorf("target %#v (%T) is not addressable", targetValue, targetValue) + return fmt.Errorf("target %#v (%T) is not addressable", targetValue, targetValue) } if !targetValue.CanSet() { - return errors.Errorf("target %#v (%T) cannot be set", targetValue, targetValue) + return fmt.Errorf("target %#v (%T) cannot be set", targetValue, targetValue) } if targetKind != reflect.Map { - return errors.Errorf("target element is of type %v, expecting kind of map", targetType) + return fmt.Errorf("target element is of type %v, expecting kind of map", targetType) } if !sourceValue.IsValid() { @@ -59,7 +58,7 @@ func UnmarshalMapValue(sourceValue reflect.Value, targetValue reflect.Value) err // Only accept map input if sourceKind != reflect.Map { - return errors.Errorf("source is of type %v, expecting kind of map", sourceValue.Type()) + return fmt.Errorf("source is of type %v, expecting kind of map", sourceValue.Type()) } if sourceValue.Len() == 0 { @@ -68,7 +67,7 @@ func UnmarshalMapValue(sourceValue reflect.Value, targetValue reflect.Value) err } if !sourceType.Key().AssignableTo(targetType.Key()) { - return errors.Errorf("source map key %q is not assignable to target map key %q", sourceType.Key(), targetType.Key()) + return fmt.Errorf("source map key %q is not assignable to target map key %q", sourceType.Key(), targetType.Key()) } // create the output slice @@ -78,7 +77,7 @@ func UnmarshalMapValue(sourceValue reflect.Value, targetValue reflect.Value) err v := reflect.New(targetType.Elem()) err := UnmarshalValue(it.Value(), v.Elem()) if err != nil { - return errors.Wrapf(err, "error unmarshaling %#v", it.Value().Interface()) + return fmt.Errorf("error unmarshaling %#v: %W", it.Value().Interface(), err) } out.SetMapIndex(it.Key(), v.Elem()) } diff --git a/pkg/mapper/UnmarshalSlice.go b/pkg/mapper/UnmarshalSlice.go index 15cb00f..bfcb8ff 100644 --- a/pkg/mapper/UnmarshalSlice.go +++ b/pkg/mapper/UnmarshalSlice.go @@ -8,9 +8,8 @@ package mapper import ( + "fmt" "reflect" - - "github.com/pkg/errors" ) // UnmarshalSlice unmarshals the given array or slice into the value, and returns an error, if any. @@ -28,7 +27,7 @@ func UnmarshalSliceValue(source reflect.Value, target reflect.Value) error { // Only accept array or slice input if sourceKind != reflect.Array && sourceKind != reflect.Slice { - return errors.Errorf("source is of type %v, expecting kind of array or slice", source.Type()) + return fmt.Errorf("source is of type %v, expecting kind of array or slice", source.Type()) } targetType := target.Type() @@ -40,15 +39,15 @@ func UnmarshalSliceValue(source reflect.Value, target reflect.Value) error { } if !target.CanAddr() { - return errors.Errorf("target %#v (%T) is not addressable", target, target) + return fmt.Errorf("target %#v (%T) is not addressable", target, target) } if !target.CanSet() { - return errors.Errorf("target %#v (%T) cannot be set", target, target) + return fmt.Errorf("target %#v (%T) cannot be set", target, target) } if targetKind != reflect.Slice { - return errors.Errorf("target element is of type %v, expecting kind of slice", targetType) + return fmt.Errorf("target element is of type %v, expecting kind of slice", targetType) } if source.Len() == 0 { @@ -65,7 +64,7 @@ func UnmarshalSliceValue(source reflect.Value, target reflect.Value) error { v.Elem().Set(reflect.Zero(targetType.Elem().Elem())) err := UnmarshalValue(reflect.ValueOf(source.Index(i).Interface()), v.Elem()) if err != nil { - return errors.Wrapf(err, "error unmarshaling slice value %d", i) + return fmt.Errorf("error unmarshaling slice value %d: %w", i, err) } out = reflect.Append(out, v) } @@ -79,7 +78,7 @@ func UnmarshalSliceValue(source reflect.Value, target reflect.Value) error { } err := UnmarshalValue(reflect.ValueOf(source.Index(i).Interface()), v.Elem()) if err != nil { - return errors.Wrapf(err, "error unmarshaling slice value %d", i) + return fmt.Errorf("error unmarshaling slice value %d: %w", i, err) } out = reflect.Append(out, v.Elem()) } diff --git a/pkg/properties/Read.go b/pkg/properties/Read.go index 20b5f2d..ba131c4 100644 --- a/pkg/properties/Read.go +++ b/pkg/properties/Read.go @@ -8,12 +8,11 @@ package properties import ( + "fmt" "reflect" "strings" "unicode" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/escaper" "github.com/spatialcurrent/go-simple-serializer/pkg/scanner" ) @@ -76,7 +75,7 @@ func Read(input *ReadInput) (interface{}, error) { } } if len(propertyName) == 0 { - return nil, errors.New("error deserializing properties for property " + property) + return nil, fmt.Errorf("error deserializing properties for property %s", property) } m.SetMapIndex( reflect.ValueOf(e.Unescape(strings.TrimSpace(propertyName))), diff --git a/pkg/properties/Write.go b/pkg/properties/Write.go index 627f0b6..0656acf 100644 --- a/pkg/properties/Write.go +++ b/pkg/properties/Write.go @@ -13,8 +13,6 @@ import ( "reflect" "strings" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/escaper" "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" "github.com/spatialcurrent/go-stringify/pkg/stringify" @@ -94,7 +92,7 @@ func Write(input *WriteInput) error { for i, key := range keys { keyString, errorKey := keySerializer(key) if errorKey != nil { - return errors.Wrap(errorKey, "error serializing property key") + return fmt.Errorf("error serializing property key: %w", errorKey) } if strings.Contains(keyString, kvSeparator) { switch kvSeparator { @@ -114,7 +112,7 @@ func Write(input *WriteInput) error { } valueString, errorValue := valueSerializer(m.MapIndex(reflect.ValueOf(key)).Interface()) if errorValue != nil { - return errors.Wrap(errorValue, "error serializing property value") + return fmt.Errorf("error serializing property value: %w", errorValue) } line := e.Escape(keyString) + kvSeparator + e.Escape(valueString) if i < m.Len()-1 { @@ -122,7 +120,7 @@ func Write(input *WriteInput) error { } _, errorWrite := outputWriter.Write([]byte(line)) if errorWrite != nil { - return errors.Wrap(errorWrite, "error writing property to output writer") + return fmt.Errorf("error writing property to output writer: %w", errorWrite) } } return nil @@ -134,11 +132,11 @@ func Write(input *WriteInput) error { for i, fieldName := range fieldNames { keyString, errorKey := keySerializer(fieldName) if errorKey != nil { - return errors.Wrap(errorKey, "error serializing property key") + return fmt.Errorf("error serializing property key: %w", errorKey) } fieldValue, errorValue := valueSerializer(s.FieldByName(fieldName).Interface()) if errorValue != nil { - return errors.Wrap(errorValue, "error serializing property value") + return fmt.Errorf("error serializing property value: %w", errorValue) } // don't need to escape field name since go field names are already valid line := keyString + kvSeparator + e.Escape(fieldValue) @@ -147,7 +145,7 @@ func Write(input *WriteInput) error { } _, errorWrite := outputWriter.Write([]byte(line)) if errorWrite != nil { - return errors.Wrap(errorWrite, "error writing property to output writer") + return fmt.Errorf("error writing property to output writer: %w", errorWrite) } } return nil diff --git a/pkg/properties/properties.go b/pkg/properties/properties.go index 8317e1b..3bb4d44 100644 --- a/pkg/properties/properties.go +++ b/pkg/properties/properties.go @@ -14,7 +14,7 @@ package properties import ( - "github.com/pkg/errors" + "errors" ) var ( diff --git a/pkg/serializer/Serializer.go b/pkg/serializer/Serializer.go index 7527e7c..a7e5da2 100644 --- a/pkg/serializer/Serializer.go +++ b/pkg/serializer/Serializer.go @@ -11,11 +11,11 @@ package serializer import ( "bytes" + "errors" "fmt" "reflect" "github.com/hashicorp/hcl" - "github.com/pkg/errors" "github.com/spatialcurrent/go-fit/pkg/fit" @@ -529,10 +529,10 @@ func (s *Serializer) Deserialize(b []byte) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(objectType)) obj, err := hcl.Parse(string(b)) if err != nil { - return nil, errors.Wrap(err, "Error parsing hcl") + return nil, fmt.Errorf("Error parsing hcl: %w", err) } if err := hcl.DecodeObject(ptr.Interface(), obj); err != nil { - return nil, errors.Wrap(err, "Error decoding hcl") + return nil, fmt.Errorf("Error decoding hcl: %w", err) } return ptr.Elem().Interface(), nil } @@ -556,7 +556,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { case FormatBSON: o, err := stringify.StringifyMapKeys(object, keySerializer) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error stringifying map keys") + return make([]byte, 0), fmt.Errorf("error stringifying map keys: %w", err) } return bson.Marshal(o) case FormatCSV, FormatTSV: @@ -578,7 +578,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { Limit: s.limit, }) if errWrite != nil { - return make([]byte, 0), errors.Wrap(errWrite, "error writing separated values") + return make([]byte, 0), fmt.Errorf("error writing separated values: %w", errWrite) } return buf.Bytes(), nil case FormatFmt: @@ -602,7 +602,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { case FormatJSON: o, err := stringify.StringifyMapKeys(object, keySerializer) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error stringifying map keys") + return make([]byte, 0), fmt.Errorf("error stringifying map keys: %w", err) } return json.Marshal(o, s.pretty) case FormatJSONL: @@ -625,7 +625,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { EscapeEqual: s.escapeEqual, }) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing properties") + return make([]byte, 0), fmt.Errorf("error writing properties: %w", err) } return buf.Bytes(), nil case FormatTags: @@ -647,13 +647,13 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { Limit: s.limit, }) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing tags") + return make([]byte, 0), fmt.Errorf("error writing tags: %w", err) } return buf.Bytes(), nil case FormatTOML, FormatYAML: o, err := stringify.StringifyMapKeys(object, keySerializer) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error stringifying map keys") + return make([]byte, 0), fmt.Errorf("error stringifying map keys: %w", err) } return MarshalFuncs[s.format](o) } diff --git a/pkg/sv/Iterator.go b/pkg/sv/Iterator.go index 0447206..e7ec182 100644 --- a/pkg/sv/Iterator.go +++ b/pkg/sv/Iterator.go @@ -9,10 +9,10 @@ package sv import ( "encoding/csv" + "errors" + "fmt" "io" "reflect" - - "github.com/pkg/errors" ) // Iterator is used to iterate over a table of separated values. @@ -59,7 +59,7 @@ func NewIterator(input *NewIteratorInput) (*Iterator, error) { if err == io.EOF { return nil, err } - return nil, errors.Wrap(err, "error skipping lines") + return nil, fmt.Errorf("error skipping lines: %w", err) } } @@ -70,7 +70,7 @@ func NewIterator(input *NewIteratorInput) (*Iterator, error) { if err == io.EOF { return nil, err } - return nil, errors.Wrap(err, "error reading header") + return nil, fmt.Errorf("error reading header: %w", err) } header = make([]interface{}, 0, len(h)) for _, str := range h { @@ -97,7 +97,7 @@ func (it *Iterator) Next() (interface{}, error) { if err == io.EOF { return nil, err } - return nil, errors.Wrap(err, "error reading next line") + return nil, fmt.Errorf("error reading next line: %w", err) } m := reflect.MakeMap(it.Type) for i, h := range it.header { diff --git a/pkg/sv/Read.go b/pkg/sv/Read.go index b73dc42..434399b 100644 --- a/pkg/sv/Read.go +++ b/pkg/sv/Read.go @@ -8,11 +8,10 @@ package sv import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" ) @@ -55,7 +54,7 @@ func Read(input *ReadInput) (interface{}, error) { Limit: input.Limit, }) if errorIterator != nil { - return nil, errors.Wrap(errorIterator, "error creating iterator") + return nil, fmt.Errorf("error creating iterator: %w", errorIterator) } output := reflect.MakeSlice(inputType, 0, 0).Interface() w := pipe.NewSliceWriterWithValues(output) diff --git a/pkg/sv/ToRowFromValue.go b/pkg/sv/ToRowFromValue.go index d475853..6965731 100644 --- a/pkg/sv/ToRowFromValue.go +++ b/pkg/sv/ToRowFromValue.go @@ -11,8 +11,6 @@ import ( "fmt" "reflect" "strings" - - "github.com/pkg/errors" ) // ToRowFromValue converts an object into a row of strings and returns an error, if any. @@ -28,13 +26,13 @@ func ToRowFromValue(objectValue reflect.Value, columns []interface{}, valueSeria if v := objectValue.MapIndex(reflect.ValueOf(key)); v.IsValid() && (v.Type().Kind() == reflect.String || !v.IsNil()) { str, err := valueSerializer(v.Interface()) if err != nil { - return row, errors.Wrap(err, "error serializing value") + return row, fmt.Errorf("error serializing value: %w", err) } row[j] = str } else { str, err := valueSerializer(nil) if err != nil { - return row, errors.Wrap(err, "error serializing value") + return row, fmt.Errorf("error serializing value: %w", err) } row[j] = str } @@ -45,13 +43,13 @@ func ToRowFromValue(objectValue reflect.Value, columns []interface{}, valueSeria if f := objectValue.FieldByNameFunc(func(match string) bool { return strings.ToLower(match) == columnLowerCase }); f.IsValid() && (f.Type().Kind() == reflect.String || !f.IsNil()) { str, err := valueSerializer(f.Interface()) if err != nil { - return row, errors.Wrap(err, "error serializing value") + return row, fmt.Errorf("error serializing value: %w", err) } row[j] = str } else { str, err := valueSerializer(nil) if err != nil { - return row, errors.Wrap(err, "error serializing value") + return row, fmt.Errorf("error serializing value: %w", err) } row[j] = str } diff --git a/pkg/sv/Write.go b/pkg/sv/Write.go index 6336b4e..1b153ec 100644 --- a/pkg/sv/Write.go +++ b/pkg/sv/Write.go @@ -13,8 +13,6 @@ import ( "reflect" "sort" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -48,7 +46,9 @@ func Write(input *WriteInput) error { Sorted: input.Sorted, // if sorted and no specific wilcard position Reversed: input.Reversed, }) - return errors.Wrap(errWriteTable, "error writing table to underlying writer") + if errWriteTable != nil { + return fmt.Errorf("error writing table to underlying writer: %w", errWriteTable) + } } inputObject := input.Object @@ -105,7 +105,7 @@ func Write(input *WriteInput) error { } row, err := ToRowFromValue(inputObjectValue, header, valueSerializer) if err != nil { - return errors.Wrap(err, "error serializing object to row") + return fmt.Errorf("error serializing object to row: %w", err) } rows = append(rows, row) case reflect.Array, reflect.Slice: @@ -119,7 +119,7 @@ func Write(input *WriteInput) error { header, knownKeys = ExpandHeader(header, knownKeys, concerete(inputObjectValue.Index(i)), input.Sorted, input.Reversed) row, err := ToRowFromValue(concerete(inputObjectValue.Index(i)), header, valueSerializer) if err != nil { - return errors.Wrap(err, "error serializing object to row") + return fmt.Errorf("error serializing object to row: %w", err) } rows = append(rows, row) } @@ -132,7 +132,7 @@ func Write(input *WriteInput) error { for i := 0; i < inputObjectValue.Len() && (input.Limit < 0 || i <= input.Limit); i++ { row, err := ToRowFromValue(concerete(inputObjectValue.Index(i)), header, valueSerializer) if err != nil { - return errors.Wrap(err, "error serializing object to row") + return fmt.Errorf("error serializing object to row: %w", err) } rows = append(rows, row) } @@ -143,7 +143,7 @@ func Write(input *WriteInput) error { header, knownKeys = ExpandHeader(header, knownKeys, concerete(inputObjectValue.Index(i)), input.Sorted, input.Reversed) row, err := ToRowFromValue(concerete(inputObjectValue.Index(i)), header, valueSerializer) if err != nil { - return errors.Wrap(err, "error serializing object to row") + return fmt.Errorf("error serializing object to row: %w", err) } rows = append(rows, row) } @@ -151,7 +151,7 @@ func Write(input *WriteInput) error { } outputHeader, errStringifyHeader := stringify.StringifySlice(header, keySerializer) if errStringifyHeader != nil { - return errors.Wrapf(errStringifyHeader, "error stringifying header %q", header) + return fmt.Errorf("error stringifying header %q: %w", header, errStringifyHeader) } errWriteTable := WriteTable(&WriteTableInput{ Writer: input.Writer, @@ -161,7 +161,9 @@ func Write(input *WriteInput) error { Sorted: input.Sorted && !wildcard, // if sorted and no specific wilcard position Reversed: input.Reversed, }) - return errors.Wrap(errWriteTable, "error writing table to underlying writer") + if errWriteTable != nil { + return fmt.Errorf("error writing table to underlying writer: %w", errWriteTable) + } } // if streaming and not expanding header. @@ -169,7 +171,7 @@ func Write(input *WriteInput) error { if inputObjectKind == reflect.Array || inputObjectKind == reflect.Slice { it, errorIterator := pipe.NewSliceIterator(inputObject) if errorIterator != nil { - return errors.Wrap(errorIterator, "error creating slice iterator") + return fmt.Errorf("error creating slice iterator: %w", errorIterator) } p = p.Input(it) p = p.Output(NewWriter( @@ -183,7 +185,7 @@ func Write(input *WriteInput) error { )) errorRun := p.Run() if errorRun != nil { - return errors.Wrap(errorRun, "error serializing separated values") + return fmt.Errorf("error serializing separated values: %w", errorRun) } return nil } @@ -200,12 +202,12 @@ func Write(input *WriteInput) error { errorWrite := w.WriteObject(inputObject) if errorWrite != nil { - return errors.Wrap(errorWrite, "error serializing separated values") + return fmt.Errorf("error serializing separated values: %w", errorWrite) } errorFlush := w.Flush() if errorFlush != nil { - return errors.Wrap(errorFlush, "error serializing separated values") + return fmt.Errorf("error serializing separated values: %w", errorFlush) } return nil diff --git a/pkg/sv/Writer.go b/pkg/sv/Writer.go index 701f5ce..8c1886e 100644 --- a/pkg/sv/Writer.go +++ b/pkg/sv/Writer.go @@ -13,8 +13,6 @@ import ( "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -67,13 +65,13 @@ func (w *Writer) WriteHeader() error { // Stringify columns into strings h, err := stringify.StringifySlice(w.columns, w.keySerializer) if err != nil { - return errors.Wrap(err, "error stringifying columns") + return fmt.Errorf("error stringifying columns: %w", err) } // Write header to writer err = w.writer.Write(h) if err != nil { - return errors.Wrap(err, "error writing header") + return fmt.Errorf("error writing header: %w", err) } return nil } @@ -102,20 +100,20 @@ func (w *Writer) WriteObject(obj interface{}) error { } } if len(w.columns) == 0 { - return errors.New(fmt.Sprintf("could not infer the header from the given value with type %T", obj)) + return fmt.Errorf("could not infer the header from the given value with type %T", obj) } err := w.WriteHeader() if err != nil { - return errors.Wrap(err, "error writing header") + return fmt.Errorf("error writing header: %w", err) } } row, errorRow := w.ToRow(obj) if errorRow != nil { - return errors.Wrap(errorRow, "error serializing object as row") + return fmt.Errorf("error serializing object as row: %w", errorRow) } errorWrite := w.writer.Write(row) if errorWrite != nil { - return errors.Wrap(errorWrite, "error writing object") + return fmt.Errorf("error writing object: %w", errorWrite) } return nil } @@ -131,7 +129,7 @@ func (w *Writer) WriteObjects(objects interface{}) error { for i := 0; i < value.Len(); i++ { err := w.WriteObject(value.Index(i).Interface()) if err != nil { - return errors.Wrap(err, "error writing object") + return fmt.Errorf("error writing object: %w", err) } } } @@ -147,7 +145,7 @@ func (w *Writer) Flush() error { if flusher, ok := w.underlying.(Flusher); ok { err := flusher.Flush() if err != nil { - return errors.Wrap(err, "error flushing underlying writer") + return fmt.Errorf("error flushing underlying writer: %w", err) } } return nil @@ -158,7 +156,7 @@ func (w *Writer) Close() error { if closer, ok := w.underlying.(io.Closer); ok { err := closer.Close() if err != nil { - return errors.Wrap(err, "error closing underlying writer") + return fmt.Errorf("error closing underlying writer: %w", err) } } return nil diff --git a/pkg/tagger/KeyValue.go b/pkg/tagger/KeyValue.go index eab0801..386bd6a 100644 --- a/pkg/tagger/KeyValue.go +++ b/pkg/tagger/KeyValue.go @@ -10,8 +10,6 @@ package tagger import ( "fmt" - - "github.com/pkg/errors" ) // KeyValue represents a struct tag key:"value" pair. @@ -25,7 +23,7 @@ type KeyValue struct { func (t KeyValue) MarshalText() ([]byte, error) { v, err := t.Value.MarshalText() if err != nil { - return make([]byte, 0), errors.Wrapf(err, "error marshaling %#v", t) + return make([]byte, 0), fmt.Errorf("error marshaling %#v: %w", t, err) } return []byte(fmt.Sprintf("%s:%q", t.Key, string(v))), nil } diff --git a/pkg/tagger/Lookup.go b/pkg/tagger/Lookup.go index 359c4ef..c7c611c 100644 --- a/pkg/tagger/Lookup.go +++ b/pkg/tagger/Lookup.go @@ -8,9 +8,8 @@ package tagger import ( + "fmt" "reflect" - - "github.com/pkg/errors" ) // Lookup lookups and parses a struct tag key-value pair if found. @@ -21,7 +20,7 @@ func Lookup(structTag reflect.StructTag, key string) (*Value, error) { v := &Value{} err := Unmarshal([]byte(str), v) if err != nil { - return nil, errors.Wrapf(err, "error unmarshaling struct tag value %q", str) + return nil, fmt.Errorf("error unmarshaling struct tag value %q: %w", str, err) } return v, nil } diff --git a/pkg/tags/Iterator.go b/pkg/tags/Iterator.go index a45a0b5..3b25b8e 100644 --- a/pkg/tags/Iterator.go +++ b/pkg/tags/Iterator.go @@ -8,13 +8,12 @@ package tags import ( + "fmt" "io" "reflect" "strings" "unicode/utf8" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/scanner" ) @@ -54,7 +53,7 @@ func NewIterator(input *NewIteratorInput) (*Iterator, error) { KeyValueSeparator, n := utf8.DecodeRuneInString(input.KeyValueSeparator) if KeyValueSeparator == utf8.RuneError && n == 1 { - return nil, errors.Wrap(ErrInvalidUTF8, "error decoding key-value separator") + return nil, fmt.Errorf("error decoding key-value separator: %w", ErrInvalidUTF8) } s := scanner.New(input.Reader, input.LineSeparator, input.DropCR) @@ -109,13 +108,13 @@ func (it *Iterator) Next() (interface{}, error) { if it.Type != nil { obj, err := UnmarshalType([]byte(line), it.KeyValueSeparator, it.Type) if err != nil { - return obj, errors.Wrap(err, "error unmarshaling next tags object") + return obj, fmt.Errorf("error unmarshaling next tags object: %w", err) } return obj, nil } obj, err := Unmarshal([]byte(line), it.KeyValueSeparator) if err != nil { - return obj, errors.Wrap(err, "error unmarshaling next tags object") + return obj, fmt.Errorf("error unmarshaling next tags object: %w", err) } return obj, nil } diff --git a/pkg/tags/Marshal.go b/pkg/tags/Marshal.go index c38a961..61ff4cd 100644 --- a/pkg/tags/Marshal.go +++ b/pkg/tags/Marshal.go @@ -9,11 +9,10 @@ package tags import ( "bytes" + "fmt" "reflect" "strings" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-simple-serializer/pkg/escaper" "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" "github.com/spatialcurrent/go-stringify/pkg/stringify" @@ -22,7 +21,7 @@ import ( func marshalTag(keyValueSeparator []byte, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, e *escaper.Escaper, objectValue reflect.Value, key interface{}) ([]byte, error) { keyString, errKeyString := keySerializer(key) if errKeyString != nil { - return make([]byte, 0), errors.Wrap(errKeyString, "error serializing tag key") + return make([]byte, 0), fmt.Errorf("error serializing tag key: %w", errKeyString) } out := &bytes.Buffer{} @@ -35,12 +34,12 @@ func marshalTag(keyValueSeparator []byte, keySerializer stringify.Stringer, valu _, err := out.Write(keyValueSeparator) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing key-value separator") + return make([]byte, 0), fmt.Errorf("error writing key-value separator: %w", err) } value, valueStringError := valueSerializer(objectValue.MapIndex(reflect.ValueOf(key)).Interface()) if valueStringError != nil { - return make([]byte, 0), errors.Wrap(valueStringError, "error serializing tag value") + return make([]byte, 0), fmt.Errorf("error serializing tag value: %w", valueStringError) } if len(value) > 0 { @@ -101,16 +100,16 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe objectValue, key) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error serializing tag") + return make([]byte, 0), fmt.Errorf("error serializing tag: %w", err) } _, err = out.Write(b) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing tag") + return make([]byte, 0), fmt.Errorf("error writing tag: %w", err) } if i < len(allKeys)-1 { _, err = out.WriteRune(space) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing space") + return make([]byte, 0), fmt.Errorf("error writing space: %w", err) } } } @@ -125,16 +124,16 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe objectValue, key) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error serializing tag") + return make([]byte, 0), fmt.Errorf("error serializing tag: %w", err) } _, err = out.Write(b) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing tag") + return make([]byte, 0), fmt.Errorf("error writing tag: %w", err) } if i < len(allKeys)-1 { _, err = out.WriteRune(space) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing space") + return make([]byte, 0), fmt.Errorf("error writing space: %w", err) } } } @@ -164,19 +163,19 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe for i, fieldName := range allFieldNames { keyString, errKeyString := keySerializer(fieldName) if errKeyString != nil { - return out.Bytes(), errors.Wrap(errKeyString, "error serializing tag key") + return out.Bytes(), fmt.Errorf("error serializing tag key: %w", errKeyString) } _, err := out.WriteString(keyString) if err != nil { - return out.Bytes(), errors.Wrap(err, "error writing tag key") + return out.Bytes(), fmt.Errorf("error writing tag key: %w", err) } _, err = out.WriteString(keyValueSeparator) if err != nil { - return out.Bytes(), errors.Wrap(err, "error writing key-value separator") + return out.Bytes(), fmt.Errorf("error writing key-value separator: %w", err) } value, err := valueSerializer(objectValue.FieldByName(fieldName).Interface()) if err != nil { - return out.Bytes(), errors.Wrap(err, "error serializing tag value") + return out.Bytes(), fmt.Errorf("error serializing tag value: %w", err) } if len(value) > 0 { if strings.Contains(value, " ") { @@ -188,7 +187,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe if i < len(allFieldNames)-1 { _, err = out.WriteRune(space) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing space") + return make([]byte, 0), fmt.Errorf("error writing space: %w", err) } } } @@ -199,19 +198,19 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe for i, fieldName := range fieldNames { keyString, errKeyString := keySerializer(fieldName) if errKeyString != nil { - return out.Bytes(), errors.Wrap(errKeyString, "error serializing tag key") + return out.Bytes(), fmt.Errorf("error serializing tag key: %w", errKeyString) } _, err := out.WriteString(keyString) if err != nil { - return out.Bytes(), errors.Wrap(err, "error writing tag key") + return out.Bytes(), fmt.Errorf("error writing tag key: %w", err) } _, err = out.WriteString(keyValueSeparator) if err != nil { - return out.Bytes(), errors.Wrap(err, "error writing key-value separator") + return out.Bytes(), fmt.Errorf("error writing key-value separator: %w", err) } value, err := valueSerializer(objectValue.FieldByName(fieldName).Interface()) if err != nil { - return out.Bytes(), errors.Wrap(err, "error serializing tag value") + return out.Bytes(), fmt.Errorf("error serializing tag value: %w", err) } if len(value) > 0 { if strings.Contains(value, " ") { @@ -223,7 +222,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe if i < len(fieldNames)-1 { _, err = out.WriteRune(space) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error writing space") + return make([]byte, 0), fmt.Errorf("error writing space: %w", err) } } } diff --git a/pkg/tags/Read.go b/pkg/tags/Read.go index 0216cd1..3ca52b8 100644 --- a/pkg/tags/Read.go +++ b/pkg/tags/Read.go @@ -8,11 +8,10 @@ package tags import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" ) @@ -50,7 +49,7 @@ func Read(input *ReadInput) (interface{}, error) { DropCR: input.DropCR, }) if err != nil { - return nil, errors.Wrap(err, "error creating interator") + return nil, fmt.Errorf("error creating interator: %w", err) } output := reflect.MakeSlice(inputType, 0, 0).Interface() w := pipe.NewSliceWriterWithValues(output) diff --git a/pkg/tags/Write.go b/pkg/tags/Write.go index a7dd974..d6523e9 100644 --- a/pkg/tags/Write.go +++ b/pkg/tags/Write.go @@ -8,11 +8,10 @@ package tags import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -51,7 +50,7 @@ func Write(input *WriteInput) error { } it, errorIterator := pipe.NewSliceIterator(inputObject) if errorIterator != nil { - return errors.Wrap(errorIterator, "error creating slice iterator") + return fmt.Errorf("error creating slice iterator: %w", errorIterator) } w := NewWriter( input.Writer, @@ -66,7 +65,7 @@ func Write(input *WriteInput) error { ) errorRun := p.Input(it).Output(w).Run() if errorRun != nil { - return errors.Wrap(errorRun, "error serializing arry or slice as tags") + return fmt.Errorf("error serializing arry or slice as tags: %w", errorRun) } return nil } @@ -83,12 +82,12 @@ func Write(input *WriteInput) error { input.Sorted, input.Reversed) if errMarshal != nil { - return errors.Wrap(errMarshal, "error serializing to tags") + return fmt.Errorf("error serializing to tags: %w", errMarshal) } _, errWrite := input.Writer.Write(b) if errWrite != nil { - return errors.Wrap(errWrite, "error writing to underlying writer") + return fmt.Errorf("error writing to underlying writer: %w", errWrite) } return nil diff --git a/pkg/tags/Writer.go b/pkg/tags/Writer.go index c56521c..515f229 100644 --- a/pkg/tags/Writer.go +++ b/pkg/tags/Writer.go @@ -8,11 +8,10 @@ package tags import ( + "fmt" "io" "reflect" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -49,14 +48,14 @@ func NewWriter(w io.Writer, keys []interface{}, expandKeys bool, keyValueSeparat func (w *Writer) WriteObject(obj interface{}) error { b, err := Marshal(obj, w.keys, w.expandKeys, w.keyValueSeparator, w.keySerializer, w.valueSerializer, w.sorted, w.reversed) if err != nil { - return errors.Wrap(err, "error marshaling object") + return fmt.Errorf("error marshaling object: %w", err) } if len(w.lineSeparator) > 0 { b = append(b, []byte(w.lineSeparator)...) } _, err = w.writer.Write(b) if err != nil { - return errors.Wrap(err, "error writing to underlying writer") + return fmt.Errorf("error writing to underlying writer: %w", err) } return nil } @@ -74,7 +73,7 @@ func (w *Writer) WriteObjects(objects interface{}) error { for i := 0; i < value.Len(); i++ { err := w.WriteObject(value.Index(i).Interface()) if err != nil { - return errors.Wrap(err, "error writing object") + return fmt.Errorf("error writing object: %w", err) } } } @@ -87,7 +86,7 @@ func (w *Writer) Flush() error { if flusher, ok := w.writer.(Flusher); ok { err := flusher.Flush() if err != nil { - return errors.Wrap(err, "error flushing underlying writer") + return fmt.Errorf("error flushing underlying writer: %w", err) } } return nil @@ -98,7 +97,7 @@ func (w *Writer) Close() error { if closer, ok := w.writer.(io.Closer); ok { err := closer.Close() if err != nil { - return errors.Wrap(err, "error closing underlying writer") + return fmt.Errorf("error closing underlying writer: %w", err) } } return nil diff --git a/pkg/tags/tags.go b/pkg/tags/tags.go index 72de3db..8b497af 100644 --- a/pkg/tags/tags.go +++ b/pkg/tags/tags.go @@ -13,9 +13,8 @@ package tags import ( + "errors" "reflect" - - "github.com/pkg/errors" ) const ( diff --git a/pkg/toml/Marshal.go b/pkg/toml/Marshal.go index 125fb36..f232c82 100644 --- a/pkg/toml/Marshal.go +++ b/pkg/toml/Marshal.go @@ -9,9 +9,9 @@ package toml import ( "bytes" + "fmt" bstoml "github.com/BurntSushi/toml" - "github.com/pkg/errors" // import the BurntSushi toml library as bstoml ) // Marshal formats an object into a slice of bytes of TOML. @@ -22,7 +22,7 @@ func Marshal(obj interface{}) ([]byte, error) { buf := new(bytes.Buffer) err := bstoml.NewEncoder(buf).Encode(obj) if err != nil { - return make([]byte, 0), errors.Wrap(err, "error marshaling TOML bytes") + return make([]byte, 0), fmt.Errorf("error marshaling TOML bytes: %w", err) } return buf.Bytes(), nil } diff --git a/pkg/toml/Unmarshal.go b/pkg/toml/Unmarshal.go index 505b54a..e6d58f6 100644 --- a/pkg/toml/Unmarshal.go +++ b/pkg/toml/Unmarshal.go @@ -11,7 +11,6 @@ import ( "fmt" bstoml "github.com/BurntSushi/toml" - "github.com/pkg/errors" // import the BurntSushi toml library as bstoml ) // Unmarshal parses a slice of bytes into a map[string]interface{} object @@ -27,7 +26,7 @@ func Unmarshal(b []byte) (interface{}, error) { obj := map[string]interface{}{} _, err := bstoml.Decode(string(b), &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling TOML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling TOML %q: %w", string(b), err) } return obj, nil } diff --git a/pkg/toml/UnmarshalType.go b/pkg/toml/UnmarshalType.go index e591348..2615559 100644 --- a/pkg/toml/UnmarshalType.go +++ b/pkg/toml/UnmarshalType.go @@ -12,7 +12,6 @@ import ( "reflect" bstoml "github.com/BurntSushi/toml" - "github.com/pkg/errors" ) // import the BurntSushi toml library as bstoml @@ -32,7 +31,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(outputType)) _, err := bstoml.Decode(string(b), ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling TOML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling TOML %q: %w", string(b), err) } return ptr.Elem().Interface(), nil } diff --git a/pkg/toml/toml.go b/pkg/toml/toml.go index 2d8f977..68ca775 100644 --- a/pkg/toml/toml.go +++ b/pkg/toml/toml.go @@ -10,9 +10,8 @@ package toml import ( + "errors" "reflect" - - "github.com/pkg/errors" ) var ( diff --git a/pkg/tools/tools.go b/pkg/tools/tools.go new file mode 100644 index 0000000..7a04838 --- /dev/null +++ b/pkg/tools/tools.go @@ -0,0 +1,23 @@ +// ================================================================= +// +// Copyright (C) 2022 Spatial Current, Inc. - All Rights Reserved +// Released as open source under the MIT License. See LICENSE file. +// +// ================================================================= + +//go:build tools + +// This file exists to track tool dependencies. This is one of the recommended practices +// for handling tool dependencies in a Go module as outlined here: +// https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module + +package tools + +import ( + _ "github.com/client9/misspell" + _ "github.com/kisielk/errcheck" + _ "github.com/mitchellh/gox" + _ "golang.org/x/tools/cmd/goimports" + _ "golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow" + _ "honnef.co/go/tools/cmd/staticcheck" +) diff --git a/pkg/writer/Writer.go b/pkg/writer/Writer.go index ca92f6a..640f13d 100644 --- a/pkg/writer/Writer.go +++ b/pkg/writer/Writer.go @@ -13,10 +13,9 @@ package writer import ( + "errors" "io" - "github.com/pkg/errors" - "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-simple-serializer/pkg/fmt" "github.com/spatialcurrent/go-simple-serializer/pkg/gob" diff --git a/pkg/yaml/Unmarshal.go b/pkg/yaml/Unmarshal.go index adb1644..f388541 100644 --- a/pkg/yaml/Unmarshal.go +++ b/pkg/yaml/Unmarshal.go @@ -14,7 +14,6 @@ import ( "strings" "unicode/utf8" // utf8 is used to decode the first rune in the string - "github.com/pkg/errors" goyaml "gopkg.in/yaml.v2" // import the YAML library from https://github.com/go-yaml/yaml ) @@ -56,14 +55,14 @@ func Unmarshal(b []byte) (interface{}, error) { if d := s.Bytes(); len(d) > 0 { element, err := Unmarshal(d) if err != nil { - return obj, errors.Wrapf(err, "error scanning document %d", i) + return obj, fmt.Errorf("error scanning document %d: %w", i, err) } obj = append(obj, element) i++ } } if err := s.Err(); err != nil { - return obj, errors.Wrap(err, fmt.Sprintf("error scanning YAML %q", string(b))) + return obj, fmt.Errorf("error scanning YAML %q: %w", string(b), err) } return obj, nil } @@ -78,21 +77,21 @@ func Unmarshal(b []byte) (interface{}, error) { obj := make([]interface{}, 0) err := goyaml.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return obj, nil case '{': obj := map[string]interface{}{} err := goyaml.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return obj, nil case '"': obj := "" err := goyaml.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return obj, nil } @@ -101,7 +100,7 @@ func Unmarshal(b []byte) (interface{}, error) { obj := map[string]interface{}{} err := goyaml.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return obj, nil } diff --git a/pkg/yaml/UnmarshalType.go b/pkg/yaml/UnmarshalType.go index d50897b..1cd90b1 100644 --- a/pkg/yaml/UnmarshalType.go +++ b/pkg/yaml/UnmarshalType.go @@ -15,7 +15,6 @@ import ( "strings" "unicode/utf8" // utf8 is used to decode the first rune in the string - "github.com/pkg/errors" goyaml "gopkg.in/yaml.v2" // import the YAML library from https://github.com/go-yaml/yaml ) @@ -60,14 +59,14 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { if d := s.Bytes(); len(d) > 0 { obj, err := UnmarshalType(d, outputType.Elem()) if err != nil { - return out.Interface(), errors.Wrapf(err, "error scanning document %d", i) + return out.Interface(), fmt.Errorf("error scanning document %d: %w", i, err) } out = reflect.Append(out, reflect.ValueOf(obj)) i++ } } if err := s.Err(); err != nil { - return out.Interface(), errors.Wrap(err, fmt.Sprintf("error scanning YAML %q", string(b))) + return out.Interface(), fmt.Errorf("error scanning YAML %q: %w", string(b), err) } return out.Interface(), nil } @@ -86,7 +85,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeSlice(outputType, 0, 0)) err := goyaml.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %W", string(b), err) } return ptr.Elem().Interface(), nil case '{': @@ -97,7 +96,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(outputType)) err := goyaml.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return ptr.Elem().Interface(), nil case '"': @@ -107,7 +106,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { obj := "" err := goyaml.Unmarshal(b, &obj) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return obj, nil } @@ -120,7 +119,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.MakeMap(outputType)) err := goyaml.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q into map", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q into map: %w", string(b), err) } return ptr.Elem().Interface(), nil } @@ -130,7 +129,7 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { ptr.Elem().Set(reflect.Zero(outputType)) err := goyaml.Unmarshal(b, ptr.Interface()) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q into struct", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q into struct: %w", string(b), err) } return ptr.Elem().Interface(), nil } @@ -142,13 +141,13 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { case reflect.Int: i, err := strconv.Atoi(string(b)) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return i, nil case reflect.Float64: f, err := strconv.ParseFloat(string(b), 64) if err != nil { - return nil, errors.Wrap(err, fmt.Sprintf("error unmarshaling YAML %q", string(b))) + return nil, fmt.Errorf("error unmarshaling YAML %q: %w", string(b), err) } return f, nil case reflect.String: @@ -160,5 +159,5 @@ func UnmarshalType(b []byte, outputType reflect.Type) (interface{}, error) { return nil, nil } - return nil, errors.Errorf("could not unmarshal YAML %q into type %v", string(b), outputType) + return nil, fmt.Errorf("could not unmarshal YAML %q into type %v", string(b), outputType) } diff --git a/pkg/yaml/yaml.go b/pkg/yaml/yaml.go index 6798796..ade8bd5 100644 --- a/pkg/yaml/yaml.go +++ b/pkg/yaml/yaml.go @@ -12,7 +12,7 @@ package yaml import ( - "github.com/pkg/errors" + "errors" ) var ( diff --git a/scripts/build-release b/scripts/build-release new file mode 100644 index 0000000..8527ca9 --- /dev/null +++ b/scripts/build-release @@ -0,0 +1,32 @@ +#!/bin/bash + +# ================================================================= +# +# Copyright (C) 2022 Spatial Current, Inc. - All Rights Reserved +# Released as open source under the MIT License. See LICENSE file. +# +# ================================================================= + +set -euo pipefail + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +XC_OS=${1:-darwin freebsd linux openbsd solaris windows} +XC_ARCH=${2:-386 amd64 arm arm64} +XC_EXCLUDE_OSARCH="!darwin/arm !darwin/386 !freebsd/arm64 !openbsd/arm !openbsd/arm64 !solaris/386 !solaris/arm !solaris/arm64" + +export CGO_ENABLED=0 + +export GOFLAGS="-mod=readonly" + +export GOPATH=${GOPATH:-$(go env GOPATH)} + +go mod download + +${DIR}/../bin/gox \ +-os="${XC_OS}" \ +-arch="${XC_ARCH}" \ +-osarch="${XC_EXCLUDE_OSARCH}" \ +-ldflags "-s -w" \ +-output "bin/{{.Dir}}_{{.OS}}_{{.Arch}}" \ +github.com/spatialcurrent/go-simple-serializer/cmd/gss diff --git a/scripts/test.sh b/scripts/test.sh index 5982e60..69912cd 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -2,15 +2,19 @@ # ================================================================= # -# Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved +# Copyright (C) 2022 Spatial Current, Inc. - All Rights Reserved # Released as open source under the MIT License. See LICENSE file. # # ================================================================= DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -set -euo pipefail +set -eu + +# move up a directory cd $DIR/.. + pkgs=$(go list ./... | grep -v /vendor/ | tr "\n" " ") + echo "******************" echo "Running unit tests" go test -p 1 -count 1 -short $pkgs @@ -19,18 +23,13 @@ echo "Running go vet" go vet $pkgs echo "******************" echo "Running go vet with shadow" -go vet -vettool=$(which shadow) $pkgs +go vet -vettool="bin/shadow" $pkgs echo "******************" echo "Running errcheck" -errcheck ${pkgs} -echo "******************" -echo "Running ineffassign" -find . -name '*.go' | xargs ineffassign +bin/errcheck ${pkgs} echo "******************" echo "Running staticcheck" -staticcheck -checks 'all' $(go list ./... | grep -v /vendor/ | grep -v /plugins/ | tr "\n" " ") -staticcheck -checks 'all,-ST1020' $(go list ./... | grep /plugins/ | tr "\n" " ") +bin/staticcheck -checks all ${pkgs} echo "******************" echo "Running misspell" -misspell -locale US -error *.md *.go -echo "******************" +bin/misspell -locale US -error *.md *.go diff --git a/testEnvironment.js b/testEnvironment.js deleted file mode 100644 index b1e08f5..0000000 --- a/testEnvironment.js +++ /dev/null @@ -1,28 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -const NodeEnvironment = require('jest-environment-node'); - -class TestEnvironment extends NodeEnvironment { - constructor(config) { - super(config); - } - - async setup() { - this.global.gss = require('./dist/gss.mod.min.js'); - } - - async teardown() { - await super.teardown(); - } - - runScript(script) { - return super.runScript(script); - } -} - -module.exports = TestEnvironment; From 2e8b2a976ebfe8d6adb537dd9f89f6f124bc266e Mon Sep 17 00:00:00 2001 From: pjdufour Date: Tue, 8 Mar 2022 12:04:30 -0700 Subject: [PATCH 02/10] update ci --- .circleci/config.yml | 97 +++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 37 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a5650cc..1280c35 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,6 +13,24 @@ executors: docker: - image: cimg/go:1.17 + # `base` uses the `cimg/base` docker image. + base: + docker: + - image: cimg/base:2020.07 + + # `macos` uses the macOS machine image. + macos: + macos: + xcode: 12.4.0 + resource_class: medium + + # `windows` uses the Windows machine image. + windows: + machine: + image: "windows-server-2019-vs2019:stable" + resource_class: "windows.medium" + shell: "powershell.exe -ExecutionPolicy Bypass" + jobs: # `test_go` tests the source code. @@ -35,15 +53,10 @@ jobs: - run: make test_cli examples: - executor: base + executor: main steps: - - run: sudo chown -R circleci /go/src - - restore_cache: - keys: - - v1-go-src-{{ .Branch }}-{{ .Revision }} - - run: make deps_gopherjs - - run: make deps_javascript - - run: npm run build:clean + - checkout + - run: make build_so - run: make run_example_c - run: make run_example_cpp - run: make run_example_python @@ -81,41 +94,51 @@ jobs: - gss_windows_386.exe - gss_windows_amd64.exe - build_so: - executor: base - steps: - - run: sudo chown -R circleci /go/src - - restore_cache: - keys: - - v1-go-src-{{ .Branch }}-{{ .Revision }} + # Install arm dependencies - run: sudo make deps_arm + + # Build shared objects - run: make build_so - - store_artifacts: - path: bin - destination: / + + # `verify_linux` verifys the linux build + verify_linux: + executor: base + steps: + - attach_workspace: + at: bin + - run: bin/gss_linux_386 --help + - run: bin/gss_linux_amd64 --help + + # `verify_macos` verifys the macOS build + verify_macos: + executor: macos + steps: + - attach_workspace: + at: bin + - run: bin/gss_darwin_amd64 --help + + # `verify_windows` verifys the windows build + verify_windows: + executor: windows + steps: + - attach_workspace: + at: bin + - run: bin/gss_windows_386.exe --help + - run: bin/gss_windows_amd64.exe --help workflows: main: jobs: - - pre_deps_golang - - test_go: - requires: - - pre_deps_golang - - test_cli: - requires: - - pre_deps_golang - - test_javascript: - requires: - - pre_deps_golang - - examples: - requires: - - pre_deps_golang - - build_cli: + - test_go + - test_cli + - build + - examples + - verify_linux: requires: - - pre_deps_golang - - build_javascript: + - build + - verify_macos: requires: - - pre_deps_golang - - build_so: + - build + - verify_windows: requires: - - pre_deps_golang + - build From b8c2d806e7b6a738b7cb6e6763f61103955d422b Mon Sep 17 00:00:00 2001 From: pjdufour Date: Tue, 8 Mar 2022 14:09:04 -0700 Subject: [PATCH 03/10] make build_release exec --- .envrc | 24 ++++++++++++++++++++++++ Makefile | 1 + scripts/build-release | 0 3 files changed, 25 insertions(+) create mode 100644 .envrc mode change 100644 => 100755 scripts/build-release diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..2bc9a51 --- /dev/null +++ b/.envrc @@ -0,0 +1,24 @@ +#!/bin/bash + +########################################## +# DO NOT MAKE LOCAL CHANGES TO THIS FILE # +# # +# Vars in this file can be overridden by # +# exporting them in .envrc.local # +########################################## + +# Add local paths for binaries and scripts +PATH_add ./bin +PATH_add ./scripts + +############################################## +# Load Local Overrides and Check Environment # +############################################## + +# Load a local overrides file. Any changes you want to make for your local +# environment should live in that file. + +if [ -e .envrc.local ] +then + source_env .envrc.local +fi diff --git a/Makefile b/Makefile index 6dd6660..ce61ecc 100644 --- a/Makefile +++ b/Makefile @@ -58,6 +58,7 @@ test_go: bin/errcheck bin/misspell bin/staticcheck bin/shadow ## Run Go tests test_cli: bin/gss ## Run CLI tests bash scripts/test-cli.sh +.PHONY: install install: ## Install the CLI on current platform go install github.com/spatialcurrent/go-simple-serializer/cmd/gss diff --git a/scripts/build-release b/scripts/build-release old mode 100644 new mode 100755 From 4fcbcc38cb7d2146ca1cd17a446309270df8348b Mon Sep 17 00:00:00 2001 From: pjdufour Date: Tue, 8 Mar 2022 14:11:07 -0700 Subject: [PATCH 04/10] fix --- .circleci/config.yml | 2 ++ scripts/test-cli.sh | 24 ++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 1280c35..65deeba 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -56,6 +56,8 @@ jobs: executor: main steps: - checkout + - run: make tidy + - run: sudo make deps_arm - run: make build_so - run: make run_example_c - run: make run_example_cpp diff --git a/scripts/test-cli.sh b/scripts/test-cli.sh index e9c681c..109bf6c 100755 --- a/scripts/test-cli.sh +++ b/scripts/test-cli.sh @@ -14,31 +14,31 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" expectedFormats="bson,csv,fmt,go,gob,hcl,json,jsonl,properties,tags,toml,tsv,yaml" testFormats() { - formats=$(gss formats -f csv) + formats=$("${DIR}/../bin/gss" formats -f csv) assertEquals "unexpected formats" "${expectedFormats}" "${formats}" } testCSVJSON() { local expected='[{"hello":"world"}]' - local output=$(printf 'hello\nworld' | gss -i csv -o json) + local output=$(printf 'hello\nworld' | "${DIR}/../bin/gss" -i csv -o json) assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testCSVJSONL() { local expected='{"hello":"world"}' - local output=$(printf 'hello\nworld' | gss -i csv -o jsonl) + local output=$(printf 'hello\nworld' | "${DIR}/../bin/gss" -i csv -o jsonl) assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testJSONCSV() { local expected='hello\nworld' - local output=$(echo '{"hello":"world"}' | gss -i json -o csv) + local output=$(echo '{"hello":"world"}' | "${DIR}/../bin/gss" -i json -o csv) assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testJSONJSON() { local expected='{"hello":"world"}' - local output=$(echo '{"hello":"world"}' | gss -i json -o json) + local output=$(echo '{"hello":"world"}' | "${DIR}/../bin/gss" -i json -o json) assertEquals "unexpected output" "${expected}" "${output}" } @@ -52,48 +52,48 @@ testJSONLGOBJSONL() { testJSONArrayCSV() { local input='[{"a":"x"},{"b":"y"},{"c":"z"}]' local expected='a=x\nb=y\nc=z' - local output=$(echo -e "${input}" | gss -i json -o tags) + local output=$(echo -e "${input}" | "${DIR}/../bin/gss" -i json -o tags) assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testJSONLTags() { local input='{"a":"x"}\n{"b":"y"}\n{"c":"z"}' local expected='a=x\nb=y\nc=z' - local output=$(echo -e "${input}" | gss -i jsonl -o tags) + local output=$(echo -e "${input}" | "${DIR}/../bin/gss" -i jsonl -o tags) assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testJSONLFmt() { local input='{"a":"x"}\n{"b":"y"}\n{"c":"z"}' local expected='map[a:x]\nmap[b:y]\nmap[c:z]' - local output=$(echo -e "${input}" | gss -i jsonl -o fmt --output-format-specifier "%v") + local output=$(echo -e "${input}" | "${DIR}/../bin/gss" -i jsonl -o fmt --output-format-specifier "%v") assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testJSONGo() { local input='["a", "x"]' local expected='[]interface {}{"a", "x"}' - local output=$(echo -e "${input}" | gss -i json -o go) + local output=$(echo -e "${input}" | "${DIR}/../bin/gss" -i json -o go) assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testJSONGoFit() { local input='["a", "x"]' local expected='[]string{"a", "x"}' - local output=$(echo -e "${input}" | gss -i json -o go --output-fit) + local output=$(echo -e "${input}" | "${DIR}/../bin/gss" -i json -o go --output-fit) assertEquals "unexpected output" "$(echo -e "${expected}")" "${output}" } testHCLJSON() { local expected='{"data":[{"aws_caller_identity":[{"current":[{}]}]}]}' - local output=$(echo 'data "aws_caller_identity" "current" {}' | gss -i hcl -o json) + local output=$(echo 'data "aws_caller_identity" "current" {}' | "${DIR}/../bin/gss" -i hcl -o json) assertEquals "unexpected output" "${expected}" "${output}" } testYAMLJSON() { local expected='[{"a":"x"},{"b":"y"},"foo",null]' - local output=$(echo -e '---\na: x\n---\nb: "y"\n---\nfoo\n---\n' | gss -i yaml -o json) + local output=$(echo -e '---\na: x\n---\nb: "y"\n---\nfoo\n---\n' | "${DIR}/../bin/gss" -i yaml -o json) assertEquals "unexpected output" "${expected}" "${output}" } From 198d12a75015a39b80e937ed2f5b9a7fae307fae Mon Sep 17 00:00:00 2001 From: pjdufour Date: Tue, 8 Mar 2022 16:37:20 -0700 Subject: [PATCH 05/10] wip --- pkg/serializer/Serializer_serialize_test.go | 12 ++++- pkg/sv/Write.go | 1 + pkg/sv/Writer.go | 58 ++++++++++++--------- 3 files changed, 45 insertions(+), 26 deletions(-) diff --git a/pkg/serializer/Serializer_serialize_test.go b/pkg/serializer/Serializer_serialize_test.go index e38380f..ee69cff 100644 --- a/pkg/serializer/Serializer_serialize_test.go +++ b/pkg/serializer/Serializer_serialize_test.go @@ -40,7 +40,7 @@ func TestSerializerCSVMap(t *testing.T) { } func TestSerializerCSVSliceString(t *testing.T) { - in := []string{"a", "b", "c"} + in := []interface{}{[]string{"a", "b", "c"}} s := New(FormatCSV).Limit(NoLimit) out, err := s.Serialize(in) assert.NoError(t, err) @@ -81,6 +81,16 @@ func TestSerializerCSVSliceExpandHeader(t *testing.T) { out, err := s.Serialize(in) assert.NoError(t, err) assert.Equal(t, "a,b,c\n1,,3\n,5,6\n", string(out)) + //a,b,c + //1,,3 + //,5,6 + // + //a,b,c + //1,,3 + //,5,6 + //a,c + //1,3 + //,6 } func TestSerializerCSVSliceExpandHeaderWithWildcard(t *testing.T) { diff --git a/pkg/sv/Write.go b/pkg/sv/Write.go index 1b153ec..bc154be 100644 --- a/pkg/sv/Write.go +++ b/pkg/sv/Write.go @@ -169,6 +169,7 @@ func Write(input *WriteInput) error { // if streaming and not expanding header. p := pipe.NewBuilder().OutputLimit(input.Limit) if inputObjectKind == reflect.Array || inputObjectKind == reflect.Slice { + fmt.Println("Input Object:", input.Header, inputObject) it, errorIterator := pipe.NewSliceIterator(inputObject) if errorIterator != nil { return fmt.Errorf("error creating slice iterator: %w", errorIterator) diff --git a/pkg/sv/Writer.go b/pkg/sv/Writer.go index 8c1886e..cf73640 100644 --- a/pkg/sv/Writer.go +++ b/pkg/sv/Writer.go @@ -60,6 +60,7 @@ func NewWriter(underlying io.Writer, separator rune, columns []interface{}, keyS } func (w *Writer) WriteHeader() error { + fmt.Println("WriteHeader():", w.columns) w.headerWritten = true // Stringify columns into strings @@ -81,35 +82,42 @@ func (w *Writer) ToRow(obj interface{}) ([]string, error) { } func (w *Writer) WriteObject(obj interface{}) error { - if !w.headerWritten { - if len(w.columns) == 0 { - inputObjectValue := reflect.ValueOf(obj) - for reflect.TypeOf(inputObjectValue.Interface()).Kind() == reflect.Ptr { - inputObjectValue = inputObjectValue.Elem() - } - inputObjectValue = reflect.ValueOf(inputObjectValue.Interface()) // sets value to concerete type - inputObjectKind := inputObjectValue.Type().Kind() - if inputObjectKind == reflect.Map { - w.columns = inspector.GetKeysFromValue(inputObjectValue, w.sorted, w.reversed) - } else if inputObjectKind == reflect.Struct { - fieldNames := make([]interface{}, 0) - for _, fieldName := range inspector.GetFieldNamesFromValue(inputObjectValue, w.sorted, w.reversed) { - fieldNames = append(fieldNames, fieldName) + row := make([]string, 0) + if slc, ok := obj.([]string); ok { + row = slc + } else { + if !w.headerWritten { + if len(w.columns) == 0 { + inputObjectValue := reflect.ValueOf(obj) + for reflect.TypeOf(inputObjectValue.Interface()).Kind() == reflect.Ptr { + inputObjectValue = inputObjectValue.Elem() + } + inputObjectValue = reflect.ValueOf(inputObjectValue.Interface()) // sets value to concerete type + inputObjectKind := inputObjectValue.Type().Kind() + if inputObjectKind == reflect.Map { + w.columns = inspector.GetKeysFromValue(inputObjectValue, w.sorted, w.reversed) + } else if inputObjectKind == reflect.Struct { + fieldNames := make([]interface{}, 0) + for _, fieldName := range inspector.GetFieldNamesFromValue(inputObjectValue, w.sorted, w.reversed) { + fieldNames = append(fieldNames, fieldName) + } + fmt.Println("Field Names:", fieldNames) + w.columns = fieldNames } - w.columns = fieldNames + } + if len(w.columns) == 0 { + return fmt.Errorf("could not infer the header from the given value %#v with type %T", obj, obj) + } + err := w.WriteHeader() + if err != nil { + return fmt.Errorf("error writing header: %w", err) } } - if len(w.columns) == 0 { - return fmt.Errorf("could not infer the header from the given value with type %T", obj) - } - err := w.WriteHeader() - if err != nil { - return fmt.Errorf("error writing header: %w", err) + r, errorRow := w.ToRow(obj) + if errorRow != nil { + return fmt.Errorf("error serializing object as row: %w", errorRow) } - } - row, errorRow := w.ToRow(obj) - if errorRow != nil { - return fmt.Errorf("error serializing object as row: %w", errorRow) + row = r } errorWrite := w.writer.Write(row) if errorWrite != nil { From a096061acac319aa365bf2c7a18cc0557d02cef4 Mon Sep 17 00:00:00 2001 From: pjdufour Date: Tue, 8 Mar 2022 20:12:22 -0700 Subject: [PATCH 06/10] fixes --- Makefile | 1 + pkg/sv/Write.go | 2 +- pkg/sv/Writer.go | 66 +++++++++++++++++++++++---------------------- plugins/gss/main.go | 11 +++----- 4 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index ce61ecc..a1fb06f 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,7 @@ imports: bin/goimports ## Update imports in Go source code vet: ## Vet Go source code go vet github.com/spatialcurrent/go-simple-serializer/pkg/... # vet packages go vet github.com/spatialcurrent/go-simple-serializer/cmd/... # vet commands + go vet github.com/spatialcurrent/go-simple-serializer/plugins/... # vet plugins tidy: ## Tidy Go source code go mod tidy diff --git a/pkg/sv/Write.go b/pkg/sv/Write.go index bc154be..aebbc81 100644 --- a/pkg/sv/Write.go +++ b/pkg/sv/Write.go @@ -164,12 +164,12 @@ func Write(input *WriteInput) error { if errWriteTable != nil { return fmt.Errorf("error writing table to underlying writer: %w", errWriteTable) } + return nil } // if streaming and not expanding header. p := pipe.NewBuilder().OutputLimit(input.Limit) if inputObjectKind == reflect.Array || inputObjectKind == reflect.Slice { - fmt.Println("Input Object:", input.Header, inputObject) it, errorIterator := pipe.NewSliceIterator(inputObject) if errorIterator != nil { return fmt.Errorf("error creating slice iterator: %w", errorIterator) diff --git a/pkg/sv/Writer.go b/pkg/sv/Writer.go index cf73640..b2a0174 100644 --- a/pkg/sv/Writer.go +++ b/pkg/sv/Writer.go @@ -60,7 +60,6 @@ func NewWriter(underlying io.Writer, separator rune, columns []interface{}, keyS } func (w *Writer) WriteHeader() error { - fmt.Println("WriteHeader():", w.columns) w.headerWritten = true // Stringify columns into strings @@ -82,47 +81,50 @@ func (w *Writer) ToRow(obj interface{}) ([]string, error) { } func (w *Writer) WriteObject(obj interface{}) error { - row := make([]string, 0) + if slc, ok := obj.([]string); ok { - row = slc - } else { - if !w.headerWritten { - if len(w.columns) == 0 { - inputObjectValue := reflect.ValueOf(obj) - for reflect.TypeOf(inputObjectValue.Interface()).Kind() == reflect.Ptr { - inputObjectValue = inputObjectValue.Elem() - } - inputObjectValue = reflect.ValueOf(inputObjectValue.Interface()) // sets value to concerete type - inputObjectKind := inputObjectValue.Type().Kind() - if inputObjectKind == reflect.Map { - w.columns = inspector.GetKeysFromValue(inputObjectValue, w.sorted, w.reversed) - } else if inputObjectKind == reflect.Struct { - fieldNames := make([]interface{}, 0) - for _, fieldName := range inspector.GetFieldNamesFromValue(inputObjectValue, w.sorted, w.reversed) { - fieldNames = append(fieldNames, fieldName) - } - fmt.Println("Field Names:", fieldNames) - w.columns = fieldNames - } - } - if len(w.columns) == 0 { - return fmt.Errorf("could not infer the header from the given value %#v with type %T", obj, obj) + errorWrite := w.writer.Write(slc) + if errorWrite != nil { + return fmt.Errorf("error writing object: %w", errorWrite) + } + return nil + } + + if !w.headerWritten { + if len(w.columns) == 0 { + inputObjectValue := reflect.ValueOf(obj) + for reflect.TypeOf(inputObjectValue.Interface()).Kind() == reflect.Ptr { + inputObjectValue = inputObjectValue.Elem() } - err := w.WriteHeader() - if err != nil { - return fmt.Errorf("error writing header: %w", err) + inputObjectValue = reflect.ValueOf(inputObjectValue.Interface()) // sets value to concerete type + inputObjectKind := inputObjectValue.Type().Kind() + if inputObjectKind == reflect.Map { + w.columns = inspector.GetKeysFromValue(inputObjectValue, w.sorted, w.reversed) + } else if inputObjectKind == reflect.Struct { + fieldNames := make([]interface{}, 0) + for _, fieldName := range inspector.GetFieldNamesFromValue(inputObjectValue, w.sorted, w.reversed) { + fieldNames = append(fieldNames, fieldName) + } + w.columns = fieldNames } } - r, errorRow := w.ToRow(obj) - if errorRow != nil { - return fmt.Errorf("error serializing object as row: %w", errorRow) + if len(w.columns) == 0 { + return fmt.Errorf("could not infer the header from the given value %#v with type %T", obj, obj) + } + err := w.WriteHeader() + if err != nil { + return fmt.Errorf("error writing header: %w", err) } - row = r + } + row, errorRow := w.ToRow(obj) + if errorRow != nil { + return fmt.Errorf("error serializing object as row: %w", errorRow) } errorWrite := w.writer.Write(row) if errorWrite != nil { return fmt.Errorf("error writing object: %w", errorWrite) } + return nil } diff --git a/plugins/gss/main.go b/plugins/gss/main.go index f98a738..637fb56 100644 --- a/plugins/gss/main.go +++ b/plugins/gss/main.go @@ -5,6 +5,8 @@ // // ================================================================= +//lint:file-ignore ST1020 artifact of C-GO + // gss.so creates a shared library of Go that can be called by C, C++, or Python // // @@ -17,11 +19,7 @@ import ( "C" "fmt" "strings" -) -//"github.com/spatialcurrent/go-stringify/pkg/stringify" - -import ( "github.com/spatialcurrent/go-simple-serializer/pkg/gss" ) @@ -46,9 +44,8 @@ func Version() *C.char { func Convert(inputString *C.char, inputFormat *C.char, outputFormat *C.char, outputPretty *C.char, outputSorted *C.char, outputString **C.char) *C.char { s, err := gss.Convert(&gss.ConvertInput{ - InputBytes: []byte(C.GoString(inputString)), - InputFormat: C.GoString(inputFormat), - //InputHeader: stringify.StringSliceToInterfaceSlice(strings.Split(C.GoString(inputHeader), ",")), + InputBytes: []byte(C.GoString(inputString)), + InputFormat: C.GoString(inputFormat), InputHeader: []interface{}{}, InputComment: "", InputLazyQuotes: false, From f4cce9e57a2ce66a29b17d1350adfb146617db07 Mon Sep 17 00:00:00 2001 From: pjdufour Date: Tue, 8 Mar 2022 20:32:10 -0700 Subject: [PATCH 07/10] fix --- .circleci/config.yml | 50 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 65deeba..bbf23f3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -8,10 +8,12 @@ version: "2.1" executors: - # `main` uses the `cimg/go:1.17` docker image. - main: - docker: - - image: cimg/go:1.17 + + # `arm` uses an ARM machine image. + arm: + machine: + image: ubuntu-2004:202101-01 + resource_class: arm.medium # `base` uses the `cimg/base` docker image. base: @@ -24,6 +26,11 @@ executors: xcode: 12.4.0 resource_class: medium + # `main` uses the `cimg/go:1.17` docker image. + main: + docker: + - image: cimg/go:1.17 + # `windows` uses the Windows machine image. windows: machine: @@ -56,9 +63,19 @@ jobs: executor: main steps: - checkout + # Update apt cache + - run: sudo apt-get update + + # Tidy dependencies - run: make tidy + + # Install ARM dependencies - run: sudo make deps_arm + + # Build shared objects - run: make build_so + + # Run examples - run: make run_example_c - run: make run_example_cpp - run: make run_example_python @@ -75,6 +92,12 @@ jobs: # Tidy dependencies - run: make tidy + # Make gox + - run: make bin/gox + + # Print supported OS/Arch combinations + - run: bin/gox -osarch-list + # Build Executeables - run: make build_release @@ -84,15 +107,22 @@ jobs: - store_artifacts: path: bin destination: / + - persist_to_workspace: root: bin paths: - gss_darwin_amd64 - gss_darwin_arm64 + - gss_freebsd_386 + - gss_freebsd_amd64 + - gss_freebsd_arm - gss_linux_386 - gss_linux_amd64 - gss_linux_arm - gss_linux_arm64 + - gss_openbsd_386 + - gss_openbsd_amd64 + - gss_solaris_amd64 - gss_windows_386.exe - gss_windows_amd64.exe @@ -111,6 +141,15 @@ jobs: - run: bin/gss_linux_386 --help - run: bin/gss_linux_amd64 --help + # `verify_linux_arm` verifys the linux/arm build + verify_linux_arm: + executor: arm + steps: + - attach_workspace: + at: bin + - run: bin/gss_linux_arm --help + - run: bin/gss_linux_arm64 --help + # `verify_macos` verifys the macOS build verify_macos: executor: macos @@ -138,6 +177,9 @@ workflows: - verify_linux: requires: - build + - verify_linux_arm: + requires: + - build - verify_macos: requires: - build From dc474cdb33faf4b5bb7ee9cde3b94cab41b4d710 Mon Sep 17 00:00:00 2001 From: pjdufour Date: Wed, 9 Mar 2022 07:14:22 -0700 Subject: [PATCH 08/10] add version --- Makefile | 4 ++-- pkg/cli/formats/NewCommand.go | 2 +- scripts/build-release | 4 +++- scripts/test-cli.sh | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index a1fb06f..ffd3772 100644 --- a/Makefile +++ b/Makefile @@ -61,7 +61,7 @@ test_cli: bin/gss ## Run CLI tests .PHONY: install install: ## Install the CLI on current platform - go install github.com/spatialcurrent/go-simple-serializer/cmd/gss + go install -ldflags="$(LDFLAGS)" github.com/spatialcurrent/go-simple-serializer/cmd/gss # # Command line Programs @@ -86,7 +86,7 @@ bin/shadow: go build -o bin/shadow golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow bin/gss: ## Build CLI for Darwin / amd64 - go build -o bin/gss github.com/spatialcurrent/go-simple-serializer/cmd/gss + go build -o bin/gss -ldflags="$(LDFLAGS)" github.com/spatialcurrent/go-simple-serializer/cmd/gss bin/gss_linux_amd64: bin/gox ## Build CLI for Darwin / amd64 scripts/build-release linux amd64 diff --git a/pkg/cli/formats/NewCommand.go b/pkg/cli/formats/NewCommand.go index d4b834f..0f95964 100644 --- a/pkg/cli/formats/NewCommand.go +++ b/pkg/cli/formats/NewCommand.go @@ -41,7 +41,7 @@ func NewCommand() *cobra.Command { f := v.GetString(FlagFormat) - b, err := serializer.New(f).LineSeparator("\n").Serialize(gss.Formats) + b, err := serializer.New(f).LineSeparator("\n").Serialize([]interface{}{gss.Formats}) if err != nil { return fmt.Errorf("error serializing formats with format %q: %w", f, err) } diff --git a/scripts/build-release b/scripts/build-release index 8527ca9..49f12df 100755 --- a/scripts/build-release +++ b/scripts/build-release @@ -21,12 +21,14 @@ export GOFLAGS="-mod=readonly" export GOPATH=${GOPATH:-$(go env GOPATH)} +export LDFLAGS="-s -w -X main.gitBranch=$(git branch | grep \* | cut -d ' ' -f2) -X main.gitCommit=$(git rev-list -1 HEAD)" + go mod download ${DIR}/../bin/gox \ -os="${XC_OS}" \ -arch="${XC_ARCH}" \ -osarch="${XC_EXCLUDE_OSARCH}" \ --ldflags "-s -w" \ +-ldflags "${LDFLAGS}" \ -output "bin/{{.Dir}}_{{.OS}}_{{.Arch}}" \ github.com/spatialcurrent/go-simple-serializer/cmd/gss diff --git a/scripts/test-cli.sh b/scripts/test-cli.sh index 109bf6c..62c0f48 100755 --- a/scripts/test-cli.sh +++ b/scripts/test-cli.sh @@ -7,7 +7,7 @@ # # ================================================================= -set -euo pipefail +#set -euo pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" From b67d4df802c4deadfef341f8484c894fce5856d4 Mon Sep 17 00:00:00 2001 From: pjdufour Date: Wed, 9 Mar 2022 07:15:27 -0700 Subject: [PATCH 09/10] fix --- scripts/test-cli.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/test-cli.sh b/scripts/test-cli.sh index 62c0f48..c63d5fd 100755 --- a/scripts/test-cli.sh +++ b/scripts/test-cli.sh @@ -45,7 +45,7 @@ testJSONJSON() { testJSONLGOBJSONL() { local input='{"hello":"world"}' local expected='{"hello":"world"}' - local output=$(echo "${input}" | gss -i jsonl -o gob | gss -i gob -t -o jsonl) + local output=$(echo "${input}" | "${DIR}/../bin/gss" -i jsonl -o gob | gss -i gob -t -o jsonl) assertEquals "unexpected output" "${expected}" "${output}" } From d5dbad4dcfe3ee427ea55a79cbe4de79414cc611 Mon Sep 17 00:00:00 2001 From: pjdufour Date: Wed, 9 Mar 2022 13:25:28 -0700 Subject: [PATCH 10/10] use go-object --- cmd/gss/main.go | 5 +- go.mod | 5 +- go.sum | 4 +- pkg/gss/Convert.go | 9 +- pkg/gss/DeserializeBytes.go | 3 +- pkg/gss/DeserializeReader.go | 3 +- pkg/gss/SerializeBytes.go | 3 +- pkg/iterator/Iterator.go | 31 ++-- pkg/serializer/Serializer.go | 53 +++---- pkg/serializer/Serializer_serialize_test.go | 3 +- pkg/sv/CreateHeaderAndKnownKeys.go | 17 --- pkg/sv/CreateHeaderAndKnownKeysFromValue.go | 41 ------ pkg/sv/CreateHeaderAndKnownKeys_test.go | 46 ------ pkg/sv/ExpandHeader.go | 29 ---- pkg/sv/ExpandHeaderWithWildcard.go | 34 ----- pkg/sv/ExpandHeaderWithWildcard_test.go | 55 ------- pkg/sv/ExpandHeader_test.go | 55 ------- pkg/sv/Iterator.go | 17 +-- pkg/sv/Iterator_test.go | 4 +- pkg/sv/Read.go | 3 +- pkg/sv/RemoveWildcard.go | 18 --- pkg/sv/RemoveWildcard_test.go | 24 --- pkg/sv/ToRow.go | 17 --- pkg/sv/ToRowFromValue.go | 60 -------- pkg/sv/ToRow_test.go | 28 ---- pkg/sv/Write.go | 153 ++++++++++---------- pkg/sv/Writer.go | 61 ++++---- pkg/sv/Writer_test.go | 13 +- pkg/tags/Marshal.go | 84 +++++------ pkg/tags/Marshal_examples_test.go | 5 +- pkg/tags/Marshal_test.go | 15 +- pkg/tags/Read.go | 7 +- pkg/tags/Write.go | 13 +- pkg/tags/Write_examples_test.go | 5 +- pkg/tags/Write_test.go | 5 +- pkg/tags/Writer.go | 13 +- pkg/tags/Writer_test.go | 19 +-- pkg/writer/Writer.go | 3 +- plugins/gss/main.go | 5 +- 39 files changed, 270 insertions(+), 698 deletions(-) delete mode 100644 pkg/sv/CreateHeaderAndKnownKeys.go delete mode 100644 pkg/sv/CreateHeaderAndKnownKeysFromValue.go delete mode 100644 pkg/sv/CreateHeaderAndKnownKeys_test.go delete mode 100644 pkg/sv/ExpandHeader.go delete mode 100644 pkg/sv/ExpandHeaderWithWildcard.go delete mode 100644 pkg/sv/ExpandHeaderWithWildcard_test.go delete mode 100644 pkg/sv/ExpandHeader_test.go delete mode 100644 pkg/sv/RemoveWildcard.go delete mode 100644 pkg/sv/RemoveWildcard_test.go delete mode 100644 pkg/sv/ToRow.go delete mode 100644 pkg/sv/ToRowFromValue.go delete mode 100644 pkg/sv/ToRow_test.go diff --git a/cmd/gss/main.go b/cmd/gss/main.go index 946161d..0e7a098 100644 --- a/cmd/gss/main.go +++ b/cmd/gss/main.go @@ -36,6 +36,7 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-simple-serializer/pkg/cli" "github.com/spatialcurrent/go-simple-serializer/pkg/cli/formats" @@ -88,13 +89,13 @@ Supports the following file formats: ` + strings.Join(gss.Formats, ", "), inputFormat := v.GetString(cli.FlagInputFormat) - inputHeader := stringify.StringSliceToInterfaceSlice(v.GetStringSlice(cli.FlagInputHeader)) + inputHeader := object.NewStringArray(v.GetStringSlice(cli.FlagInputHeader)).ObjectArray() inputLineSeparator := v.GetString(cli.FlagInputLineSeparator) outputFormat := v.GetString(cli.FlagOutputFormat) - outputHeader := stringify.StringSliceToInterfaceSlice(v.GetStringSlice(cli.FlagOutputHeader)) + outputHeader := object.NewStringArray(v.GetStringSlice(cli.FlagOutputHeader)).ObjectArray() outputSorted := v.GetBool(cli.FlagOutputSorted) outputReversed := v.GetBool(cli.FlagOutputReversed) diff --git a/go.mod b/go.mod index 62939f9..252bb44 100644 --- a/go.mod +++ b/go.mod @@ -2,14 +2,16 @@ module github.com/spatialcurrent/go-simple-serializer go 1.17 +replace github.com/spatialcurrent/go-object => ../go-object + require ( github.com/BurntSushi/toml v1.0.0 github.com/client9/misspell v0.3.4 github.com/hashicorp/hcl v1.0.0 github.com/kisielk/errcheck v1.6.0 github.com/mitchellh/gox v1.0.1 - github.com/pkg/errors v0.9.1 github.com/spatialcurrent/go-fit v0.0.0-20220308154842-0eadb7a509c2 + github.com/spatialcurrent/go-object v0.0.0-00010101000000-000000000000 github.com/spatialcurrent/go-pipe v0.0.0-20211121224133-8c3e90fc2b6a github.com/spatialcurrent/go-stringify v0.0.0-20220308153339-0abf902cfee4 github.com/spf13/cobra v1.3.0 @@ -32,6 +34,7 @@ require ( github.com/mitchellh/mapstructure v1.4.3 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/spatialcurrent/go-try-get v0.0.0-20211130135300-b29289e7960d // indirect github.com/spf13/afero v1.6.0 // indirect github.com/spf13/cast v1.4.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/go.sum b/go.sum index 07f3117..16a6d10 100644 --- a/go.sum +++ b/go.sum @@ -294,8 +294,6 @@ github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhEC github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= 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.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= @@ -329,6 +327,8 @@ github.com/spatialcurrent/go-pipe v0.0.0-20211121224133-8c3e90fc2b6a h1:wqR56ICm github.com/spatialcurrent/go-pipe v0.0.0-20211121224133-8c3e90fc2b6a/go.mod h1:Lq/brpH++gKrSYVzimS8cBqldqdZyZPRhAj06ZEl5S0= github.com/spatialcurrent/go-stringify v0.0.0-20220308153339-0abf902cfee4 h1:9Pg1iV1PATa6xYxQAlSGsRYwHh1OEnp7Lphaf+MV6bs= github.com/spatialcurrent/go-stringify v0.0.0-20220308153339-0abf902cfee4/go.mod h1:QOkIEQRq/x7eI60dZf97Z1kCCICTXEoRCcHPbtq0kIQ= +github.com/spatialcurrent/go-try-get v0.0.0-20211130135300-b29289e7960d h1:6ElNijSE4fc9acQ96SzfgauPrJmKd+RDk5LZ8DALMe0= +github.com/spatialcurrent/go-try-get v0.0.0-20211130135300-b29289e7960d/go.mod h1:q7+eppnJzzYY5lBaKARbyOrplvKt7xneBJYjJLE7Jjc= github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= diff --git a/pkg/gss/Convert.go b/pkg/gss/Convert.go index f571c41..b0bade2 100644 --- a/pkg/gss/Convert.go +++ b/pkg/gss/Convert.go @@ -11,6 +11,7 @@ import ( "fmt" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -19,7 +20,7 @@ import ( type ConvertInput struct { InputBytes []byte InputFormat string - InputHeader []interface{} + InputHeader object.ObjectArray InputComment string InputLazyQuotes bool InputScannerBufferSize int @@ -36,7 +37,7 @@ type ConvertInput struct { OutputFormat string OutputFormatSpecifier string OutputFit bool - OutputHeader []interface{} + OutputHeader object.ObjectArray OutputLimit int OutputPretty bool OutputSorted bool @@ -55,7 +56,7 @@ func NewConvertInput(bytes []byte, inputFormat string, outputFormat string) *Con return &ConvertInput{ InputBytes: bytes, InputFormat: inputFormat, - InputHeader: NoHeader, + InputHeader: object.NewObjectArray(NoHeader), InputComment: NoComment, InputLazyQuotes: false, InputScannerBufferSize: 0, @@ -71,7 +72,7 @@ func NewConvertInput(bytes []byte, inputFormat string, outputFormat string) *Con OutputFormat: outputFormat, OutputFormatSpecifier: "", OutputFit: false, - OutputHeader: NoHeader, + OutputHeader: object.NewObjectArray(NoHeader), OutputLimit: NoLimit, OutputPretty: false, OutputSorted: false, diff --git a/pkg/gss/DeserializeBytes.go b/pkg/gss/DeserializeBytes.go index 52b19dd..9e24ec7 100644 --- a/pkg/gss/DeserializeBytes.go +++ b/pkg/gss/DeserializeBytes.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/hcl" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-simple-serializer/pkg/iterator" "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" @@ -24,7 +25,7 @@ import ( type DeserializeBytesInput struct { Bytes []byte Format string - Header []interface{} + Header object.ObjectArray Comment string LazyQuotes bool ScannerBufferSize int diff --git a/pkg/gss/DeserializeReader.go b/pkg/gss/DeserializeReader.go index 26af79b..84a0aff 100644 --- a/pkg/gss/DeserializeReader.go +++ b/pkg/gss/DeserializeReader.go @@ -14,6 +14,7 @@ import ( "io/ioutil" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-simple-serializer/pkg/iterator" "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" @@ -23,7 +24,7 @@ import ( type DeserializeReaderInput struct { Reader io.Reader Format string - Header []interface{} + Header object.ObjectArray Comment string LazyQuotes bool SkipLines int diff --git a/pkg/gss/SerializeBytes.go b/pkg/gss/SerializeBytes.go index b177308..72f369c 100644 --- a/pkg/gss/SerializeBytes.go +++ b/pkg/gss/SerializeBytes.go @@ -11,6 +11,7 @@ import ( "fmt" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-simple-serializer/pkg/serializer" ) @@ -20,7 +21,7 @@ type SerializeBytesInput struct { Format string FormatSpecifier string Fit bool - Header []interface{} + Header object.ObjectArray Limit int Pretty bool Sorted bool diff --git a/pkg/iterator/Iterator.go b/pkg/iterator/Iterator.go index edf3ac7..737cfb2 100644 --- a/pkg/iterator/Iterator.go +++ b/pkg/iterator/Iterator.go @@ -18,6 +18,7 @@ import ( "io" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-simple-serializer/pkg/gob" "github.com/spatialcurrent/go-simple-serializer/pkg/jsonl" "github.com/spatialcurrent/go-simple-serializer/pkg/sv" @@ -36,21 +37,21 @@ type Iterator interface { // NewIteratorInput provides the input parameters for the NewIterator function. type NewIteratorInput struct { - Reader io.Reader // the underlying reader - Format string // the format - Header []interface{} // for csv and tsv, the header. If not given, then reads first line of stream as header. - ScannerBufferSize int // the initial buffer size for the scanner - SkipLines int // Skip a given number of lines at the beginning of the stream. - SkipBlanks bool // Skip blank lines. If false, Next() returns a blank line as (nil, nil). If true, Next() simply skips forward until it finds a non-blank line. - SkipComments bool // Skip commented lines. If false, Next() returns a commented line as (nil, nil). If true, Next() simply skips forward until it finds a non-commented line. - Comment string // The comment line prefix. CSV and TSV only support single characters. JSON Lines support any string. - Trim bool // Trim each input line before parsing into an object. - LazyQuotes bool // for csv and tsv, parse with lazy quotes - Limit int // Limit the number of objects to read and return from the underlying stream. - KeyValueSeparator string // For tags, the key-value separator. - LineSeparator string // For JSON Lines, the new line byte. - DropCR bool // For JSON Lines, drop carriage returns at the end of lines. - Type reflect.Type // + Reader io.Reader // the underlying reader + Format string // the format + Header object.ObjectArray // for csv and tsv, the header. If not given, then reads first line of stream as header. + ScannerBufferSize int // the initial buffer size for the scanner + SkipLines int // Skip a given number of lines at the beginning of the stream. + SkipBlanks bool // Skip blank lines. If false, Next() returns a blank line as (nil, nil). If true, Next() simply skips forward until it finds a non-blank line. + SkipComments bool // Skip commented lines. If false, Next() returns a commented line as (nil, nil). If true, Next() simply skips forward until it finds a non-commented line. + Comment string // The comment line prefix. CSV and TSV only support single characters. JSON Lines support any string. + Trim bool // Trim each input line before parsing into an object. + LazyQuotes bool // for csv and tsv, parse with lazy quotes + Limit int // Limit the number of objects to read and return from the underlying stream. + KeyValueSeparator string // For tags, the key-value separator. + LineSeparator string // For JSON Lines, the new line byte. + DropCR bool // For JSON Lines, drop carriage returns at the end of lines. + Type reflect.Type // } // NewIterator returns an Iterator for the given input source, format, and other options. diff --git a/pkg/serializer/Serializer.go b/pkg/serializer/Serializer.go index a7e5da2..b09c324 100644 --- a/pkg/serializer/Serializer.go +++ b/pkg/serializer/Serializer.go @@ -19,6 +19,7 @@ import ( "github.com/spatialcurrent/go-fit/pkg/fit" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-simple-serializer/pkg/bson" "github.com/spatialcurrent/go-simple-serializer/pkg/gob" "github.com/spatialcurrent/go-simple-serializer/pkg/json" @@ -109,17 +110,17 @@ type Serializer struct { format string // one of gss.Formats formatSpecifier string fit bool - header []interface{} // if formt as csv or tsv, the column names - comment string // the line comment prefix - lazyQuotes bool // if format is csv or tsv, allow LazyQuotes. - scannerBufferSize int // the initial buffer size for the scanner. - skipLines int // if format is csv, tsv, or jsonl, the number of lines to skip before processing. - skipBlanks bool // Skip blank lines. If false, Next() returns a blank line as (nil, nil). If true, Next() simply skips forward until it finds a non-blank line. - skipComments bool // Skip commented lines. If false, Next() returns a commented line as (nil, nil). If true, Next() simply skips forward until it finds a non-commented line. - limit int // if format is a csv, tsv, or jsonl, then limit the number of items processed. - objectType reflect.Type // the type of the output object - pretty bool // pretty output - lineSeparator string // new line character, used by properties and jsonl + header object.ObjectArray // if formt as csv or tsv, the column names + comment string // the line comment prefix + lazyQuotes bool // if format is csv or tsv, allow LazyQuotes. + scannerBufferSize int // the initial buffer size for the scanner. + skipLines int // if format is csv, tsv, or jsonl, the number of lines to skip before processing. + skipBlanks bool // Skip blank lines. If false, Next() returns a blank line as (nil, nil). If true, Next() simply skips forward until it finds a non-blank line. + skipComments bool // Skip commented lines. If false, Next() returns a commented line as (nil, nil). If true, Next() simply skips forward until it finds a non-commented line. + limit int // if format is a csv, tsv, or jsonl, then limit the number of items processed. + objectType reflect.Type // the type of the output object + pretty bool // pretty output + lineSeparator string // new line character, used by properties and jsonl keyValueSeparator string sorted bool // sort output reversed bool // if sorted, sort in reverse alphabetical order @@ -234,7 +235,7 @@ func NewWithOptions(format string, options ...map[string]interface{}) (*Serializ s = s.ExpandHeader(v > 0.0) } case "header": - s = s.Header(toInterfaceSlice(value)) + s = s.Header(object.NewObjectArray(toInterfaceSlice(value))) default: return s, &ErrUnknownOption{Name: key} } @@ -263,7 +264,7 @@ func (s *Serializer) Fit(f bool) *Serializer { } // Header sets the header of the serializer. -func (s *Serializer) Header(header []interface{}) *Serializer { +func (s *Serializer) Header(header object.ObjectArray) *Serializer { s.header = header return s } @@ -540,7 +541,7 @@ func (s *Serializer) Deserialize(b []byte) (interface{}, error) { } // Serialize serializes an object into a slice of byte and returns and error, if any. -func (s *Serializer) Serialize(object interface{}) ([]byte, error) { +func (s *Serializer) Serialize(obj interface{}) ([]byte, error) { keySerializer := s.keySerializer if keySerializer == nil { @@ -554,7 +555,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { switch s.format { case FormatBSON: - o, err := stringify.StringifyMapKeys(object, keySerializer) + o, err := stringify.StringifyMapKeys(obj, keySerializer) if err != nil { return make([]byte, 0), fmt.Errorf("error stringifying map keys: %w", err) } @@ -568,7 +569,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { errWrite := sv.Write(&sv.WriteInput{ Writer: buf, Separator: separator, - Object: object, + Object: object.NewObject(obj), KeySerializer: keySerializer, ValueSerializer: valueSerializer, Sorted: s.sorted, @@ -583,9 +584,9 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { return buf.Bytes(), nil case FormatFmt: if s.fit { - return []byte(fmt.Sprintf(s.formatSpecifier, fit.Fit(object))), nil + return []byte(fmt.Sprintf(s.formatSpecifier, fit.Fit(obj))), nil } - return []byte(fmt.Sprintf(s.formatSpecifier, object)), nil + return []byte(fmt.Sprintf(s.formatSpecifier, obj)), nil case FormatGo: // TODO: // Pretty output disabled until https://github.com/kr/pretty/issues/45 is fixed @@ -594,26 +595,26 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { // return []byte(krpretty.Sprint(object)), nil //} if s.fit { - return []byte(fmt.Sprintf("%#v", fit.Fit(object))), nil + return []byte(fmt.Sprintf("%#v", fit.Fit(obj))), nil } - return []byte(fmt.Sprintf("%#v", object)), nil + return []byte(fmt.Sprintf("%#v", obj)), nil case FormatGob: - return gob.Marshal(object, s.fit) + return gob.Marshal(obj, s.fit) case FormatJSON: - o, err := stringify.StringifyMapKeys(object, keySerializer) + o, err := stringify.StringifyMapKeys(obj, keySerializer) if err != nil { return make([]byte, 0), fmt.Errorf("error stringifying map keys: %w", err) } return json.Marshal(o, s.pretty) case FormatJSONL: - return jsonl.Marshal(object, s.lineSeparator, keySerializer, s.pretty, s.limit) + return jsonl.Marshal(obj, s.lineSeparator, keySerializer, s.pretty, s.limit) case FormatProperties: buf := new(bytes.Buffer) err := properties.Write(&properties.WriteInput{ Writer: buf, LineSeparator: s.lineSeparator, KeyValueSeparator: s.keyValueSeparator, - Object: object, + Object: obj, KeySerializer: keySerializer, ValueSerializer: valueSerializer, Sorted: s.sorted, @@ -639,7 +640,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { ExpandKeys: s.expandHeader, KeyValueSeparator: s.keyValueSeparator, LineSeparator: s.lineSeparator, - Object: object, + Object: obj, KeySerializer: keySerializer, ValueSerializer: valueSerializer, Sorted: s.sorted, @@ -651,7 +652,7 @@ func (s *Serializer) Serialize(object interface{}) ([]byte, error) { } return buf.Bytes(), nil case FormatTOML, FormatYAML: - o, err := stringify.StringifyMapKeys(object, keySerializer) + o, err := stringify.StringifyMapKeys(obj, keySerializer) if err != nil { return make([]byte, 0), fmt.Errorf("error stringifying map keys: %w", err) } diff --git a/pkg/serializer/Serializer_serialize_test.go b/pkg/serializer/Serializer_serialize_test.go index ee69cff..87ea2c1 100644 --- a/pkg/serializer/Serializer_serialize_test.go +++ b/pkg/serializer/Serializer_serialize_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/assert" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -104,7 +105,7 @@ func TestSerializerCSVSliceExpandHeaderWithWildcard(t *testing.T) { "c": "6", }, } - s := New(FormatCSV).Limit(NoLimit).ExpandHeader(true).Header([]interface{}{"*", "c"}) + s := New(FormatCSV).Limit(NoLimit).ExpandHeader(true).Header(object.NewObjectArray([]interface{}{"*", "c"})) out, err := s.Serialize(in) assert.NoError(t, err) assert.Equal(t, "a,b,c\n1,,3\n,5,6\n", string(out)) diff --git a/pkg/sv/CreateHeaderAndKnownKeys.go b/pkg/sv/CreateHeaderAndKnownKeys.go deleted file mode 100644 index f912efe..0000000 --- a/pkg/sv/CreateHeaderAndKnownKeys.go +++ /dev/null @@ -1,17 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "reflect" -) - -// CreateHeaderAndKnownKeys returns an object's keys or field names as a slice and set. -func CreateHeaderAndKnownKeys(object interface{}, sorted bool, reversed bool) ([]interface{}, map[interface{}]struct{}) { - return CreateHeaderAndKnownKeysFromValue(reflect.ValueOf(object), sorted, reversed) -} diff --git a/pkg/sv/CreateHeaderAndKnownKeysFromValue.go b/pkg/sv/CreateHeaderAndKnownKeysFromValue.go deleted file mode 100644 index f349032..0000000 --- a/pkg/sv/CreateHeaderAndKnownKeysFromValue.go +++ /dev/null @@ -1,41 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "reflect" - - "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" -) - -// CreateHeaderAndKnownKeysFromValue returns an object's keys or field names as a slice and set. -func CreateHeaderAndKnownKeysFromValue(objectValue reflect.Value, sorted bool, reversed bool) ([]interface{}, map[interface{}]struct{}) { - for reflect.TypeOf(objectValue.Interface()).Kind() == reflect.Ptr { - objectValue = objectValue.Elem() - } - objectValue = reflect.ValueOf(objectValue.Interface()) // sets value to concerete type - switch objectValue.Type().Kind() { - case reflect.Map: - keys := inspector.GetKeys(objectValue.Interface(), sorted, reversed) - knownKeys := map[interface{}]struct{}{} - for _, key := range keys { - knownKeys[key] = struct{}{} - } - return keys, knownKeys - case reflect.Struct: - fieldNames := inspector.GetFieldNames(objectValue.Interface(), sorted, reversed) - header := make([]interface{}, 0, len(fieldNames)) - knownKeys := map[interface{}]struct{}{} - for _, fieldName := range fieldNames { - header = append(header, fieldName) - knownKeys[fieldName] = struct{}{} - } - return header, knownKeys - } - return make([]interface{}, 0), map[interface{}]struct{}{} -} diff --git a/pkg/sv/CreateHeaderAndKnownKeys_test.go b/pkg/sv/CreateHeaderAndKnownKeys_test.go deleted file mode 100644 index 480dc1e..0000000 --- a/pkg/sv/CreateHeaderAndKnownKeys_test.go +++ /dev/null @@ -1,46 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestCreateHeaderAndKnownKeys(t *testing.T) { - in := map[string]interface{}{ - "a": "x", - "b": "y", - "c": "z", - } - expectedKnownKeys := map[interface{}]struct{}{ - "a": struct{}{}, - "b": struct{}{}, - "c": struct{}{}, - } - header, knownKeys := CreateHeaderAndKnownKeys(in, true, false) - assert.Equal(t, []interface{}{"a", "b", "c"}, header) - assert.Equal(t, expectedKnownKeys, knownKeys) -} - -func TestCreateHeaderAndKnownKeysPointer(t *testing.T) { - in := map[string]interface{}{ - "a": "x", - "b": "y", - "c": "z", - } - expectedKnownKeys := map[interface{}]struct{}{ - "a": struct{}{}, - "b": struct{}{}, - "c": struct{}{}, - } - header, knownKeys := CreateHeaderAndKnownKeys(&in, true, false) - assert.Equal(t, []interface{}{"a", "b", "c"}, header) - assert.Equal(t, expectedKnownKeys, knownKeys) -} diff --git a/pkg/sv/ExpandHeader.go b/pkg/sv/ExpandHeader.go deleted file mode 100644 index ad53dfa..0000000 --- a/pkg/sv/ExpandHeader.go +++ /dev/null @@ -1,29 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "reflect" - - "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" -) - -// ExpandHeader expands a table header with the keys from the given object. -func ExpandHeader(header []interface{}, knownKeys map[interface{}]struct{}, object reflect.Value, sorted bool, reversed bool) ([]interface{}, map[interface{}]struct{}) { - newHeader := make([]interface{}, 0, len(header)) - newKnownKeys := map[interface{}]struct{}{} - for _, knownKey := range header { - newHeader = append(newHeader, knownKey) - newKnownKeys[knownKey] = struct{}{} - } - for _, unknownKey := range inspector.GetUnknownKeysFromValue(object, knownKeys, sorted, reversed) { - newHeader = append(newHeader, unknownKey) - newKnownKeys[unknownKey] = struct{}{} - } - return newHeader, newKnownKeys -} diff --git a/pkg/sv/ExpandHeaderWithWildcard.go b/pkg/sv/ExpandHeaderWithWildcard.go deleted file mode 100644 index e87b810..0000000 --- a/pkg/sv/ExpandHeaderWithWildcard.go +++ /dev/null @@ -1,34 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "reflect" - - "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" -) - -// ExpandHeaderWithWildcard expands a table header at the wildcard position with keys from the object. -func ExpandHeaderWithWildcard(header []interface{}, knownKeys map[interface{}]struct{}, object reflect.Value, sorted bool, reversed bool) ([]interface{}, map[interface{}]struct{}) { - newHeader := make([]interface{}, 0, len(header)) - newKnownKeys := map[interface{}]struct{}{} - for _, knownKey := range header { - if str, ok := knownKey.(string); ok && str == Wildcard { - for _, unknownKey := range inspector.GetUnknownKeysFromValue(object, knownKeys, sorted, reversed) { - newHeader = append(newHeader, unknownKey) - newKnownKeys[unknownKey] = struct{}{} - } - // Keep the wildcard in place for future expanding of the heade - newHeader = append(newHeader, knownKey) - } else { - newHeader = append(newHeader, knownKey) - newKnownKeys[knownKey] = struct{}{} - } - } - return newHeader, newKnownKeys -} diff --git a/pkg/sv/ExpandHeaderWithWildcard_test.go b/pkg/sv/ExpandHeaderWithWildcard_test.go deleted file mode 100644 index fbee43d..0000000 --- a/pkg/sv/ExpandHeaderWithWildcard_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "reflect" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestExpandHeaderWithWildcard(t *testing.T) { - in := map[string]interface{}{ - "a": "x", - "b": "y", - "c": "z", - } - header := []interface{}{"b", Wildcard} - knownKeys := map[interface{}]struct{}{ - "b": struct{}{}, - } - expectedKnownKeys := map[interface{}]struct{}{ - "a": struct{}{}, - "b": struct{}{}, - "c": struct{}{}, - } - - newHeader, newKnownKeys := ExpandHeaderWithWildcard(header, knownKeys, reflect.ValueOf(in), true, false) - assert.Equal(t, []interface{}{"b", "a", "c", Wildcard}, newHeader) - assert.Equal(t, expectedKnownKeys, newKnownKeys) - - in = map[string]interface{}{ - "d": "x", - "e": "y", - "f": "z", - } - header = newHeader - knownKeys = newKnownKeys - expectedKnownKeys = map[interface{}]struct{}{ - "a": struct{}{}, - "b": struct{}{}, - "c": struct{}{}, - "d": struct{}{}, - "e": struct{}{}, - "f": struct{}{}, - } - newHeader, newKnownKeys = ExpandHeaderWithWildcard(header, knownKeys, reflect.ValueOf(in), true, false) - assert.Equal(t, []interface{}{"b", "a", "c", "d", "e", "f", Wildcard}, newHeader) - assert.Equal(t, expectedKnownKeys, newKnownKeys) -} diff --git a/pkg/sv/ExpandHeader_test.go b/pkg/sv/ExpandHeader_test.go deleted file mode 100644 index c0fb66c..0000000 --- a/pkg/sv/ExpandHeader_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "reflect" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestExpandHeader(t *testing.T) { - in := map[string]interface{}{ - "a": "x", - "b": "y", - "c": "z", - } - header := []interface{}{"b"} - knownKeys := map[interface{}]struct{}{ - "b": struct{}{}, - } - expectedKnownKeys := map[interface{}]struct{}{ - "a": struct{}{}, - "b": struct{}{}, - "c": struct{}{}, - } - - newHeader, newKnownKeys := ExpandHeader(header, knownKeys, reflect.ValueOf(in), true, false) - assert.Equal(t, []interface{}{"b", "a", "c"}, newHeader) - assert.Equal(t, expectedKnownKeys, newKnownKeys) - - in = map[string]interface{}{ - "d": "x", - "e": "y", - "f": "z", - } - header = newHeader - knownKeys = newKnownKeys - expectedKnownKeys = map[interface{}]struct{}{ - "a": struct{}{}, - "b": struct{}{}, - "c": struct{}{}, - "d": struct{}{}, - "e": struct{}{}, - "f": struct{}{}, - } - newHeader, newKnownKeys = ExpandHeader(header, knownKeys, reflect.ValueOf(in), true, false) - assert.Equal(t, []interface{}{"b", "a", "c", "d", "e", "f"}, newHeader) - assert.Equal(t, expectedKnownKeys, newKnownKeys) -} diff --git a/pkg/sv/Iterator.go b/pkg/sv/Iterator.go index e7ec182..d2c0a2c 100644 --- a/pkg/sv/Iterator.go +++ b/pkg/sv/Iterator.go @@ -13,13 +13,15 @@ import ( "fmt" "io" "reflect" + + "github.com/spatialcurrent/go-object/pkg/object" ) // Iterator is used to iterate over a table of separated values. type Iterator struct { Reader *csv.Reader Type reflect.Type - header []interface{} + header object.ObjectArray limit int count int } @@ -29,7 +31,7 @@ type NewIteratorInput struct { Reader io.Reader Type reflect.Type // required Separator rune // the values separator - Header []interface{} + Header object.ObjectArray SkipLines int Comment string LazyQuotes bool @@ -64,7 +66,7 @@ func NewIterator(input *NewIteratorInput) (*Iterator, error) { } header := input.Header - if len(input.Header) == 0 { + if header.Empty() { h, err := reader.Read() if err != nil { if err == io.EOF { @@ -72,10 +74,7 @@ func NewIterator(input *NewIteratorInput) (*Iterator, error) { } return nil, fmt.Errorf("error reading header: %w", err) } - header = make([]interface{}, 0, len(h)) - for _, str := range h { - header = append(header, str) - } + header = object.NewStringArray(h).ObjectArray() } return &Iterator{Reader: reader, Type: input.Type, header: header, limit: input.Limit, count: 0}, nil @@ -100,7 +99,7 @@ func (it *Iterator) Next() (interface{}, error) { return nil, fmt.Errorf("error reading next line: %w", err) } m := reflect.MakeMap(it.Type) - for i, h := range it.header { + for i, h := range it.header.Value() { if i < len(row) { m.SetMapIndex(reflect.ValueOf(h), reflect.ValueOf(row[i])) } @@ -108,6 +107,6 @@ func (it *Iterator) Next() (interface{}, error) { return m.Interface(), nil } -func (it *Iterator) Header() []interface{} { +func (it *Iterator) Header() object.ObjectArray { return it.header } diff --git a/pkg/sv/Iterator_test.go b/pkg/sv/Iterator_test.go index 25156b5..c4ac070 100644 --- a/pkg/sv/Iterator_test.go +++ b/pkg/sv/Iterator_test.go @@ -14,6 +14,8 @@ import ( "testing" "github.com/stretchr/testify/assert" + + "github.com/spatialcurrent/go-object/pkg/object" ) func TestIterator(t *testing.T) { @@ -68,7 +70,7 @@ joe,XYZ,79 Comment: "", SkipLines: 1, // skip the first line: a,b,c LazyQuotes: false, - Header: []interface{}{"name", "type", "age"}, + Header: object.NewObjectArray([]interface{}{"name", "type", "age"}), }) assert.NoError(t, err) diff --git a/pkg/sv/Read.go b/pkg/sv/Read.go index 434399b..21450ba 100644 --- a/pkg/sv/Read.go +++ b/pkg/sv/Read.go @@ -12,6 +12,7 @@ import ( "io" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" ) @@ -20,7 +21,7 @@ type ReadInput struct { Type reflect.Type // the output type Reader io.Reader Separator rune // the values separator - Header []interface{} + Header object.ObjectArray SkipLines int Comment string LazyQuotes bool diff --git a/pkg/sv/RemoveWildcard.go b/pkg/sv/RemoveWildcard.go deleted file mode 100644 index 2530b2a..0000000 --- a/pkg/sv/RemoveWildcard.go +++ /dev/null @@ -1,18 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -func RemoveWildcard(header []interface{}) []interface{} { - newHeader := make([]interface{}, 0) - for _, x := range header { - if str, ok := x.(string); !ok || str != Wildcard { - newHeader = append(newHeader, x) - } - } - return newHeader -} diff --git a/pkg/sv/RemoveWildcard_test.go b/pkg/sv/RemoveWildcard_test.go deleted file mode 100644 index deabaac..0000000 --- a/pkg/sv/RemoveWildcard_test.go +++ /dev/null @@ -1,24 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestRemoveWildcard(t *testing.T) { - in := []interface{}{ - "a", - "*", - "c", - } - out := RemoveWildcard(in) - assert.Equal(t, []interface{}{"a", "c"}, out) -} diff --git a/pkg/sv/ToRow.go b/pkg/sv/ToRow.go deleted file mode 100644 index 985b8f5..0000000 --- a/pkg/sv/ToRow.go +++ /dev/null @@ -1,17 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "reflect" -) - -// ToRow converts an object into a row of strings and returns an error, if any. -func ToRow(object interface{}, columns []interface{}, valueSerializer func(object interface{}) (string, error)) ([]string, error) { - return ToRowFromValue(reflect.ValueOf(object), columns, valueSerializer) -} diff --git a/pkg/sv/ToRowFromValue.go b/pkg/sv/ToRowFromValue.go deleted file mode 100644 index 6965731..0000000 --- a/pkg/sv/ToRowFromValue.go +++ /dev/null @@ -1,60 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "fmt" - "reflect" - "strings" -) - -// ToRowFromValue converts an object into a row of strings and returns an error, if any. -func ToRowFromValue(objectValue reflect.Value, columns []interface{}, valueSerializer func(object interface{}) (string, error)) ([]string, error) { - for reflect.TypeOf(objectValue.Interface()).Kind() == reflect.Ptr { - objectValue = objectValue.Elem() - } - objectValue = reflect.ValueOf(objectValue.Interface()) // sets value to concerete type - row := make([]string, len(columns)) - switch objectValue.Type().Kind() { - case reflect.Map: - for j, key := range columns { - if v := objectValue.MapIndex(reflect.ValueOf(key)); v.IsValid() && (v.Type().Kind() == reflect.String || !v.IsNil()) { - str, err := valueSerializer(v.Interface()) - if err != nil { - return row, fmt.Errorf("error serializing value: %w", err) - } - row[j] = str - } else { - str, err := valueSerializer(nil) - if err != nil { - return row, fmt.Errorf("error serializing value: %w", err) - } - row[j] = str - } - } - case reflect.Struct: - for j, column := range columns { - columnLowerCase := strings.ToLower(fmt.Sprint(column)) - if f := objectValue.FieldByNameFunc(func(match string) bool { return strings.ToLower(match) == columnLowerCase }); f.IsValid() && (f.Type().Kind() == reflect.String || !f.IsNil()) { - str, err := valueSerializer(f.Interface()) - if err != nil { - return row, fmt.Errorf("error serializing value: %w", err) - } - row[j] = str - } else { - str, err := valueSerializer(nil) - if err != nil { - return row, fmt.Errorf("error serializing value: %w", err) - } - row[j] = str - } - } - } - - return row, nil -} diff --git a/pkg/sv/ToRow_test.go b/pkg/sv/ToRow_test.go deleted file mode 100644 index 0453b2e..0000000 --- a/pkg/sv/ToRow_test.go +++ /dev/null @@ -1,28 +0,0 @@ -// ================================================================= -// -// Copyright (C) 2019 Spatial Current, Inc. - All Rights Reserved -// Released as open source under the MIT License. See LICENSE file. -// -// ================================================================= - -package sv - -import ( - "testing" - - "github.com/stretchr/testify/assert" - - "github.com/spatialcurrent/go-stringify/pkg/stringify" -) - -func TestToRow(t *testing.T) { - in := map[string]interface{}{ - "a": "x", - "b": "y", - "c": "z", - } - header := []interface{}{"a", "b", "c"} - row, err := ToRow(in, header, stringify.NewStringer("", false, false, false)) - assert.NoError(t, err) - assert.Equal(t, []string{"x", "y", "z"}, row) -} diff --git a/pkg/sv/Write.go b/pkg/sv/Write.go index aebbc81..0ad293b 100644 --- a/pkg/sv/Write.go +++ b/pkg/sv/Write.go @@ -11,8 +11,8 @@ import ( "fmt" "io" "reflect" - "sort" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -21,13 +21,13 @@ import ( type WriteInput struct { Writer io.Writer // the underlying writer Separator rune // the values separator - Header []interface{} + Header object.ObjectArray KeySerializer stringify.Stringer ValueSerializer stringify.Stringer - Object interface{} // the object to write - ExpandHeader bool // dynamically expand header, requires caching output in memory - Sorted bool // sort columns - Reversed bool // if sorted, sort in reverse alphabetical order. + Object object.Object // the object to write + ExpandHeader bool // dynamically expand header, requires caching output in memory + Sorted bool // sort columns + Reversed bool // if sorted, sort in reverse alphabetical order. Limit int } @@ -36,8 +36,10 @@ type WriteInput struct { // Otherwise, just writes a CSV with a header and one row for the object. func Write(input *WriteInput) error { + concrete := input.Object.Concrete() + // If the input is a slice of strings, simply write it as a row - if slc, ok := input.Object.([]string); ok { + if slc, ok := concrete.Value().([]string); ok { errWriteTable := WriteTable(&WriteTableInput{ Writer: input.Writer, Separator: input.Separator, @@ -51,14 +53,6 @@ func Write(input *WriteInput) error { } } - inputObject := input.Object - inputObjectValue := reflect.ValueOf(inputObject) - for reflect.TypeOf(inputObjectValue.Interface()).Kind() == reflect.Ptr { - inputObjectValue = inputObjectValue.Elem() - } - inputObjectValue = reflect.ValueOf(inputObjectValue.Interface()) // sets value to concerete type - inputObjectKind := inputObjectValue.Type().Kind() - if input.ExpandHeader { // set the key serializer @@ -75,84 +69,91 @@ func Write(input *WriteInput) error { // initialize header, wildcard, and known keys header := input.Header - wildcard := false - knownKeys := map[interface{}]struct{}{} - if len(header) > 0 { - for _, k := range header { - if k == "*" { - wildcard = true - } else { - knownKeys[k] = struct{}{} - } - } - if input.Sorted { - sort.Slice(header, func(i, j int) bool { - return (fmt.Sprint(header[i]) < fmt.Sprint(header[j])) && (!input.Reversed) - }) - } - } + wildcard := header.Unique().Has("*") rows := make([][]string, 0) - switch inputObjectKind { + switch concrete.Kind() { case reflect.Map, reflect.Struct: - if len(header) == 0 { - header, _ = CreateHeaderAndKnownKeysFromValue(inputObjectValue, input.Sorted, input.Reversed) + + if header.Empty() { + header = concrete.Keys().Append(concrete.FieldNames().ObjectArray()) } else if wildcard { - header, _ = ExpandHeaderWithWildcard(header, knownKeys, inputObjectValue, input.Sorted, input.Reversed) + header = header.Replace( + "*", + header.Append(concrete.Keys().Append(concrete.FieldNames().ObjectArray()).Unique().Subtract(header.Unique()).Array()).Value()..., + ) } else { - header, _ = ExpandHeader(header, knownKeys, inputObjectValue, input.Sorted, input.Reversed) + // Get keys from object, subtract the known keys, and add the difference to the header + header = header.Append(concrete.Keys().Append(concrete.FieldNames().ObjectArray()).Unique().Subtract(header.Unique()).Array()) } - row, err := ToRowFromValue(inputObjectValue, header, valueSerializer) - if err != nil { - return fmt.Errorf("error serializing object to row: %w", err) + + // Create row from object + row, errorRow := header.MapE(func(i int, v interface{}) (interface{}, error) { + switch concrete.Kind() { + case reflect.Map: + return valueSerializer(concrete.Index(v).Value()) + case reflect.Struct: + return valueSerializer(concrete.FieldByName(object.NewObject(v).String()).Value()) + } + return nil, nil + }) + if errorRow != nil { + return fmt.Errorf("error serializing object as row: %w", errorRow) } - rows = append(rows, row) + rows = append(rows, row.StringArray().Value()) + case reflect.Array, reflect.Slice: - if inputObjectValue.Len() == 0 { + if concrete.Empty() { // If there are no records then just return an empty string return nil } - if len(header) == 0 { - header, knownKeys = CreateHeaderAndKnownKeysFromValue(inputObjectValue.Index(0), input.Sorted, input.Reversed) - for i := 0; i < inputObjectValue.Len() && (input.Limit < 0 || i <= input.Limit); i++ { - header, knownKeys = ExpandHeader(header, knownKeys, concerete(inputObjectValue.Index(i)), input.Sorted, input.Reversed) - row, err := ToRowFromValue(concerete(inputObjectValue.Index(i)), header, valueSerializer) - if err != nil { - return fmt.Errorf("error serializing object to row: %w", err) - } - rows = append(rows, row) - } - } else if wildcard { - // With a wildcard, must expand header before creating rows - for i := 0; i < inputObjectValue.Len() && (input.Limit < 0 || i <= input.Limit); i++ { - header, knownKeys = ExpandHeaderWithWildcard(header, knownKeys, concerete(inputObjectValue.Index(i)), input.Sorted, input.Reversed) - } - header = RemoveWildcard(header) - for i := 0; i < inputObjectValue.Len() && (input.Limit < 0 || i <= input.Limit); i++ { - row, err := ToRowFromValue(concerete(inputObjectValue.Index(i)), header, valueSerializer) - if err != nil { - return fmt.Errorf("error serializing object to row: %w", err) - } - rows = append(rows, row) + // create header + for i := 0; i < concrete.Length() && (input.Limit < 0 || i <= input.Limit); i++ { + x := object.NewObject(concrete.Index(i).Value()).Concrete() + if header.Empty() { + header = x.Keys().Append(x.FieldNames().ObjectArray()) + } else if wildcard { + // replace wildcard with new columns + header = header.Replace( + "*", + header.Append(x.Keys().Append(x.FieldNames().ObjectArray()).Unique().Subtract(header.Unique()).Array()).Value()..., + ) + } else { + // Get keys from object, subtract the known keys, and add the difference to the header + header = header.Append(x.Keys().Append(x.FieldNames().ObjectArray()).Unique().Subtract(header.Unique()).Array()) } - } else { - // If the length of the initial header is greater than zero and does not include a wildcard. - // Can expand header inline - for i := 0; i < inputObjectValue.Len() && (input.Limit < 0 || i <= input.Limit); i++ { - header, knownKeys = ExpandHeader(header, knownKeys, concerete(inputObjectValue.Index(i)), input.Sorted, input.Reversed) - row, err := ToRowFromValue(concerete(inputObjectValue.Index(i)), header, valueSerializer) - if err != nil { - return fmt.Errorf("error serializing object to row: %w", err) + } + // create rows + for i := 0; i < concrete.Length() && (input.Limit < 0 || i <= input.Limit); i++ { + x := object.NewObject(concrete.Index(i).Value()).Concrete() + // Create row from element + row, errorRow := header.MapE(func(i int, v interface{}) (interface{}, error) { + switch x.Kind() { + case reflect.Map: + return valueSerializer(x.Index(v).Value()) + case reflect.Struct: + return valueSerializer(x.FieldByName(object.NewObject(v).String()).Value()) } - rows = append(rows, row) + return nil, nil + }) + if errorRow != nil { + return fmt.Errorf("error serializing object as row: %w", errorRow) } + rows = append(rows, row.StringArray().Value()) } } + + // sort header + if input.Sorted { + header = header.Sort(input.Reversed) + } + outputHeader, errStringifyHeader := stringify.StringifySlice(header, keySerializer) if errStringifyHeader != nil { - return fmt.Errorf("error stringifying header %q: %w", header, errStringifyHeader) + return fmt.Errorf("error stringifying header %v: %w", header.Value(), errStringifyHeader) } + errWriteTable := WriteTable(&WriteTableInput{ Writer: input.Writer, Separator: input.Separator, @@ -169,8 +170,8 @@ func Write(input *WriteInput) error { // if streaming and not expanding header. p := pipe.NewBuilder().OutputLimit(input.Limit) - if inputObjectKind == reflect.Array || inputObjectKind == reflect.Slice { - it, errorIterator := pipe.NewSliceIterator(inputObject) + if concrete.Kind() == reflect.Array || concrete.Kind() == reflect.Slice { + it, errorIterator := pipe.NewSliceIterator(concrete.Value()) if errorIterator != nil { return fmt.Errorf("error creating slice iterator: %w", errorIterator) } @@ -201,7 +202,7 @@ func Write(input *WriteInput) error { input.Reversed, ) - errorWrite := w.WriteObject(inputObject) + errorWrite := w.WriteObject(concrete.Value()) if errorWrite != nil { return fmt.Errorf("error serializing separated values: %w", errorWrite) } diff --git a/pkg/sv/Writer.go b/pkg/sv/Writer.go index b2a0174..e3bc8b3 100644 --- a/pkg/sv/Writer.go +++ b/pkg/sv/Writer.go @@ -13,14 +13,14 @@ import ( "io" "reflect" - "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) type Writer struct { underlying io.Writer writer *csv.Writer - columns []interface{} + columns object.ObjectArray headerWritten bool keySerializer stringify.Stringer valueSerializer stringify.Stringer @@ -31,7 +31,7 @@ type Writer struct { // NewWriter returns a new Writer for writing objects to an underlying writer formatted as separated values. // NewWriter is a streaming writer, so cannot dynamically expand the header. // To dynamically expand the header, then use the Write function with ExpandHeader set to true. -func NewWriter(underlying io.Writer, separator rune, columns []interface{}, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, sorted bool, reversed bool) *Writer { +func NewWriter(underlying io.Writer, separator rune, columns object.ObjectArray, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, sorted bool, reversed bool) *Writer { // Create a new CSV writer. csvWriter := csv.NewWriter(underlying) @@ -63,7 +63,7 @@ func (w *Writer) WriteHeader() error { w.headerWritten = true // Stringify columns into strings - h, err := stringify.StringifySlice(w.columns, w.keySerializer) + h, err := stringify.StringifySlice(w.columns.Value(), w.keySerializer) if err != nil { return fmt.Errorf("error stringifying columns: %w", err) } @@ -76,10 +76,6 @@ func (w *Writer) WriteHeader() error { return nil } -func (w *Writer) ToRow(obj interface{}) ([]string, error) { - return ToRow(obj, w.columns, w.valueSerializer) -} - func (w *Writer) WriteObject(obj interface{}) error { if slc, ok := obj.([]string); ok { @@ -90,25 +86,13 @@ func (w *Writer) WriteObject(obj interface{}) error { return nil } + concrete := object.NewObject(obj).Concrete() + if !w.headerWritten { - if len(w.columns) == 0 { - inputObjectValue := reflect.ValueOf(obj) - for reflect.TypeOf(inputObjectValue.Interface()).Kind() == reflect.Ptr { - inputObjectValue = inputObjectValue.Elem() - } - inputObjectValue = reflect.ValueOf(inputObjectValue.Interface()) // sets value to concerete type - inputObjectKind := inputObjectValue.Type().Kind() - if inputObjectKind == reflect.Map { - w.columns = inspector.GetKeysFromValue(inputObjectValue, w.sorted, w.reversed) - } else if inputObjectKind == reflect.Struct { - fieldNames := make([]interface{}, 0) - for _, fieldName := range inspector.GetFieldNamesFromValue(inputObjectValue, w.sorted, w.reversed) { - fieldNames = append(fieldNames, fieldName) - } - w.columns = fieldNames - } + if w.columns.Empty() { + w.columns = concrete.Keys().Append(concrete.FieldNames().ObjectArray()) } - if len(w.columns) == 0 { + if w.columns.Empty() { return fmt.Errorf("could not infer the header from the given value %#v with type %T", obj, obj) } err := w.WriteHeader() @@ -116,11 +100,21 @@ func (w *Writer) WriteObject(obj interface{}) error { return fmt.Errorf("error writing header: %w", err) } } - row, errorRow := w.ToRow(obj) + + row, errorRow := w.columns.MapE(func(i int, v interface{}) (interface{}, error) { + switch concrete.Kind() { + case reflect.Map: + return w.valueSerializer(concrete.Index(v).Value()) + case reflect.Struct: + return w.valueSerializer(concrete.FieldByName(object.NewObject(v).String()).Value()) + } + return nil, nil + }) if errorRow != nil { return fmt.Errorf("error serializing object as row: %w", errorRow) } - errorWrite := w.writer.Write(row) + + errorWrite := w.writer.Write(row.StringArray().Value()) if errorWrite != nil { return fmt.Errorf("error writing object: %w", errorWrite) } @@ -129,15 +123,10 @@ func (w *Writer) WriteObject(obj interface{}) error { } func (w *Writer) WriteObjects(objects interface{}) error { - value := reflect.ValueOf(objects) - k := value.Type().Kind() - if k == reflect.Ptr { - value = value.Elem() - k = value.Type().Kind() - } - if k == reflect.Array || k == reflect.Slice { - for i := 0; i < value.Len(); i++ { - err := w.WriteObject(value.Index(i).Interface()) + value := object.NewObject(objects).Concrete() + if value.Kind() == reflect.Array || value.Kind() == reflect.Slice { + for i := 0; i < value.Length(); i++ { + err := w.WriteObject(value.Index(i).Value()) if err != nil { return fmt.Errorf("error writing object: %w", err) } diff --git a/pkg/sv/Writer_test.go b/pkg/sv/Writer_test.go index c37c085..374d6ff 100644 --- a/pkg/sv/Writer_test.go +++ b/pkg/sv/Writer_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/assert" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -23,7 +24,7 @@ func TestWriteHeader(t *testing.T) { w := NewWriter( buf, ',', - []interface{}{"a", "b", "d"}, + object.NewObjectArray([]interface{}{"a", "b", "d"}), stringify.NewStringer("", false, false, false), stringify.NewStringer("", false, false, false), true, @@ -43,7 +44,7 @@ func TestWriteHeader(t *testing.T) { } func TestWriteObject(t *testing.T) { - object := map[string]interface{}{ + obj := map[string]interface{}{ "a": "1", "b": "2", "c": "3", @@ -54,7 +55,7 @@ func TestWriteObject(t *testing.T) { w := NewWriter( buf, ',', - []interface{}{"a", "b", "d"}, + object.NewObjectArray([]interface{}{"a", "b", "d"}), stringify.NewStringer("", true, false, false), stringify.NewStringer("", true, false, false), true, @@ -65,7 +66,7 @@ func TestWriteObject(t *testing.T) { err := w.WriteHeader() assert.NoError(t, err) - err = w.WriteObject(object) + err = w.WriteObject(obj) assert.NoError(t, err) err = w.Flush() @@ -95,7 +96,7 @@ func TestWriterObjects(t *testing.T) { w := NewWriter( buf, ',', - []interface{}{"a", "b", "d"}, + object.NewObjectArray([]interface{}{"a", "b", "d"}), stringify.NewStringer("", true, false, false), stringify.NewStringer("", true, false, false), true, @@ -144,7 +145,7 @@ func TestWriteStructs(t *testing.T) { w := NewWriter( buf, ',', - []interface{}{"a", "b", "d"}, + object.NewObjectArray([]interface{}{"a", "b", "d"}), stringify.NewStringer("", true, false, false), stringify.NewStringer("", true, false, false), true, diff --git a/pkg/tags/Marshal.go b/pkg/tags/Marshal.go index 61ff4cd..f6798aa 100644 --- a/pkg/tags/Marshal.go +++ b/pkg/tags/Marshal.go @@ -13,12 +13,12 @@ import ( "reflect" "strings" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-simple-serializer/pkg/escaper" - "github.com/spatialcurrent/go-simple-serializer/pkg/inspector" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) -func marshalTag(keyValueSeparator []byte, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, e *escaper.Escaper, objectValue reflect.Value, key interface{}) ([]byte, error) { +func marshalTag(keyValueSeparator []byte, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, e *escaper.Escaper, obj object.Object, key interface{}) ([]byte, error) { keyString, errKeyString := keySerializer(key) if errKeyString != nil { return make([]byte, 0), fmt.Errorf("error serializing tag key: %w", errKeyString) @@ -37,7 +37,7 @@ func marshalTag(keyValueSeparator []byte, keySerializer stringify.Stringer, valu return make([]byte, 0), fmt.Errorf("error writing key-value separator: %w", err) } - value, valueStringError := valueSerializer(objectValue.MapIndex(reflect.ValueOf(key)).Interface()) + value, valueStringError := valueSerializer(obj.Index(key).Value()) if valueStringError != nil { return make([]byte, 0), fmt.Errorf("error serializing tag value: %w", valueStringError) } @@ -59,7 +59,9 @@ func marshalTag(keyValueSeparator []byte, keySerializer stringify.Stringer, valu // If expandKeys is true, then adds unknown keys to the end of the list of tags. // If sorted and not reversed, then the keys are sorted in alphabetical order. // If sorted and reversed, then the keys are sorted in reverse alphabetical order. -func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSeparator string, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, sorted bool, reversed bool) ([]byte, error) { +func Marshal(obj interface{}, keys object.ObjectArray, expandKeys bool, keyValueSeparator string, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, sorted bool, reversed bool) ([]byte, error) { + + concrete := object.NewObject(obj).Concrete() if keySerializer == nil { return make([]byte, 0), ErrMissingKeySerializer @@ -69,35 +71,23 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe return make([]byte, 0), ErrMissingValueSerializer } - objectValue := reflect.ValueOf(object) - for objectValue.Type().Kind() == reflect.Ptr { - objectValue = objectValue.Elem() - } - - objectType := objectValue.Type() - e := escaper.New().Prefix("\\").Sub("\"", "\n") - switch objectType.Kind() { + switch concrete.Kind() { case reflect.Map: out := &bytes.Buffer{} - if len(keys) > 0 { + if keys.Length() > 0 { allKeys := keys if expandKeys { - knownKeys := map[interface{}]struct{}{} - for _, k := range keys { - knownKeys[k] = struct{}{} - } - unknownKeys := inspector.GetUnknownKeysFromValue(objectValue, knownKeys, sorted, reversed) - allKeys = append(keys, unknownKeys...) + allKeys = keys.Append(concrete.Keys().Unique().Subtract(keys.Unique()).Array()) } - for i, key := range allKeys { + for i, key := range allKeys.Value() { b, err := marshalTag( []byte(keyValueSeparator), keySerializer, valueSerializer, e, - objectValue, + concrete, key) if err != nil { return make([]byte, 0), fmt.Errorf("error serializing tag: %w", err) @@ -106,7 +96,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe if err != nil { return make([]byte, 0), fmt.Errorf("error writing tag: %w", err) } - if i < len(allKeys)-1 { + if i < allKeys.Length()-1 { _, err = out.WriteRune(space) if err != nil { return make([]byte, 0), fmt.Errorf("error writing space: %w", err) @@ -114,14 +104,17 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe } } } else { - allKeys := inspector.GetKeysFromValue(objectValue, sorted, reversed) - for i, key := range allKeys { + allKeys := concrete.Keys() + if sorted { + allKeys = allKeys.Sort(reversed) + } + for i, key := range allKeys.Value() { b, err := marshalTag( []byte(keyValueSeparator), keySerializer, valueSerializer, e, - objectValue, + concrete, key) if err != nil { return make([]byte, 0), fmt.Errorf("error serializing tag: %w", err) @@ -130,7 +123,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe if err != nil { return make([]byte, 0), fmt.Errorf("error writing tag: %w", err) } - if i < len(allKeys)-1 { + if i < allKeys.Length()-1 { _, err = out.WriteRune(space) if err != nil { return make([]byte, 0), fmt.Errorf("error writing space: %w", err) @@ -140,27 +133,13 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe } return out.Bytes(), nil case reflect.Struct: - if len(keys) > 0 { - allFieldNames := make([]string, 0) + if keys.Length() > 0 { + allFieldNames := keys.StringArray() if expandKeys { - knownFieldNames := map[string]struct{}{} - for _, k := range keys { - if str, ok := k.(string); ok { - allFieldNames = append(allFieldNames, str) - knownFieldNames[str] = struct{}{} - } - } - unknownFieldNames := inspector.GetUnknownFieldNamesFromValue(objectValue, knownFieldNames, sorted, reversed) - allFieldNames = append(allFieldNames, unknownFieldNames...) - } else { - for _, k := range keys { - if str, ok := k.(string); ok { - allFieldNames = append(allFieldNames, str) - } - } + allFieldNames = keys.StringArray().Append(concrete.FieldNames().Unique().Subtract(keys.Unique().StringArray().Value()...).Array()) } out := &bytes.Buffer{} - for i, fieldName := range allFieldNames { + for i, fieldName := range allFieldNames.Value() { keyString, errKeyString := keySerializer(fieldName) if errKeyString != nil { return out.Bytes(), fmt.Errorf("error serializing tag key: %w", errKeyString) @@ -173,7 +152,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe if err != nil { return out.Bytes(), fmt.Errorf("error writing key-value separator: %w", err) } - value, err := valueSerializer(objectValue.FieldByName(fieldName).Interface()) + value, err := valueSerializer(concrete.FieldByName(fieldName).Value()) if err != nil { return out.Bytes(), fmt.Errorf("error serializing tag value: %w", err) } @@ -184,7 +163,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe out.WriteString(e.Escape(value)) } } - if i < len(allFieldNames)-1 { + if i < allFieldNames.Length()-1 { _, err = out.WriteRune(space) if err != nil { return make([]byte, 0), fmt.Errorf("error writing space: %w", err) @@ -194,8 +173,11 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe return out.Bytes(), nil } else { out := &bytes.Buffer{} - fieldNames := inspector.GetFieldNamesFromValue(objectValue, sorted, reversed) - for i, fieldName := range fieldNames { + fieldNames := concrete.FieldNames() + if sorted { + fieldNames = fieldNames.Sort(reversed) + } + for i, fieldName := range fieldNames.Value() { keyString, errKeyString := keySerializer(fieldName) if errKeyString != nil { return out.Bytes(), fmt.Errorf("error serializing tag key: %w", errKeyString) @@ -208,7 +190,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe if err != nil { return out.Bytes(), fmt.Errorf("error writing key-value separator: %w", err) } - value, err := valueSerializer(objectValue.FieldByName(fieldName).Interface()) + value, err := valueSerializer(concrete.FieldByName(fieldName).Value()) if err != nil { return out.Bytes(), fmt.Errorf("error serializing tag value: %w", err) } @@ -219,7 +201,7 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe out.WriteString(e.Escape(value)) } } - if i < len(fieldNames)-1 { + if i < fieldNames.Length()-1 { _, err = out.WriteRune(space) if err != nil { return make([]byte, 0), fmt.Errorf("error writing space: %w", err) @@ -230,5 +212,5 @@ func Marshal(object interface{}, keys []interface{}, expandKeys bool, keyValueSe } } - return []byte(""), &ErrInvalidKind{Value: objectType, Expected: []reflect.Kind{reflect.Map, reflect.Struct}} + return []byte(""), &ErrInvalidKind{Value: concrete.Type(), Expected: []reflect.Kind{reflect.Map, reflect.Struct}} } diff --git a/pkg/tags/Marshal_examples_test.go b/pkg/tags/Marshal_examples_test.go index 548ccbb..3be851a 100644 --- a/pkg/tags/Marshal_examples_test.go +++ b/pkg/tags/Marshal_examples_test.go @@ -10,6 +10,7 @@ package tags import ( "fmt" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -20,7 +21,7 @@ func ExampleMarshal_map() { "b": 2, "c": 3, } - keys := make([]interface{}, 0) + keys := object.NewObjectArray([]interface{}{}) b, err := Marshal(obj, keys, true, "=", stringify.NewStringer("", false, false, false), stringify.NewStringer("", false, false, false), true, false) if err != nil { panic(err) @@ -36,7 +37,7 @@ func ExampleMarshal_stuct() { B string C string }{A: "1", B: "2", C: "3"} - keys := make([]interface{}, 0) + keys := object.NewObjectArray([]interface{}{}) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) b, err := Marshal(in, keys, true, "=", keySerializer, valueSerializer, true, false) diff --git a/pkg/tags/Marshal_test.go b/pkg/tags/Marshal_test.go index 4b4ce0b..451a7df 100644 --- a/pkg/tags/Marshal_test.go +++ b/pkg/tags/Marshal_test.go @@ -12,13 +12,14 @@ import ( "github.com/stretchr/testify/assert" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) func TestMarshalMap(t *testing.T) { in := map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0} - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) @@ -30,7 +31,7 @@ func TestMarshalMap(t *testing.T) { func TestMarshalMapKeys(t *testing.T) { in := map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0} - keys := []interface{}{"a", "c"} + keys := object.NewObjectArray([]interface{}{"a", "c"}) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) @@ -42,7 +43,7 @@ func TestMarshalMapKeys(t *testing.T) { func TestMarshalMapKeysExpand(t *testing.T) { in := map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0} - keys := []interface{}{"a", "c"} + keys := object.NewObjectArray([]interface{}{"a", "c"}) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) @@ -54,7 +55,7 @@ func TestMarshalMapKeysExpand(t *testing.T) { func TestMarshalMapUpper(t *testing.T) { in := map[string]interface{}{"a": 1.0, "b": 2.0, "c": 3.0} - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, false, true) valueSerializer := stringify.NewStringer("", false, false, false) @@ -69,7 +70,7 @@ func TestMarshalStruct(t *testing.T) { B string C string }{A: "1", B: "2", C: "3"} - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) b, err := Marshal(in, keys, true, "=", keySerializer, valueSerializer, true, false) @@ -83,7 +84,7 @@ func TestMarshalStructKeys(t *testing.T) { B string C string }{A: "1", B: "2", C: "3"} - keys := []interface{}{"A", "C"} + keys := object.NewObjectArray([]interface{}{"A", "C"}) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) b, err := Marshal(in, keys, false, "=", keySerializer, valueSerializer, true, false) @@ -97,7 +98,7 @@ func TestMarshalStructLower(t *testing.T) { B string C string }{A: "1", B: "2", C: "3"} - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, true, false) valueSerializer := stringify.NewStringer("", false, false, false) b, err := Marshal(in, keys, true, "=", keySerializer, valueSerializer, true, false) diff --git a/pkg/tags/Read.go b/pkg/tags/Read.go index 3ca52b8..279bd60 100644 --- a/pkg/tags/Read.go +++ b/pkg/tags/Read.go @@ -12,14 +12,15 @@ import ( "io" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" ) // ReadInput provides the input for the Read function. type ReadInput struct { - Type reflect.Type // the output type - Reader io.Reader // the underlying reader - Keys []interface{} // the keys to read + Type reflect.Type // the output type + Reader io.Reader // the underlying reader + Keys object.ObjectArray // the keys to read SkipLines int SkipBlanks bool SkipComments bool diff --git a/pkg/tags/Write.go b/pkg/tags/Write.go index d6523e9..c2a5740 100644 --- a/pkg/tags/Write.go +++ b/pkg/tags/Write.go @@ -12,18 +12,19 @@ import ( "io" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) // WriteInput provides the input for the Write function. type WriteInput struct { - Writer io.Writer // the underlying writer - Keys []interface{} // subset of keys to print - ExpandKeys bool // dynamically expand keys - KeyValueSeparator string // the key-value separator - LineSeparator string // the line separator - Object interface{} // the object to write + Writer io.Writer // the underlying writer + Keys object.ObjectArray // subset of keys to print + ExpandKeys bool // dynamically expand keys + KeyValueSeparator string // the key-value separator + LineSeparator string // the line separator + Object interface{} // the object to write KeySerializer stringify.Stringer ValueSerializer stringify.Stringer Sorted bool // sort keys diff --git a/pkg/tags/Write_examples_test.go b/pkg/tags/Write_examples_test.go index 2093f4b..9c39af5 100644 --- a/pkg/tags/Write_examples_test.go +++ b/pkg/tags/Write_examples_test.go @@ -11,13 +11,14 @@ import ( "bytes" "fmt" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) // This example shows you can marshal a single map into a JSON object func ExampleWrite_map() { obj := map[string]string{"a": "b", "c": "beautiful world", "d": "beautiful \"wide\" world"} - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) @@ -54,7 +55,7 @@ func ExampleWrite_slice() { "c": 6, }, } - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) diff --git a/pkg/tags/Write_test.go b/pkg/tags/Write_test.go index abf6ff7..8d54d65 100644 --- a/pkg/tags/Write_test.go +++ b/pkg/tags/Write_test.go @@ -13,6 +13,7 @@ import ( "github.com/stretchr/testify/assert" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) @@ -29,7 +30,7 @@ func TestWrite(t *testing.T) { "c": 6, }, } - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) buf := new(bytes.Buffer) err := Write(&WriteInput{ @@ -61,7 +62,7 @@ func TestWriteKeys(t *testing.T) { "c": 6, }, } - keys := []interface{}{"a", "c"} + keys := object.NewObjectArray([]interface{}{"a", "c"}) buf := new(bytes.Buffer) err := Write(&WriteInput{ diff --git a/pkg/tags/Writer.go b/pkg/tags/Writer.go index 515f229..65fe48a 100644 --- a/pkg/tags/Writer.go +++ b/pkg/tags/Writer.go @@ -12,16 +12,17 @@ import ( "io" "reflect" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) // Writer formats and writes objects to the underlying writer as JSON Lines (aka jsonl). type Writer struct { - writer io.Writer // writer for the underlying stream - keys []interface{} // known keys in order - expandKeys bool // expand keys with unknown keys - keyValueSeparator string // the separator between a key and value - lineSeparator string // the separator stirng to use, e.g, null byte or \n. + writer io.Writer // writer for the underlying stream + keys object.ObjectArray // known keys in order + expandKeys bool // expand keys with unknown keys + keyValueSeparator string // the separator between a key and value + lineSeparator string // the separator stirng to use, e.g, null byte or \n. keySerializer stringify.Stringer valueSerializer stringify.Stringer sorted bool // sort the keys by alphabetical order @@ -29,7 +30,7 @@ type Writer struct { } // NewWriter returns a writer for formating and writing objets to the underlying writer as JSON Lines (aka jsonl). -func NewWriter(w io.Writer, keys []interface{}, expandKeys bool, keyValueSeparator string, lineSeparator string, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, sorted bool, reversed bool) *Writer { +func NewWriter(w io.Writer, keys object.ObjectArray, expandKeys bool, keyValueSeparator string, lineSeparator string, keySerializer stringify.Stringer, valueSerializer stringify.Stringer, sorted bool, reversed bool) *Writer { return &Writer{ writer: w, keys: keys, diff --git a/pkg/tags/Writer_test.go b/pkg/tags/Writer_test.go index a9f7028..297b9b4 100644 --- a/pkg/tags/Writer_test.go +++ b/pkg/tags/Writer_test.go @@ -14,25 +14,26 @@ import ( "github.com/stretchr/testify/assert" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-stringify/pkg/stringify" ) func TestWriteObject(t *testing.T) { - object := map[string]interface{}{ + obj := map[string]interface{}{ "a": 1, "b": 2, "c": 3, } buf := bytes.NewBuffer(make([]byte, 0)) - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) w := NewWriter(buf, keys, true, "=", "\n", keySerializer, valueSerializer, true, false) assert.NotNil(t, w) - err := w.WriteObject(object) + err := w.WriteObject(obj) assert.NoError(t, err) err = w.Flush() @@ -44,7 +45,7 @@ func TestWriteObject(t *testing.T) { } func TestWriteStruct(t *testing.T) { - object := struct { + obj := struct { A string B string C string @@ -55,9 +56,9 @@ func TestWriteStruct(t *testing.T) { } buf := bytes.NewBuffer(make([]byte, 0)) - keys := make([]interface{}, 0) - keySerializer := func(object interface{}) (string, error) { - str, err := stringify.NewStringer("", false, false, false)(object) + keys := object.NewObjectArray(nil) + keySerializer := func(obj interface{}) (string, error) { + str, err := stringify.NewStringer("", false, false, false)(obj) if err != nil { return str, err } @@ -68,7 +69,7 @@ func TestWriteStruct(t *testing.T) { w := NewWriter(buf, keys, true, "=", "\n", keySerializer, valueSerializer, true, false) assert.NotNil(t, w) - err := w.WriteObject(object) + err := w.WriteObject(obj) assert.NoError(t, err) err = w.Flush() @@ -94,7 +95,7 @@ func TestWriterObjects(t *testing.T) { } buf := bytes.NewBuffer(make([]byte, 0)) - keys := make([]interface{}, 0) + keys := object.NewObjectArray(nil) keySerializer := stringify.NewStringer("", false, false, false) valueSerializer := stringify.NewStringer("", false, false, false) diff --git a/pkg/writer/Writer.go b/pkg/writer/Writer.go index 640f13d..67a4943 100644 --- a/pkg/writer/Writer.go +++ b/pkg/writer/Writer.go @@ -16,6 +16,7 @@ import ( "errors" "io" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-pipe/pkg/pipe" "github.com/spatialcurrent/go-simple-serializer/pkg/fmt" "github.com/spatialcurrent/go-simple-serializer/pkg/gob" @@ -35,7 +36,7 @@ type NewWriterInput struct { Writer io.Writer Format string FormatSpecifier string - Header []interface{} + Header object.ObjectArray ExpandHeader bool // in context, only used by tags as ExpandKeys KeySerializer stringify.Stringer ValueSerializer stringify.Stringer diff --git a/plugins/gss/main.go b/plugins/gss/main.go index 637fb56..ae9836d 100644 --- a/plugins/gss/main.go +++ b/plugins/gss/main.go @@ -20,6 +20,7 @@ import ( "fmt" "strings" + "github.com/spatialcurrent/go-object/pkg/object" "github.com/spatialcurrent/go-simple-serializer/pkg/gss" ) @@ -46,7 +47,7 @@ func Convert(inputString *C.char, inputFormat *C.char, outputFormat *C.char, out s, err := gss.Convert(&gss.ConvertInput{ InputBytes: []byte(C.GoString(inputString)), InputFormat: C.GoString(inputFormat), - InputHeader: []interface{}{}, + InputHeader: object.NewObjectArray(nil), InputComment: "", InputLazyQuotes: false, InputSkipLines: 0, @@ -54,7 +55,7 @@ func Convert(inputString *C.char, inputFormat *C.char, outputFormat *C.char, out InputLineSeparator: "\n", InputEscapePrefix: "//", OutputFormat: C.GoString(outputFormat), - OutputHeader: []interface{}{}, + OutputHeader: object.NewObjectArray(nil), OutputLimit: -1, OutputPretty: C.GoString(outputFormat) == "1", OutputSorted: C.GoString(outputSorted) == "1",