From 933a47b9663dadb62988b70a4ae99c5ebb0b026b Mon Sep 17 00:00:00 2001 From: William Cheng Date: Mon, 14 Aug 2023 15:29:30 +0800 Subject: [PATCH] Revert "add golang full example (#48)" This reverts commit 2f9e06659d12d16af51a2067815fb913e56ff709. --- examples/golang/BUILD | 14 -- examples/golang/WORKSPACE | 59 ------- examples/golang/go.mod | 33 ---- examples/golang/src/BUILD | 38 ----- examples/golang/src/main.go | 12 -- examples/golang/src/petstore.yml | 113 -------------- examples/golang/workspace.bzl | 255 ------------------------------- 7 files changed, 524 deletions(-) delete mode 100644 examples/golang/BUILD delete mode 100644 examples/golang/WORKSPACE delete mode 100644 examples/golang/go.mod delete mode 100644 examples/golang/src/BUILD delete mode 100644 examples/golang/src/main.go delete mode 100644 examples/golang/src/petstore.yml delete mode 100644 examples/golang/workspace.bzl diff --git a/examples/golang/BUILD b/examples/golang/BUILD deleted file mode 100644 index f29234c..0000000 --- a/examples/golang/BUILD +++ /dev/null @@ -1,14 +0,0 @@ -load("@bazel_gazelle//:def.bzl", "gazelle") - -# gazelle:prefix examples/golang -gazelle(name = "gazelle") - -gazelle( - name = "gazelle-update-repos", - args = [ - "-from_file=go.mod", - "-to_macro=workspace.bzl%go_dependencies", - "-prune", - ], - command = "update-repos", -) diff --git a/examples/golang/WORKSPACE b/examples/golang/WORKSPACE deleted file mode 100644 index 40191a6..0000000 --- a/examples/golang/WORKSPACE +++ /dev/null @@ -1,59 +0,0 @@ -local_repository( - name = "openapi_tools_generator_bazel", - path = "../..", -) - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -###################### -# Golang -###################### -# https://github.com/bazelbuild/rules_go/releases -http_archive( - name = "io_bazel_rules_go", - sha256 = "6dc2da7ab4cf5d7bfc7c949776b1b7c733f05e56edc4bcd9022bb249d2e2a996", - urls = ["https://github.com/bazelbuild/rules_go/releases/download/v0.39.1/rules_go-v0.39.0.zip"], -) - -load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") - -go_rules_dependencies() - -go_register_toolchains(version = "1.20.3") - -# Gazelle: https://github.com/bazelbuild/bazel-gazelle/releases -http_archive( - name = "bazel_gazelle", - sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405", - urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz"], -) - -load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") -load("//:workspace.bzl", "go_dependencies") - -# gazelle:repository_macro workspace.bzl%go_dependencies -go_dependencies() - -gazelle_dependencies() - -###################### -# Aspect's Bazel -###################### -# https://github.com/aspect-build/bazel-lib/releases -http_archive( - name = "aspect_bazel_lib", - sha256 = "5f3443b1d98a462a8b7330f4742483afc8b2d17c8555dd97ce4146f43e961718", - strip_prefix = "bazel-lib-1.31.1", - url = "https://github.com/aspect-build/bazel-lib/releases/download/v1.31.1/bazel-lib-v1.31.1.tar.gz", -) - -load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies") - -aspect_bazel_lib_dependencies() - -####################### -# OpenAPI Generator -####################### -load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_tools_generator_bazel_repositories") - -openapi_tools_generator_bazel_repositories() diff --git a/examples/golang/go.mod b/examples/golang/go.mod deleted file mode 100644 index 6daa008..0000000 --- a/examples/golang/go.mod +++ /dev/null @@ -1,33 +0,0 @@ -module examples/golang - -go 1.20 - -require github.com/gin-gonic/gin v1.9.0 - -require ( - github.com/bytedance/sonic v1.8.0 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect - github.com/gin-gonic/gin v1.9.0 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.11.2 // indirect - github.com/goccy/go-json v0.10.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/cpuid/v2 v2.0.9 // indirect - github.com/leodido/go-urn v1.2.1 // indirect - github.com/mattn/go-isatty v0.0.17 // indirect - github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/pelletier/go-toml/v2 v2.0.6 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect - github.com/ugorji/go/codec v1.2.9 // indirect - golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect - golang.org/x/crypto v0.5.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect - google.golang.org/protobuf v1.28.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/examples/golang/src/BUILD b/examples/golang/src/BUILD deleted file mode 100644 index ee42ce1..0000000 --- a/examples/golang/src/BUILD +++ /dev/null @@ -1,38 +0,0 @@ -load("@openapi_tools_generator_bazel//:defs.bzl", "openapi_generator") -load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory") -load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") - -openapi_generator( - name = "petstore", - generator = "go-gin-server", - spec = "petstore.yml", -) - -copy_to_directory( - name = "petstore.go", - srcs = [":petstore"], - exclude_srcs_patterns = ["**/main.go"], - include_srcs_patterns = ["**/*.go"], -) - -go_library( - name = "petstore_lib", - srcs = [":petstore.go"], - importpath = "petstore", - visibility = ["//visibility:private"], - deps = ["@com_github_gin_gonic_gin//:gin"], -) - -go_library( - name = "server_lib", - srcs = ["main.go"], - importpath = "examples/golang", - visibility = ["//visibility:private"], - deps = [":petstore_lib"], -) - -go_binary( - name = "server", - embed = [":server_lib"], - visibility = ["//visibility:public"], -) diff --git a/examples/golang/src/main.go b/examples/golang/src/main.go deleted file mode 100644 index 3dc0150..0000000 --- a/examples/golang/src/main.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "log" - sw "petstore" -) - -func main() { - log.Printf("Server started") - router := sw.NewRouter() - log.Fatal(router.Run(":8080")) -} diff --git a/examples/golang/src/petstore.yml b/examples/golang/src/petstore.yml deleted file mode 100644 index 5910232..0000000 --- a/examples/golang/src/petstore.yml +++ /dev/null @@ -1,113 +0,0 @@ -openapi: "3.0.0" -info: - version: 1.0.0 - title: Swagger Petstore - license: - name: MIT -servers: - - url: http://petstore.swagger.io/v1 -paths: - /pets: - get: - summary: List all pets - operationId: listPets - tags: - - pets - parameters: - - name: limit - in: query - description: How many items to return at one time (max 100) - required: false - schema: - type: integer - maximum: 100 - format: int32 - responses: - '200': - description: A paged array of pets - headers: - x-next: - description: A link to the next page of responses - schema: - type: string - content: - application/json: - schema: - $ref: "#/components/schemas/Pets" - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Create a pet - operationId: createPets - tags: - - pets - responses: - '201': - description: Null response - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /pets/{petId}: - get: - summary: Info for a specific pet - operationId: showPetById - tags: - - pets - parameters: - - name: petId - in: path - required: true - description: The id of the pet to retrieve - schema: - type: string - responses: - '200': - description: Expected response to a valid request - content: - application/json: - schema: - $ref: "#/components/schemas/Pet" - default: - description: unexpected error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" -components: - schemas: - Pet: - type: object - required: - - id - - name - properties: - id: - type: integer - format: int64 - name: - type: string - tag: - type: string - Pets: - type: array - maxItems: 100 - items: - $ref: "#/components/schemas/Pet" - Error: - type: object - required: - - code - - message - properties: - code: - type: integer - format: int32 - message: - type: string diff --git a/examples/golang/workspace.bzl b/examples/golang/workspace.bzl deleted file mode 100644 index 17aa7f7..0000000 --- a/examples/golang/workspace.bzl +++ /dev/null @@ -1,255 +0,0 @@ -load("@bazel_gazelle//:deps.bzl", "go_repository") - -def go_dependencies(): - go_repository( - name = "com_github_bytedance_sonic", - importpath = "github.com/bytedance/sonic", - sum = "h1:ea0Xadu+sHlu7x5O3gKhRpQ1IKiMrSiHttPF0ybECuA=", - version = "v1.8.0", - ) - go_repository( - name = "com_github_chenzhuoyu_base64x", - importpath = "github.com/chenzhuoyu/base64x", - sum = "h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=", - version = "v0.0.0-20221115062448-fe3a3abad311", - ) - go_repository( - name = "com_github_davecgh_go_spew", - importpath = "github.com/davecgh/go-spew", - sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", - version = "v1.1.1", - ) - go_repository( - name = "com_github_gin_contrib_sse", - importpath = "github.com/gin-contrib/sse", - sum = "h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=", - version = "v0.1.0", - ) - go_repository( - name = "com_github_gin_gonic_gin", - importpath = "github.com/gin-gonic/gin", - sum = "h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8=", - version = "v1.9.0", - ) - go_repository( - name = "com_github_go_playground_assert_v2", - importpath = "github.com/go-playground/assert/v2", - sum = "h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=", - version = "v2.2.0", - ) - go_repository( - name = "com_github_go_playground_locales", - importpath = "github.com/go-playground/locales", - sum = "h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=", - version = "v0.14.1", - ) - go_repository( - name = "com_github_go_playground_universal_translator", - importpath = "github.com/go-playground/universal-translator", - sum = "h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=", - version = "v0.18.1", - ) - go_repository( - name = "com_github_go_playground_validator_v10", - importpath = "github.com/go-playground/validator/v10", - sum = "h1:q3SHpufmypg+erIExEKUmsgmhDTyhcJ38oeKGACXohU=", - version = "v10.11.2", - ) - go_repository( - name = "com_github_goccy_go_json", - importpath = "github.com/goccy/go-json", - sum = "h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=", - version = "v0.10.0", - ) - go_repository( - name = "com_github_golang_protobuf", - importpath = "github.com/golang/protobuf", - sum = "h1:LUVKkCeviFUMKqHa4tXIIij/lbhnMbP7Fn5wKdKkRh4=", - version = "v1.5.0", - ) - go_repository( - name = "com_github_google_go_cmp", - importpath = "github.com/google/go-cmp", - sum = "h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=", - version = "v0.5.5", - ) - go_repository( - name = "com_github_google_gofuzz", - importpath = "github.com/google/gofuzz", - sum = "h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=", - version = "v1.0.0", - ) - go_repository( - name = "com_github_json_iterator_go", - importpath = "github.com/json-iterator/go", - sum = "h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=", - version = "v1.1.12", - ) - go_repository( - name = "com_github_klauspost_cpuid_v2", - importpath = "github.com/klauspost/cpuid/v2", - sum = "h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=", - version = "v2.0.9", - ) - go_repository( - name = "com_github_kr_pretty", - importpath = "github.com/kr/pretty", - sum = "h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=", - version = "v0.3.0", - ) - go_repository( - name = "com_github_kr_text", - importpath = "github.com/kr/text", - sum = "h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=", - version = "v0.2.0", - ) - go_repository( - name = "com_github_leodido_go_urn", - importpath = "github.com/leodido/go-urn", - sum = "h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=", - version = "v1.2.1", - ) - go_repository( - name = "com_github_mattn_go_isatty", - importpath = "github.com/mattn/go-isatty", - sum = "h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=", - version = "v0.0.17", - ) - go_repository( - name = "com_github_modern_go_concurrent", - importpath = "github.com/modern-go/concurrent", - sum = "h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=", - version = "v0.0.0-20180228061459-e0a39a4cb421", - ) - go_repository( - name = "com_github_modern_go_reflect2", - importpath = "github.com/modern-go/reflect2", - sum = "h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=", - version = "v1.0.2", - ) - go_repository( - name = "com_github_pelletier_go_toml_v2", - importpath = "github.com/pelletier/go-toml/v2", - sum = "h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=", - version = "v2.0.6", - ) - go_repository( - name = "com_github_pmezard_go_difflib", - importpath = "github.com/pmezard/go-difflib", - sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", - version = "v1.0.0", - ) - go_repository( - name = "com_github_rogpeppe_go_internal", - importpath = "github.com/rogpeppe/go-internal", - sum = "h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=", - version = "v1.8.0", - ) - go_repository( - name = "com_github_stretchr_objx", - importpath = "github.com/stretchr/objx", - sum = "h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=", - version = "v0.5.0", - ) - go_repository( - name = "com_github_stretchr_testify", - importpath = "github.com/stretchr/testify", - sum = "h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=", - version = "v1.8.1", - ) - go_repository( - name = "com_github_twitchyliquid64_golang_asm", - importpath = "github.com/twitchyliquid64/golang-asm", - sum = "h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=", - version = "v0.15.1", - ) - go_repository( - name = "com_github_ugorji_go_codec", - importpath = "github.com/ugorji/go/codec", - sum = "h1:rmenucSohSTiyL09Y+l2OCk+FrMxGMzho2+tjr5ticU=", - version = "v1.2.9", - ) - go_repository( - name = "in_gopkg_check_v1", - importpath = "gopkg.in/check.v1", - sum = "h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=", - version = "v1.0.0-20201130134442-10cb98267c6c", - ) - go_repository( - name = "in_gopkg_yaml_v2", - importpath = "gopkg.in/yaml.v2", - sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=", - version = "v2.4.0", - ) - go_repository( - name = "in_gopkg_yaml_v3", - importpath = "gopkg.in/yaml.v3", - sum = "h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=", - version = "v3.0.1", - ) - go_repository( - name = "io_rsc_pdf", - importpath = "rsc.io/pdf", - sum = "h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4=", - version = "v0.1.1", - ) - go_repository( - name = "org_golang_google_protobuf", - importpath = "google.golang.org/protobuf", - sum = "h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=", - version = "v1.28.1", - ) - go_repository( - name = "org_golang_x_arch", - importpath = "golang.org/x/arch", - sum = "h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=", - version = "v0.0.0-20210923205945-b76863e36670", - ) - go_repository( - name = "org_golang_x_crypto", - importpath = "golang.org/x/crypto", - sum = "h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=", - version = "v0.5.0", - ) - go_repository( - name = "org_golang_x_mod", - importpath = "golang.org/x/mod", - sum = "h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=", - version = "v0.6.0-dev.0.20220419223038-86c51ed26bb4", - ) - go_repository( - name = "org_golang_x_net", - importpath = "golang.org/x/net", - sum = "h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=", - version = "v0.7.0", - ) - go_repository( - name = "org_golang_x_sys", - importpath = "golang.org/x/sys", - sum = "h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=", - version = "v0.5.0", - ) - go_repository( - name = "org_golang_x_term", - importpath = "golang.org/x/term", - sum = "h1:n2a8QNdAb0sZNpU9R1ALUXBbY+w51fCQDN+7EdxNBsY=", - version = "v0.5.0", - ) - go_repository( - name = "org_golang_x_text", - importpath = "golang.org/x/text", - sum = "h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=", - version = "v0.7.0", - ) - go_repository( - name = "org_golang_x_tools", - importpath = "golang.org/x/tools", - sum = "h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=", - version = "v0.1.12", - ) - go_repository( - name = "org_golang_x_xerrors", - importpath = "golang.org/x/xerrors", - sum = "h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=", - version = "v0.0.0-20191204190536-9bdfabe68543", - )