From 1404a292d8805f0a54aa1410db0e5b08c5c96319 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Fri, 29 Sep 2023 15:41:35 +0100 Subject: [PATCH] Move internal/examples to examples folder --- Makefile | 7 +++-- README.md | 2 +- buf.work.yaml | 2 +- .../connect+grpc/README.md | 0 .../connect+grpc/cmd/client/main.go | 0 .../connect+grpc/cmd/server/main.go | 0 .../examples => examples}/connect+grpc/go.mod | 4 +-- .../examples => examples}/connect+grpc/go.sum | 0 .../fileserver/README.md | 0 .../examples => examples}/fileserver/main.go | 0 .../examples => examples}/pets/README.md | 0 .../examples => examples}/pets/buf.gen.yaml | 2 +- .../pets/cmd/pets-be/main.go | 4 +-- .../pets/cmd/pets-fe/main.go | 4 +-- {internal/examples => examples}/pets/go.mod | 4 +-- {internal/examples => examples}/pets/go.sum | 0 .../pets/internal/trace.go | 0 .../internal => examples/pets}/proto/buf.lock | 0 .../internal => examples/pets}/proto/buf.yaml | 0 .../proto/io/swagger/petstore/v2/pets.proto | 0 go.work | 4 +-- .../gen/io/swagger/petstore/v2/pets.pb.go | 26 +++++++++---------- .../v2/petstorev2connect/pets.connect.go | 2 +- internal/proto/buf.lock | 4 +-- 24 files changed, 31 insertions(+), 34 deletions(-) rename {internal/examples => examples}/connect+grpc/README.md (100%) rename {internal/examples => examples}/connect+grpc/cmd/client/main.go (100%) rename {internal/examples => examples}/connect+grpc/cmd/server/main.go (100%) rename {internal/examples => examples}/connect+grpc/go.mod (89%) rename {internal/examples => examples}/connect+grpc/go.sum (100%) rename {internal/examples => examples}/fileserver/README.md (100%) rename {internal/examples => examples}/fileserver/main.go (100%) rename {internal/examples => examples}/pets/README.md (100%) rename {internal/examples => examples}/pets/buf.gen.yaml (81%) rename {internal/examples => examples}/pets/cmd/pets-be/main.go (94%) rename {internal/examples => examples}/pets/cmd/pets-fe/main.go (96%) rename {internal/examples => examples}/pets/go.mod (85%) rename {internal/examples => examples}/pets/go.sum (100%) rename {internal/examples => examples}/pets/internal/trace.go (100%) rename {internal/examples/pets/internal => examples/pets}/proto/buf.lock (100%) rename {internal/examples/pets/internal => examples/pets}/proto/buf.yaml (100%) rename {internal/examples/pets/internal => examples/pets}/proto/io/swagger/petstore/v2/pets.proto (100%) rename internal/{examples/pets/internal => }/gen/io/swagger/petstore/v2/pets.pb.go (96%) rename internal/{examples/pets/internal => }/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go (99%) diff --git a/Makefile b/Makefile index d114b6f..93b470d 100644 --- a/Makefile +++ b/Makefile @@ -29,8 +29,8 @@ clean: ## Delete intermediate build artifacts .PHONY: test test: build ## Run unit tests $(GO) test -vet=off -race -cover ./... - cd internal/examples/pets && $(GO) test -vet=off -race -cover ./... - cd internal/examples/connect+grpc && $(GO) test -vet=off -race -cover ./... + cd examples/pets && $(GO) test -vet=off -race -cover ./... + cd examples/connect+grpc && $(GO) test -vet=off -race -cover ./... .PHONY: build build: generate ## Build all packages @@ -38,8 +38,7 @@ build: generate ## Build all packages .PHONY: generate generate: $(BIN)/buf $(BIN)/license-header ## Regenerate code and licenses - $(BIN)/buf generate internal/proto - cd internal/examples/pets && ../../../$(BIN)/buf generate internal/proto + $(BIN)/buf generate @# We want to operate on a list of modified and new files, excluding @# deleted and ignored files. git-ls-files can't do this alone. comm -23 takes @# two files and prints the union, dropping lines common to both (-3) and diff --git a/README.md b/README.md index 02d1b0f..2340cce 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ between gRPC, gRPC-Web, Connect, or REST, Vanguard has got you covered. With sup Google's [HTTP transcoding options](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44), it can effortlessly translate protocols using strongly typed Protobuf definitions. -[See an example in action!](internal/examples/fileserver/main.go) +[See an example in action!](examples/fileserver/main.go) ## Why Vanguard? diff --git a/buf.work.yaml b/buf.work.yaml index dabba77..5b8224b 100644 --- a/buf.work.yaml +++ b/buf.work.yaml @@ -1,4 +1,4 @@ version: v1 directories: - internal/proto - - internal/examples/pets/internal/proto + - examples/pets/proto diff --git a/internal/examples/connect+grpc/README.md b/examples/connect+grpc/README.md similarity index 100% rename from internal/examples/connect+grpc/README.md rename to examples/connect+grpc/README.md diff --git a/internal/examples/connect+grpc/cmd/client/main.go b/examples/connect+grpc/cmd/client/main.go similarity index 100% rename from internal/examples/connect+grpc/cmd/client/main.go rename to examples/connect+grpc/cmd/client/main.go diff --git a/internal/examples/connect+grpc/cmd/server/main.go b/examples/connect+grpc/cmd/server/main.go similarity index 100% rename from internal/examples/connect+grpc/cmd/server/main.go rename to examples/connect+grpc/cmd/server/main.go diff --git a/internal/examples/connect+grpc/go.mod b/examples/connect+grpc/go.mod similarity index 89% rename from internal/examples/connect+grpc/go.mod rename to examples/connect+grpc/go.mod index 375c6b2..dc73b30 100644 --- a/internal/examples/connect+grpc/go.mod +++ b/examples/connect+grpc/go.mod @@ -1,9 +1,9 @@ -module connectrpc.com/vanguard/internal/examples/connect+grpc +module connectrpc.com/vanguard/examples/connect+grpc go 1.20 // once the repo is public, we can remove this -replace connectrpc.com/vanguard => ../../../ +replace connectrpc.com/vanguard => ../../ require ( buf.build/gen/go/connectrpc/eliza/connectrpc/go v1.11.1-20230822171018-8b8b971d6fde.1 diff --git a/internal/examples/connect+grpc/go.sum b/examples/connect+grpc/go.sum similarity index 100% rename from internal/examples/connect+grpc/go.sum rename to examples/connect+grpc/go.sum diff --git a/internal/examples/fileserver/README.md b/examples/fileserver/README.md similarity index 100% rename from internal/examples/fileserver/README.md rename to examples/fileserver/README.md diff --git a/internal/examples/fileserver/main.go b/examples/fileserver/main.go similarity index 100% rename from internal/examples/fileserver/main.go rename to examples/fileserver/main.go diff --git a/internal/examples/pets/README.md b/examples/pets/README.md similarity index 100% rename from internal/examples/pets/README.md rename to examples/pets/README.md diff --git a/internal/examples/pets/buf.gen.yaml b/examples/pets/buf.gen.yaml similarity index 81% rename from internal/examples/pets/buf.gen.yaml rename to examples/pets/buf.gen.yaml index c2a7502..9e2c254 100644 --- a/internal/examples/pets/buf.gen.yaml +++ b/examples/pets/buf.gen.yaml @@ -2,7 +2,7 @@ version: v1 managed: enabled: true go_package_prefix: - default: connectrpc.com/vanguard/internal/examples/pets/internal/gen + default: connectrpc.com/vanguard/internal/gen except: - buf.build/googleapis/googleapis plugins: diff --git a/internal/examples/pets/cmd/pets-be/main.go b/examples/pets/cmd/pets-be/main.go similarity index 94% rename from internal/examples/pets/cmd/pets-be/main.go rename to examples/pets/cmd/pets-be/main.go index 71da997..53d6b2c 100644 --- a/internal/examples/pets/cmd/pets-be/main.go +++ b/examples/pets/cmd/pets-be/main.go @@ -30,8 +30,8 @@ import ( "connectrpc.com/grpcreflect" "connectrpc.com/vanguard" - "connectrpc.com/vanguard/internal/examples/pets/internal" - "connectrpc.com/vanguard/internal/examples/pets/internal/gen/io/swagger/petstore/v2/petstorev2connect" + "connectrpc.com/vanguard/examples/pets/internal" + "connectrpc.com/vanguard/internal/gen/io/swagger/petstore/v2/petstorev2connect" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" "golang.org/x/sync/errgroup" diff --git a/internal/examples/pets/cmd/pets-fe/main.go b/examples/pets/cmd/pets-fe/main.go similarity index 96% rename from internal/examples/pets/cmd/pets-fe/main.go rename to examples/pets/cmd/pets-fe/main.go index 547bee4..41eb5b9 100644 --- a/internal/examples/pets/cmd/pets-fe/main.go +++ b/examples/pets/cmd/pets-fe/main.go @@ -32,8 +32,8 @@ import ( "connectrpc.com/grpcreflect" "connectrpc.com/vanguard" - "connectrpc.com/vanguard/internal/examples/pets/internal" - "connectrpc.com/vanguard/internal/examples/pets/internal/gen/io/swagger/petstore/v2/petstorev2connect" + "connectrpc.com/vanguard/examples/pets/internal" + "connectrpc.com/vanguard/internal/gen/io/swagger/petstore/v2/petstorev2connect" "golang.org/x/net/http2" "golang.org/x/net/http2/h2c" "golang.org/x/sync/errgroup" diff --git a/internal/examples/pets/go.mod b/examples/pets/go.mod similarity index 85% rename from internal/examples/pets/go.mod rename to examples/pets/go.mod index f29c7bc..3e10cb7 100644 --- a/internal/examples/pets/go.mod +++ b/examples/pets/go.mod @@ -1,9 +1,9 @@ -module connectrpc.com/vanguard/internal/examples/pets +module connectrpc.com/vanguard/examples/pets go 1.20 // once the repo is public, we can remove this -replace connectrpc.com/vanguard => ../../../ +replace connectrpc.com/vanguard => ../../ require ( connectrpc.com/connect v1.11.0 diff --git a/internal/examples/pets/go.sum b/examples/pets/go.sum similarity index 100% rename from internal/examples/pets/go.sum rename to examples/pets/go.sum diff --git a/internal/examples/pets/internal/trace.go b/examples/pets/internal/trace.go similarity index 100% rename from internal/examples/pets/internal/trace.go rename to examples/pets/internal/trace.go diff --git a/internal/examples/pets/internal/proto/buf.lock b/examples/pets/proto/buf.lock similarity index 100% rename from internal/examples/pets/internal/proto/buf.lock rename to examples/pets/proto/buf.lock diff --git a/internal/examples/pets/internal/proto/buf.yaml b/examples/pets/proto/buf.yaml similarity index 100% rename from internal/examples/pets/internal/proto/buf.yaml rename to examples/pets/proto/buf.yaml diff --git a/internal/examples/pets/internal/proto/io/swagger/petstore/v2/pets.proto b/examples/pets/proto/io/swagger/petstore/v2/pets.proto similarity index 100% rename from internal/examples/pets/internal/proto/io/swagger/petstore/v2/pets.proto rename to examples/pets/proto/io/swagger/petstore/v2/pets.proto diff --git a/go.work b/go.work index 2982e1d..44db64e 100644 --- a/go.work +++ b/go.work @@ -2,6 +2,6 @@ go 1.20 use ( . - ./internal/examples/connect+grpc - ./internal/examples/pets + ./examples/connect+grpc + ./examples/pets ) diff --git a/internal/examples/pets/internal/gen/io/swagger/petstore/v2/pets.pb.go b/internal/gen/io/swagger/petstore/v2/pets.pb.go similarity index 96% rename from internal/examples/pets/internal/gen/io/swagger/petstore/v2/pets.pb.go rename to internal/gen/io/swagger/petstore/v2/pets.pb.go index 45f71b5..0a46efd 100644 --- a/internal/examples/pets/internal/gen/io/swagger/petstore/v2/pets.pb.go +++ b/internal/gen/io/swagger/petstore/v2/pets.pb.go @@ -838,24 +838,22 @@ var file_io_swagger_petstore_v2_pets_proto_rawDesc = []byte{ 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x65, 0x74, 0x73, 0x22, 0x22, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x19, 0x62, 0x04, 0x70, 0x65, 0x74, 0x73, 0x12, 0x11, 0x2f, 0x70, 0x65, 0x74, 0x2f, 0x66, 0x69, 0x6e, 0x64, 0x42, 0x79, 0x53, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x90, 0x02, 0x01, 0x42, 0x81, 0x02, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x69, + 0x74, 0x75, 0x73, 0x90, 0x02, 0x01, 0x42, 0xea, 0x01, 0x0a, 0x1a, 0x63, 0x6f, 0x6d, 0x2e, 0x69, 0x6f, 0x2e, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x76, 0x32, 0x42, 0x09, 0x50, 0x65, 0x74, 0x73, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x5d, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x63, + 0x50, 0x01, 0x5a, 0x46, 0x63, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x72, 0x70, 0x63, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x76, 0x61, 0x6e, 0x67, 0x75, 0x61, 0x72, 0x64, 0x2f, 0x69, 0x6e, 0x74, 0x65, - 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x70, 0x65, - 0x74, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, - 0x69, 0x6f, 0x2f, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2f, 0x70, 0x65, 0x74, 0x73, 0x74, - 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x32, 0x3b, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x76, - 0x32, 0xa2, 0x02, 0x03, 0x49, 0x53, 0x50, 0xaa, 0x02, 0x16, 0x49, 0x6f, 0x2e, 0x53, 0x77, 0x61, - 0x67, 0x67, 0x65, 0x72, 0x2e, 0x50, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x32, - 0xca, 0x02, 0x16, 0x49, 0x6f, 0x5c, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x5c, 0x50, 0x65, - 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x32, 0xe2, 0x02, 0x22, 0x49, 0x6f, 0x5c, 0x53, + 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x69, 0x6f, 0x2f, 0x73, 0x77, 0x61, 0x67, + 0x67, 0x65, 0x72, 0x2f, 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x76, 0x32, 0x3b, + 0x70, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x76, 0x32, 0xa2, 0x02, 0x03, 0x49, 0x53, 0x50, + 0xaa, 0x02, 0x16, 0x49, 0x6f, 0x2e, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x50, 0x65, + 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x56, 0x32, 0xca, 0x02, 0x16, 0x49, 0x6f, 0x5c, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x5c, 0x50, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5c, - 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, - 0x19, 0x49, 0x6f, 0x3a, 0x3a, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x3a, 0x3a, 0x50, 0x65, - 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3a, 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x56, 0x32, 0xe2, 0x02, 0x22, 0x49, 0x6f, 0x5c, 0x53, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x5c, + 0x50, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x5c, 0x56, 0x32, 0x5c, 0x47, 0x50, 0x42, 0x4d, + 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x19, 0x49, 0x6f, 0x3a, 0x3a, 0x53, 0x77, + 0x61, 0x67, 0x67, 0x65, 0x72, 0x3a, 0x3a, 0x50, 0x65, 0x74, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x3a, + 0x3a, 0x56, 0x32, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/internal/examples/pets/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go b/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go similarity index 99% rename from internal/examples/pets/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go rename to internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go index 8c97a8c..00b5579 100644 --- a/internal/examples/pets/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go +++ b/internal/gen/io/swagger/petstore/v2/petstorev2connect/pets.connect.go @@ -20,7 +20,7 @@ package petstorev2connect import ( connect "connectrpc.com/connect" - v2 "connectrpc.com/vanguard/internal/examples/pets/internal/gen/io/swagger/petstore/v2" + v2 "connectrpc.com/vanguard/internal/gen/io/swagger/petstore/v2" context "context" errors "errors" emptypb "google.golang.org/protobuf/types/known/emptypb" diff --git a/internal/proto/buf.lock b/internal/proto/buf.lock index 3435191..6c4355d 100644 --- a/internal/proto/buf.lock +++ b/internal/proto/buf.lock @@ -4,5 +4,5 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 711e289f6a384c4caeebaff7c6931ade - digest: shake256:e08fb55dad7469f69df00304eed31427d2d1576e9aab31e6bf86642688e04caaf0372f15fe6974cf79432779a635b3ea401ca69c943976dc42749524e4c25d94 + commit: 28151c0d0a1641bf938a7672c500e01d + digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de