diff --git a/.gitignore b/.gitignore index a09c56d..5026778 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /.idea +/bazel-* diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..8a4fb8a --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,20 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@bazel_gazelle//:def.bzl", "gazelle") + +# The gazelle:prefix allows Bazel to determine which packages are project-local +# gazelle:prefix github.com/fgm/izidic +gazelle(name = "gazelle") + +go_library( + name = "izidic", + srcs = ["izidic.go"], + importpath = "github.com/fgm/izidic", + visibility = ["//visibility:public"], +) + +go_test( + name = "izidic_test", + srcs = ["izidic_test.go"], + embed = [":izidic"], + deps = ["@com_github_google_go_cmp//cmp:go_default_library"], +) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..6bae418 --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,40 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "io_bazel_rules_go", + sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", + "https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip", + ], +) + +http_archive( + name = "bazel_gazelle", + sha256 = "efbbba6ac1a4fd342d5122cbdfdb82aeb2cf2862e35022c752eaddffada7c3f3", + urls = [ + "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.27.0/bazel-gazelle-v0.27.0.tar.gz", + "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.27.0/bazel-gazelle-v0.27.0.tar.gz", + ], +) + +load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") +load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies") + +############################################################ +# Define your own dependencies here using go_repository. +# Else, dependencies declared by rules_go/gazelle will be used. +# The first declaration of an external repository "wins". +############################################################ + +load("//:deps.bzl", "go_dependencies") + +# gazelle:repository_macro deps.bzl%go_dependencies +go_dependencies() + +go_rules_dependencies() + +go_register_toolchains(version = "1.19.2") + +gazelle_dependencies() +# gazelle_dependencies(go_repository_default_config = "@//:WORKSPACE") diff --git a/deps.bzl b/deps.bzl new file mode 100644 index 0000000..86ab617 --- /dev/null +++ b/deps.bzl @@ -0,0 +1,9 @@ +load("@bazel_gazelle//:deps.bzl", "go_repository") + +def go_dependencies(): + go_repository( + name = "com_github_google_go_cmp", + importpath = "github.com/google/go-cmp", + sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=", + version = "v0.5.9", + )