diff --git a/Makefile b/Makefile index a114053..e9391c1 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -COMMAND_NAME := bqtableschema +COMMAND_NAME := bqschema-gen COMMIT_HASH := $(shell git rev-parse HEAD) ROOT_DIR := $(shell git rev-parse --show-toplevel) MAIN_DIR := ${ROOT_DIR} diff --git a/README.md b/README.md index 97298d5..bd2d387 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# bqtableschema +# bqschema-gen-go -BigQuery table schema struct generator +BigQuery table schema Go struct generator -[![main](https://github.com/djeeno/bqtableschema/workflows/main/badge.svg)](https://github.com/djeeno/bqtableschema/tree/main) -[![codecov](https://codecov.io/gh/djeeno/bqtableschema/branch/main/graph/badge.svg)](https://codecov.io/gh/djeeno/bqtableschema) +[![main](https://github.com/djeeno/bqschema-gen-go/workflows/main/badge.svg)](https://github.com/djeeno/bqschema-gen-go/tree/main) +[![codecov](https://codecov.io/gh/djeeno/bqschema-gen-go/branch/main/graph/badge.svg)](https://codecov.io/gh/djeeno/bqschema-gen-go) ## generate @@ -12,9 +12,9 @@ BigQuery table schema struct generator ```bash cd /path/to/your/golang-project-repository -# Create a directory where bqtableschema will generate the code. -mkdir -p bqtableschema -cd bqtableschema +# Create a directory where bqschema-gen-go will generate the code. +mkdir -p bqschema +cd bqschema # Set the required environment variables. export GOOGLE_APPLICATION_CREDENTIALS=/path/to/serviceaccount/keyfile.json @@ -23,20 +23,20 @@ export GCLOUD_PROJECT_ID=bigquery-public-data # Set BigQuery Dataset name ref. https://console.cloud.google.com/bigquery?p=bigquery-public-data&d=hacker_news&page=dataset export BIGQUERY_DATASET=hacker_news # Set output file -export OUTPUT_FILE=bqtableschema.generated.go +export OUTPUT_FILE=bqschema.generated.go # generate -go run github.com/djeeno/bqtableschema +go run github.com/djeeno/bqschema-gen-go ``` Example generated file content: ```go -// Code generated by go run github.com/djeeno/bqtableschema; DO NOT EDIT. +// Code generated by go run github.com/djeeno/bqschema-gen-go; DO NOT EDIT. -//go:generate go run github.com/djeeno/bqtableschema +//go:generate go run github.com/djeeno/bqschema-gen-go -package bqtableschema +package bqschema import "time" diff --git a/go.mod b/go.mod index 4172cc2..32d7ec2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/djeeno/bqtableschema +module github.com/djeeno/bqschema-gen-go go 1.15 diff --git a/main.go b/main.go index 7f6ef9d..df5a2e7 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,4 @@ -//go:generate go run github.com/djeeno/bqtableschema +//go:generate go run github.com/djeeno/bqschema-gen-go package main @@ -34,7 +34,7 @@ const ( envNameOutputFile = "OUTPUT_FILE" // defaultValue defaultValueEmpty = "" - defaultValueOutputFile = "bqtableschema.generated.go" + defaultValueOutputFile = "bqschema.generated.go" ) var ( @@ -116,11 +116,11 @@ func Run(ctx context.Context) (err error) { func Generate(ctx context.Context, client *bigquery.Client, dataset string) (generatedCode []byte, err error) { - const head = `// Code generated by go run github.com/djeeno/bqtableschema; DO NOT EDIT. + const head = `// Code generated by go run github.com/djeeno/bqschema-gen-go; DO NOT EDIT. -//go:generate go run github.com/djeeno/bqtableschema +//go:generate go run github.com/djeeno/bqschema-gen-go -package bqtableschema +package bqschema ` diff --git a/main_test.go b/main_test.go index ac35775..28dbad5 100644 --- a/main_test.go +++ b/main_test.go @@ -270,7 +270,7 @@ func Test_generateTableSchemaCode(t *testing.T) { t.Error(err) } // NOTE(djeeno): ここまで来たら、確認したいことは確認済み。 - // ref. https://github.com/djeeno/bqtableschema/blob/260524ce0ae2dd5bdcbdd57446cdd8c140326ca4/main.go#L212 + // ref. https://github.com/djeeno/bqschema-gen-go/blob/260524ce0ae2dd5bdcbdd57446cdd8c140326ca4/main.go#L212 return } } diff --git a/tools/generatewalker.bash b/tools/generatewalker.bash index 0e0ff32..33410e4 100755 --- a/tools/generatewalker.bash +++ b/tools/generatewalker.bash @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -E -e -o pipefail -grep "^\t*//go:generate go run github.com/djeeno/bqtableschema" -r "$(pwd)" -l | xargs -I{} bash -cx "go generate {}" +grep "^\t*//go:generate go run github.com/djeeno/bqschema-gen-go" -r "$(pwd)" -l | xargs -I{} bash -cx "go generate {}"