Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
soneda-yuya committed Jan 12, 2025
1 parent c61e839 commit d61d22c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions server/internal/locales/gen/errorkeys/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,9 @@ func capitalize(s string) string {
}

func main() {
// JSON ファイルを指定
jsonFile := "en/error.json"
outputFile := "errorkeys_gen.go"
// JSON ファイルを読み込む

file, err := os.Open(jsonFile)
if err != nil {
panic(err)
Expand All @@ -79,22 +78,22 @@ func main() {
panic(err)
}

// JSON のキーを収集
// collect keys from JSON
keys := CollectKeysFromJSON(data, "")

// 定数コードを生成
// generate constants
var buf bytes.Buffer
buf.WriteString("// Code generated by go generate; DO NOT EDIT.\n")
buf.WriteString("package locales\n\n")
// ここで `type ErrorKey string` を含めないようにする
// here we don't include `type ErrorKey string`
buf.WriteString("const (\n")
for _, key := range keys {
constName := "ErrKey" + toCamelCase(key)
buf.WriteString(fmt.Sprintf("\t%s ErrorKey = \"%s\"\n", constName, key))
}
buf.WriteString(")\n")

// ファイルに書き出し
// write to file
if err := os.WriteFile(outputFile, buf.Bytes(), 0644); err != nil {
panic(err)
}
Expand Down

0 comments on commit d61d22c

Please sign in to comment.