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

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)