This commit is contained in:
Christian Nieves
2023-07-12 22:28:24 -05:00
parent 4060a5c274
commit ae55110082
6 changed files with 106 additions and 8 deletions

5
BUILD
View File

@ -18,3 +18,8 @@ gazelle(
],
command = "update-repos",
)
alias(
name = "beornextract",
actual = "//cmd/beornextract:beornextract",
)

View File

@ -1,20 +1,25 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
package(
default_visibility = ["//visibility:public"],
)
alias(
name = "beornextract",
actual = "//beornextract/",
)
go_library(
name = "beornextract_lib",
srcs = ["main.go"],
data = [
"//cmd/beornextract/data:Bot.Cards.json",
"//cmd/beornextract/data:Export.Cards.json",
],
importpath = "github.com/squk/lotr/cmd/beornextract",
deps = [
"//cmd/beornextract/types",
"@com_github_davecgh_go_spew//spew",
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
],
)
go_binary(
name = "beornextract",
embed = [":beornextract_lib"],
)

View File

@ -4,17 +4,36 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"path/filepath"
"github.com/bazelbuild/rules_go/go/tools/bazel"
"github.com/davecgh/go-spew/spew"
"github.com/squk/lotr/cmd/beornextract/types"
)
func main() {
fmt.Println("LOTR CARD PARSE")
f, err := bazel.Runfile(".")
if err != nil {
panic(err)
}
err = filepath.Walk(f,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
fmt.Println(path, info.Size())
return nil
})
if err != nil {
log.Println(err)
}
// Open our jsonFile
jsonFile, err := os.Open("./data/Bot.Cards.json")
// jsonFile, err := os.Open("cmd/beornextract/data/Bot.Cards.json")
jsonFile, err := bazel.Runfile("cmd/beornextract/data/Bot.Cards.json")
// if we os.Open returns an error then handle it
if err != nil {
fmt.Println(err)

View File

@ -1,6 +1,14 @@
load("@bazel_gazelle//:deps.bzl", "go_repository")
def go_dependencies():
go_repository(
name = "com_github_bazelbuild_rules_go",
build_file_proto_mode = "disable_global",
importpath = "github.com/bazelbuild/rules_go",
sum = "h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=",
version = "v0.41.0",
)
go_repository(
name = "com_github_davecgh_go_spew",
build_file_proto_mode = "disable_global",
@ -8,6 +16,20 @@ def go_dependencies():
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
version = "v1.1.1",
)
go_repository(
name = "com_github_golang_mock",
build_file_proto_mode = "disable_global",
importpath = "github.com/golang/mock",
sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=",
version = "v1.6.0",
)
go_repository(
name = "com_github_golang_protobuf",
build_file_proto_mode = "disable_global",
importpath = "github.com/golang/protobuf",
sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=",
version = "v1.5.2",
)
go_repository(
name = "com_github_mattn_go_sqlite3",
@ -16,3 +38,45 @@ def go_dependencies():
sum = "h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=",
version = "v1.14.17",
)
go_repository(
name = "org_golang_google_genproto",
build_file_proto_mode = "disable_global",
importpath = "google.golang.org/genproto",
sum = "h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY=",
version = "v0.0.0-20200526211855-cb27e3aa2013",
)
go_repository(
name = "org_golang_google_grpc",
build_file_proto_mode = "disable_global",
importpath = "google.golang.org/grpc",
sum = "h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU=",
version = "v1.50.0",
)
go_repository(
name = "org_golang_google_protobuf",
build_file_proto_mode = "disable_global",
importpath = "google.golang.org/protobuf",
sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=",
version = "v1.28.0",
)
go_repository(
name = "org_golang_x_net",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/net",
sum = "h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=",
version = "v0.0.0-20210405180319-a5a99cb37ef4",
)
go_repository(
name = "org_golang_x_sys",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/sys",
sum = "h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=",
version = "v0.0.0-20210510120138-977fb7262007",
)
go_repository(
name = "org_golang_x_text",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/text",
sum = "h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=",
version = "v0.3.3",
)

5
go.mod
View File

@ -4,4 +4,7 @@ go 1.19
require github.com/davecgh/go-spew v1.1.1
require github.com/mattn/go-sqlite3 v1.14.17 // indirect
require (
github.com/bazelbuild/rules_go v0.41.0 // indirect
github.com/mattn/go-sqlite3 v1.14.17 // indirect
)

2
go.sum
View File

@ -1,3 +1,5 @@
github.com/bazelbuild/rules_go v0.41.0 h1:JzlRxsFNhlX+g4drDRPhIaU5H5LnI978wdMJ0vK4I+k=
github.com/bazelbuild/rules_go v0.41.0/go.mod h1:TMHmtfpvyfsxaqfL9WnahCsXMWDMICTw7XeK9yVb+YU=
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/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM=