From 0a6b3e5e61befe9bf13cc48f093d52f667d63f98 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 22 Apr 2024 01:44:35 -0700 Subject: [PATCH] refactor: migrate to protobuf-go-lite Signed-off-by: Christian Stewart --- .github/workflows/codeql-analysis.yml | 5 - .github/workflows/dependency-review.yml | 5 - .github/workflows/tests.yml | 5 - Makefile | 81 ++--- cmd/kvfile/.gitignore | 1 + go.mod | 10 +- go.sum | 24 +- hack/go.mod | 12 +- hack/go.sum | 19 +- hack/tools.go | 9 +- kv.pb.go | 398 +++++++++++++++++------- kv_test.go | 1 - kv_vtproto.pb.go | 263 ---------------- yarn.lock | 4 + 14 files changed, 372 insertions(+), 465 deletions(-) create mode 100644 cmd/kvfile/.gitignore delete mode 100644 kv_vtproto.pb.go create mode 100644 yarn.lock diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 89240f0..458da5d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -29,11 +29,6 @@ jobs: # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support steps: - - name: Harden Runner - uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 - with: - egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 3acf143..a64f75f 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -14,11 +14,6 @@ jobs: dependency-review: runs-on: ubuntu-latest steps: - - name: Harden Runner - uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 - with: - egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - name: 'Checkout Repository' uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: 'Dependency Review' diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 874a0d1..2d123a3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -19,11 +19,6 @@ jobs: go: ['1.21'] timeout-minutes: 10 steps: - - name: Harden Runner - uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 - with: - egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Setup Go ${{ matrix.go }} uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 diff --git a/Makefile b/Makefile index 2d0b8ef..c35b1c5 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,8 @@ -# https://github.com/aperturerobotics/protobuf-project +# https://github.com/aperturerobotics/template SHELL:=bash PROTOWRAP=hack/bin/protowrap -PROTOC_GEN_GO=hack/bin/protoc-gen-go -PROTOC_GEN_STARPC=hack/bin/protoc-gen-go-starpc -PROTOC_GEN_VTPROTO=hack/bin/protoc-gen-go-vtproto +PROTOC_GEN_GO=hack/bin/protoc-gen-go-lite GOIMPORTS=hack/bin/goimports GOFUMPT=hack/bin/gofumpt GOLANGCI_LINT=hack/bin/golangci-lint @@ -12,8 +10,8 @@ GO_MOD_OUTDATED=hack/bin/go-mod-outdated GOLIST=go list -f "{{ .Dir }}" -m export GO111MODULE=on -undefine GOOS undefine GOARCH +undefine GOOS all: @@ -23,20 +21,8 @@ vendor: $(PROTOC_GEN_GO): cd ./hack; \ go build -v \ - -o ./bin/protoc-gen-go \ - google.golang.org/protobuf/cmd/protoc-gen-go - -$(PROTOC_GEN_VTPROTO): - cd ./hack; \ - go build -v \ - -o ./bin/protoc-gen-go-vtproto \ - github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto - -$(PROTOC_GEN_STARPC): - cd ./hack; \ - go build -v \ - -o ./bin/protoc-gen-go-starpc \ - github.com/aperturerobotics/starpc/cmd/protoc-gen-go-starpc + -o ./bin/protoc-gen-go-lite \ + github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite $(GOIMPORTS): cd ./hack; \ @@ -68,38 +54,37 @@ $(GO_MOD_OUTDATED): -o ./bin/go-mod-outdated \ github.com/psampaz/go-mod-outdated -.PHONY: gengo -gengo: vendor $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTOC_GEN_VTPROTO) $(PROTOC_GEN_STARPC) +node_modules: + yarn install + +.PHONY: genproto +genproto: vendor node_modules $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) shopt -s globstar; \ set -eo pipefail; \ export PROJECT=$$(go list -m); \ export PATH=$$(pwd)/hack/bin:$${PATH}; \ - mkdir -p $$(pwd)/vendor/$$(dirname $${PROJECT}); \ + export OUT=$$(pwd)/vendor; \ + mkdir -p $${OUT}/$$(dirname $${PROJECT}); \ rm $$(pwd)/vendor/$${PROJECT} || true; \ ln -s $$(pwd) $$(pwd)/vendor/$${PROJECT} ; \ - $(PROTOWRAP) \ - -I $$(pwd)/vendor \ - --go_out=$$(pwd)/vendor \ - --go-vtproto_out=$$(pwd)/vendor \ - --go-vtproto_opt=features=marshal+unmarshal+size+equal+clone \ - --go-starpc_out=$$(pwd)/vendor \ - --proto_path $$(pwd)/vendor \ - --print_structure \ - --only_specified_files \ - $$(\ - git \ - ls-files "*.proto" |\ - xargs printf -- \ - "$$(pwd)/vendor/$${PROJECT}/%s "); \ + protogen() { \ + $(PROTOWRAP) \ + -I $${OUT} \ + --go-lite_out=$${OUT} \ + --go-lite_opt=features=marshal+unmarshal+size+equal+json+clone \ + --proto_path $${OUT} \ + --print_structure \ + --only_specified_files \ + $$(\ + git \ + ls-files "$$1" |\ + xargs printf -- \ + "$$(pwd)/vendor/$${PROJECT}/%s "); \ + }; \ + protogen "./*.proto"; \ rm $$(pwd)/vendor/$${PROJECT} || true $(GOIMPORTS) -w ./ -node_modules: - yarn install - -.PHONY: genproto -genproto: gengo - .PHONY: gen gen: genproto @@ -113,17 +98,17 @@ list: $(GO_MOD_OUTDATED) .PHONY: lint lint: $(GOLANGCI_LINT) - $(GOLANGCI_LINT) run --timeout=10m + $(GOLANGCI_LINT) run .PHONY: fix fix: $(GOLANGCI_LINT) - $(GOLANGCI_LINT) run --fix --timeout=10m + $(GOLANGCI_LINT) run --fix + +.PHONY: test +test: + go test -v ./... .PHONY: format format: $(GOFUMPT) $(GOIMPORTS) $(GOIMPORTS) -w ./ $(GOFUMPT) -w ./ - -.PHONY: test -test: - go test -v ./... diff --git a/cmd/kvfile/.gitignore b/cmd/kvfile/.gitignore new file mode 100644 index 0000000..dd15e38 --- /dev/null +++ b/cmd/kvfile/.gitignore @@ -0,0 +1 @@ +kvfile* \ No newline at end of file diff --git a/go.mod b/go.mod index 354bac7..b6a57e7 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,15 @@ module github.com/aperturerobotics/go-kvfile -go 1.21 +go 1.22 + +toolchain go1.22.2 require ( github.com/SaveTheRbtz/zstd-seekable-format-go v0.6.1 + github.com/aperturerobotics/protobuf-go-lite v0.4.9 github.com/klauspost/compress v1.17.8 github.com/mr-tron/base58 v1.2.0 github.com/pkg/errors v0.9.1 - github.com/planetscale/vtprotobuf v0.6.0 github.com/urfave/cli/v2 v2.27.1 google.golang.org/protobuf v1.33.0 ) @@ -16,7 +18,9 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/go-cmp v0.5.8 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect go.uber.org/atomic v1.10.0 // indirect diff --git a/go.sum b/go.sum index 1e936f1..86945af 100644 --- a/go.sum +++ b/go.sum @@ -1,33 +1,41 @@ github.com/SaveTheRbtz/zstd-seekable-format-go v0.6.1 h1:VuaOpU/0Aklkjcq8KBisGC862WTlf8bPbW3hqBrR6gs= github.com/SaveTheRbtz/zstd-seekable-format-go v0.6.1/go.mod h1:IfUnG57D5yphwHgIIeIl74Gp5VCu74GsE7h3riM4cxs= +github.com/aperturerobotics/protobuf-go-lite v0.4.9 h1:pSVzr9FjsPzIoV1gVjUq+svjrv6Z+8S7WBwkfTFweiI= +github.com/aperturerobotics/protobuf-go-lite v0.4.9/go.mod h1:wRZn4YydbTn8Bdx4NB6ms0doF19llgim+0SNBvQ7M9c= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/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/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg= -github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/compress v1.17.8 h1:YcnTYrq7MikUT7k0Yb5eceMmALQPYBW/Xltxn0NAMnU= github.com/klauspost/compress v1.17.8/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/planetscale/vtprotobuf v0.6.0 h1:nBeETjudeJ5ZgBHUz1fVHvbqUKnYOXNhsIEabROxmNA= -github.com/planetscale/vtprotobuf v0.6.0/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= 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/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= diff --git a/hack/go.mod b/hack/go.mod index 44bcaca..a6707bb 100644 --- a/hack/go.mod +++ b/hack/go.mod @@ -4,22 +4,20 @@ go 1.22 toolchain go1.22.2 -replace google.golang.org/protobuf => github.com/aperturerobotics/protobuf-go v1.33.1-0.20240322235918-b46c9358eab6 // aperture +replace google.golang.org/protobuf => github.com/aperturerobotics/protobuf-go v1.33.1-0.20240411062030-e36f75e0a3b8 // aperture replace github.com/aperturerobotics/go-kvfile => ../ require ( github.com/aperturerobotics/go-kvfile v0.5.2 github.com/aperturerobotics/goprotowrap v0.3.1 - github.com/aperturerobotics/starpc v0.29.1 ) require ( + github.com/aperturerobotics/protobuf-go-lite v0.4.9 github.com/golangci/golangci-lint v1.57.2 - github.com/planetscale/vtprotobuf v0.6.0 github.com/psampaz/go-mod-outdated v0.9.0 golang.org/x/tools v0.20.0 - google.golang.org/protobuf v1.33.0 mvdan.cc/gofumpt v0.6.0 ) @@ -100,6 +98,7 @@ require ( github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect github.com/jjti/go-spancheck v0.5.3 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/julz/importas v0.1.0 // indirect github.com/karamaru-alpha/copyloopvar v1.0.10 // indirect github.com/kisielk/errcheck v1.7.0 // indirect @@ -123,6 +122,8 @@ require ( github.com/mgechev/revive v1.3.7 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/moricho/tparallel v0.3.1 // indirect github.com/nakabonne/nestif v0.3.1 // indirect github.com/nishanths/exhaustive v0.12.0 // indirect @@ -188,12 +189,13 @@ require ( go.uber.org/automaxprocs v1.5.3 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8 // indirect + golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/mod v0.17.0 // indirect golang.org/x/sync v0.7.0 // indirect golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect + google.golang.org/protobuf v1.33.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/hack/go.sum b/hack/go.sum index 9fd88f7..fdd173a 100644 --- a/hack/go.sum +++ b/hack/go.sum @@ -76,11 +76,10 @@ github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQ github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= github.com/aperturerobotics/goprotowrap v0.3.1 h1:nFCWZ4QNQEzpsgCN1mVWLDVTF/Jm0hWtlCMUMGm3p1Y= github.com/aperturerobotics/goprotowrap v0.3.1/go.mod h1:5tRlYsb4VF0ySzx2/My3u9PtzTWNu5o2bqYHj0TRw+U= -github.com/aperturerobotics/protobuf-go v1.33.1-0.20240322235918-b46c9358eab6 h1:ScQPbkbABsFb7e86ArWSRtoOemQGrX4BDKeHj+JAgbQ= -github.com/aperturerobotics/protobuf-go v1.33.1-0.20240322235918-b46c9358eab6/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -github.com/aperturerobotics/starpc v0.28.0 h1:axzzg+NVmnuIUQ45+XP2PY+JRiJdrYBn7MPos6gOldw= -github.com/aperturerobotics/starpc v0.28.0/go.mod h1:Ie+AE8AikN3Xs/c5jB0F6wTjxfdlAFTd6U64exVWsTA= -github.com/aperturerobotics/starpc v0.29.1/go.mod h1:2PvdaOKaV2ZnbIctoGIABnoV8L+vylqe4GM054oHPGE= +github.com/aperturerobotics/protobuf-go v1.33.1-0.20240411062030-e36f75e0a3b8 h1:Juij9Gj5jVOJjqiu3EGHWnX9nH6fkBeGGu/3U8i5qss= +github.com/aperturerobotics/protobuf-go v1.33.1-0.20240411062030-e36f75e0a3b8/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +github.com/aperturerobotics/protobuf-go-lite v0.4.9 h1:pSVzr9FjsPzIoV1gVjUq+svjrv6Z+8S7WBwkfTFweiI= +github.com/aperturerobotics/protobuf-go-lite v0.4.9/go.mod h1:wRZn4YydbTn8Bdx4NB6ms0doF19llgim+0SNBvQ7M9c= github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8gerOIVIY= github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s= @@ -306,6 +305,7 @@ github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= 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= @@ -373,9 +373,11 @@ github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrk github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= 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 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/moricho/tparallel v0.3.1 h1:fQKD4U1wRMAYNngDonW5XupoB/ZGJHdpzrWqgyg9krA= github.com/moricho/tparallel v0.3.1/go.mod h1:leENX2cUv7Sv2qDgdi0D0fCftN8fRC67Bcn8pqzeYNI= @@ -410,8 +412,6 @@ github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE 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/planetscale/vtprotobuf v0.6.0 h1:nBeETjudeJ5ZgBHUz1fVHvbqUKnYOXNhsIEabROxmNA= -github.com/planetscale/vtprotobuf v0.6.0/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polyfloyd/go-errorlint v1.4.8 h1:jiEjKDH33ouFktyez7sckv6pHWif9B7SuS8cutDXFHw= @@ -602,9 +602,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= -golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= -golang.org/x/exp v0.0.0-20240409090435-93d18d7e34b8/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI= +golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= +golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f h1:phY1HzDcf18Aq9A8KkmRtY9WvOFIxN8wgfvy6Zm1DV8= diff --git a/hack/tools.go b/hack/tools.go index 7d9ba60..326a4da 100644 --- a/hack/tools.go +++ b/hack/tools.go @@ -10,18 +10,15 @@ import ( // _ imports protowrap _ "github.com/aperturerobotics/goprotowrap/cmd/protowrap" - // _ imports protoc-gen-go - _ "google.golang.org/protobuf/cmd/protoc-gen-go" - // _ imports protoc-gen-go-vtproto - _ "github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto" + // _ imports protoc-gen-go-lite + _ "github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite" + // _ imports golangci-lint _ "github.com/golangci/golangci-lint/pkg/golinters" // _ imports golangci-lint commands _ "github.com/golangci/golangci-lint/pkg/commands" // _ imports go-mod-outdated _ "github.com/psampaz/go-mod-outdated" - // _ imports protoc-gen-starpc - _ "github.com/aperturerobotics/starpc/cmd/protoc-gen-go-starpc" // _ imports goimports _ "golang.org/x/tools/cmd/goimports" // _ imports gofumpt diff --git a/kv.pb.go b/kv.pb.go index 85caef8..7284e2f 100644 --- a/kv.pb.go +++ b/kv.pb.go @@ -1,33 +1,21 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.33.0-devel -// protoc v5.26.1 +// Code generated by protoc-gen-go-lite. DO NOT EDIT. +// protoc-gen-go-lite version: v0.4.9 // source: github.com/aperturerobotics/go-kvfile/kv.proto package kvfile import ( - reflect "reflect" - sync "sync" + io "io" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) + protobuf_go_lite "github.com/aperturerobotics/protobuf-go-lite" + json "github.com/aperturerobotics/protobuf-go-lite/json" + errors "github.com/pkg/errors" ) // IndexEntry is an entry in the index. // The index is sorted by key. type IndexEntry struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + unknownFields []byte // Key is the key of the entry. Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` // Offset is the position of the value in bytes. @@ -38,36 +26,10 @@ type IndexEntry struct { func (x *IndexEntry) Reset() { *x = IndexEntry{} - if protoimpl.UnsafeEnabled { - mi := &file_github_com_aperturerobotics_go_kvfile_kv_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *IndexEntry) String() string { - return protoimpl.X.MessageStringOf(x) } func (*IndexEntry) ProtoMessage() {} -func (x *IndexEntry) ProtoReflect() protoreflect.Message { - mi := &file_github_com_aperturerobotics_go_kvfile_kv_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use IndexEntry.ProtoReflect.Descriptor instead. -func (*IndexEntry) Descriptor() ([]byte, []int) { - return file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescGZIP(), []int{0} -} - func (x *IndexEntry) GetKey() []byte { if x != nil { return x.Key @@ -89,79 +51,303 @@ func (x *IndexEntry) GetSize() uint64 { return 0 } -var File_github_com_aperturerobotics_go_kvfile_kv_proto protoreflect.FileDescriptor +func (m *IndexEntry) CloneVT() *IndexEntry { + if m == nil { + return (*IndexEntry)(nil) + } + r := new(IndexEntry) + r.Offset = m.Offset + r.Size = m.Size + if rhs := m.Key; rhs != nil { + tmpBytes := make([]byte, len(rhs)) + copy(tmpBytes, rhs) + r.Key = tmpBytes + } + if len(m.unknownFields) > 0 { + r.unknownFields = make([]byte, len(m.unknownFields)) + copy(r.unknownFields, m.unknownFields) + } + return r +} -var file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDesc = []byte{ - 0x0a, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x65, - 0x72, 0x74, 0x75, 0x72, 0x65, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x69, 0x63, 0x73, 0x2f, 0x67, 0x6f, - 0x2d, 0x6b, 0x76, 0x66, 0x69, 0x6c, 0x65, 0x2f, 0x6b, 0x76, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x06, 0x6b, 0x76, 0x66, 0x69, 0x6c, 0x65, 0x22, 0x4a, 0x0a, 0x0a, 0x49, 0x6e, 0x64, 0x65, - 0x78, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0c, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, - 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, - 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x04, - 0x73, 0x69, 0x7a, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +func (m *IndexEntry) CloneMessageVT() protobuf_go_lite.CloneMessage { + return m.CloneVT() } -var ( - file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescOnce sync.Once - file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescData = file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDesc -) +func (this *IndexEntry) EqualVT(that *IndexEntry) bool { + if this == that { + return true + } else if this == nil || that == nil { + return false + } + if string(this.Key) != string(that.Key) { + return false + } + if this.Offset != that.Offset { + return false + } + if this.Size != that.Size { + return false + } + return string(this.unknownFields) == string(that.unknownFields) +} -func file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescGZIP() []byte { - file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescOnce.Do(func() { - file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescData) - }) - return file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDescData +func (this *IndexEntry) EqualMessageVT(thatMsg any) bool { + that, ok := thatMsg.(*IndexEntry) + if !ok { + return false + } + return this.EqualVT(that) } -var file_github_com_aperturerobotics_go_kvfile_kv_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_github_com_aperturerobotics_go_kvfile_kv_proto_goTypes = []interface{}{ - (*IndexEntry)(nil), // 0: kvfile.IndexEntry +// MarshalProtoJSON marshals the IndexEntry message to JSON. +func (x *IndexEntry) MarshalProtoJSON(s *json.MarshalState) { + if x == nil { + s.WriteNil() + return + } + s.WriteObjectStart() + var wroteField bool + if len(x.Key) > 0 || s.HasField("key") { + s.WriteMoreIf(&wroteField) + s.WriteObjectField("key") + s.WriteBytes(x.Key) + } + if x.Offset != 0 || s.HasField("offset") { + s.WriteMoreIf(&wroteField) + s.WriteObjectField("offset") + s.WriteUint64(x.Offset) + } + if x.Size != 0 || s.HasField("size") { + s.WriteMoreIf(&wroteField) + s.WriteObjectField("size") + s.WriteUint64(x.Size) + } + s.WriteObjectEnd() } -var file_github_com_aperturerobotics_go_kvfile_kv_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + +// MarshalJSON marshals the IndexEntry to JSON. +func (x *IndexEntry) MarshalJSON() ([]byte, error) { + return json.DefaultMarshalerConfig.Marshal(x) } -func init() { file_github_com_aperturerobotics_go_kvfile_kv_proto_init() } -func file_github_com_aperturerobotics_go_kvfile_kv_proto_init() { - if File_github_com_aperturerobotics_go_kvfile_kv_proto != nil { +// UnmarshalProtoJSON unmarshals the IndexEntry message from JSON. +func (x *IndexEntry) UnmarshalProtoJSON(s *json.UnmarshalState) { + if s.ReadNil() { return } - if !protoimpl.UnsafeEnabled { - file_github_com_aperturerobotics_go_kvfile_kv_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*IndexEntry); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil + s.ReadObject(func(key string) { + switch key { + default: + s.ReadAny() // ignore unknown field + case "key": + s.AddField("key") + x.Key = s.ReadBytes() + case "offset": + s.AddField("offset") + x.Offset = s.ReadUint64() + case "size": + s.AddField("size") + x.Size = s.ReadUint64() + } + }) +} + +// UnmarshalJSON unmarshals the IndexEntry from JSON. +func (x *IndexEntry) UnmarshalJSON(b []byte) error { + return json.DefaultUnmarshalerConfig.Unmarshal(b, x) +} + +func (m *IndexEntry) MarshalVT() (dAtA []byte, err error) { + if m == nil { + return nil, nil + } + size := m.SizeVT() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBufferVT(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *IndexEntry) MarshalToVT(dAtA []byte) (int, error) { + size := m.SizeVT() + return m.MarshalToSizedBufferVT(dAtA[:size]) +} + +func (m *IndexEntry) MarshalToSizedBufferVT(dAtA []byte) (int, error) { + if m == nil { + return 0, nil + } + i := len(dAtA) + _ = i + var l int + _ = l + if m.unknownFields != nil { + i -= len(m.unknownFields) + copy(dAtA[i:], m.unknownFields) + } + if m.Size != 0 { + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(m.Size)) + i-- + dAtA[i] = 0x18 + } + if m.Offset != 0 { + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(m.Offset)) + i-- + dAtA[i] = 0x10 + } + if len(m.Key) > 0 { + i -= len(m.Key) + copy(dAtA[i:], m.Key) + i = protobuf_go_lite.EncodeVarint(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *IndexEntry) SizeVT() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + protobuf_go_lite.SizeOfVarint(uint64(l)) + } + if m.Offset != 0 { + n += 1 + protobuf_go_lite.SizeOfVarint(uint64(m.Offset)) + } + if m.Size != 0 { + n += 1 + protobuf_go_lite.SizeOfVarint(uint64(m.Size)) + } + n += len(m.unknownFields) + return n +} + +func (m *IndexEntry) UnmarshalVT(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return errors.Errorf("proto: IndexEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return errors.Errorf("proto: IndexEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return errors.Errorf("proto: wrong wireType = %d for field Key", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protobuf_go_lite.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) + if m.Key == nil { + m.Key = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return errors.Errorf("proto: wrong wireType = %d for field Offset", wireType) + } + m.Offset = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Offset |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return errors.Errorf("proto: wrong wireType = %d for field Size", wireType) + } + m.Size = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protobuf_go_lite.ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Size |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := protobuf_go_lite.Skip(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protobuf_go_lite.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDesc, - NumEnums: 0, - NumMessages: 1, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_github_com_aperturerobotics_go_kvfile_kv_proto_goTypes, - DependencyIndexes: file_github_com_aperturerobotics_go_kvfile_kv_proto_depIdxs, - MessageInfos: file_github_com_aperturerobotics_go_kvfile_kv_proto_msgTypes, - }.Build() - File_github_com_aperturerobotics_go_kvfile_kv_proto = out.File - file_github_com_aperturerobotics_go_kvfile_kv_proto_rawDesc = nil - file_github_com_aperturerobotics_go_kvfile_kv_proto_goTypes = nil - file_github_com_aperturerobotics_go_kvfile_kv_proto_depIdxs = nil + return nil } diff --git a/kv_test.go b/kv_test.go index 409e6d7..d7f0276 100644 --- a/kv_test.go +++ b/kv_test.go @@ -262,5 +262,4 @@ func TestWriter(t *testing.T) { if prefixIdx != 0 || !bytes.Equal(prefixEntry.GetKey(), []byte("test-1")) { t.Fatalf("search prefix last=false failed: %v %v", prefixIdx, string(prefixEntry.GetKey())) } - } diff --git a/kv_vtproto.pb.go b/kv_vtproto.pb.go deleted file mode 100644 index 8d3743b..0000000 --- a/kv_vtproto.pb.go +++ /dev/null @@ -1,263 +0,0 @@ -// Code generated by protoc-gen-go-vtproto. DO NOT EDIT. -// protoc-gen-go-vtproto version: v0.6.0 -// source: github.com/aperturerobotics/go-kvfile/kv.proto - -package kvfile - -import ( - fmt "fmt" - io "io" - - protohelpers "github.com/planetscale/vtprotobuf/protohelpers" - proto "google.golang.org/protobuf/proto" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -func (m *IndexEntry) CloneVT() *IndexEntry { - if m == nil { - return (*IndexEntry)(nil) - } - r := new(IndexEntry) - r.Offset = m.Offset - r.Size = m.Size - if rhs := m.Key; rhs != nil { - tmpBytes := make([]byte, len(rhs)) - copy(tmpBytes, rhs) - r.Key = tmpBytes - } - if len(m.unknownFields) > 0 { - r.unknownFields = make([]byte, len(m.unknownFields)) - copy(r.unknownFields, m.unknownFields) - } - return r -} - -func (m *IndexEntry) CloneMessageVT() proto.Message { - return m.CloneVT() -} - -func (this *IndexEntry) EqualVT(that *IndexEntry) bool { - if this == that { - return true - } else if this == nil || that == nil { - return false - } - if string(this.Key) != string(that.Key) { - return false - } - if this.Offset != that.Offset { - return false - } - if this.Size != that.Size { - return false - } - return string(this.unknownFields) == string(that.unknownFields) -} - -func (this *IndexEntry) EqualMessageVT(thatMsg proto.Message) bool { - that, ok := thatMsg.(*IndexEntry) - if !ok { - return false - } - return this.EqualVT(that) -} -func (m *IndexEntry) MarshalVT() (dAtA []byte, err error) { - if m == nil { - return nil, nil - } - size := m.SizeVT() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBufferVT(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *IndexEntry) MarshalToVT(dAtA []byte) (int, error) { - size := m.SizeVT() - return m.MarshalToSizedBufferVT(dAtA[:size]) -} - -func (m *IndexEntry) MarshalToSizedBufferVT(dAtA []byte) (int, error) { - if m == nil { - return 0, nil - } - i := len(dAtA) - _ = i - var l int - _ = l - if m.unknownFields != nil { - i -= len(m.unknownFields) - copy(dAtA[i:], m.unknownFields) - } - if m.Size != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Size)) - i-- - dAtA[i] = 0x18 - } - if m.Offset != 0 { - i = protohelpers.EncodeVarint(dAtA, i, uint64(m.Offset)) - i-- - dAtA[i] = 0x10 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = protohelpers.EncodeVarint(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *IndexEntry) SizeVT() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + protohelpers.SizeOfVarint(uint64(l)) - } - if m.Offset != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.Offset)) - } - if m.Size != 0 { - n += 1 + protohelpers.SizeOfVarint(uint64(m.Size)) - } - n += len(m.unknownFields) - return n -} - -func (m *IndexEntry) UnmarshalVT(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: IndexEntry: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: IndexEntry: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return protohelpers.ErrInvalidLength - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return protohelpers.ErrInvalidLength - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Offset", wireType) - } - m.Offset = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Offset |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Size", wireType) - } - m.Size = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return protohelpers.ErrIntOverflow - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Size |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := protohelpers.Skip(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return protohelpers.ErrInvalidLength - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +