Skip to content

Commit

Permalink
🐛 Fix go-json generator. (#1806)
Browse files Browse the repository at this point in the history
go generate ./... generates panic as import paths have
probably changed over time. This commit free this command
from panics.
  • Loading branch information
thylong committed Mar 5, 2022
1 parent d0934df commit df85b62
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/go-json/cmd/generator/main.go
Expand Up @@ -268,7 +268,7 @@ func (t OpType) FieldToOmitEmptyField() OpType {
}); err != nil {
return err
}
path := filepath.Join(repoRoot(), "internal", "encoder", "optype.go")
path := filepath.Join(repoRoot(), "internal", "go-json", "encoder", "optype.go")
buf, err := format.Source(b.Bytes())
if err != nil {
return err
Expand All @@ -290,7 +290,7 @@ func generateVM() error {
f.Name.Name = pkg
var buf bytes.Buffer
printer.Fprint(&buf, fset, f)
path := filepath.Join(repoRoot(), "internal", "encoder", pkg, "vm.go")
path := filepath.Join(repoRoot(), "internal", "go-json", "encoder", pkg, "vm.go")
source, err := format.Source(buf.Bytes())
if err != nil {
return err
Expand All @@ -304,7 +304,7 @@ func generateVM() error {

func repoRoot() string {
_, file, _, _ := runtime.Caller(0)
relativePathFromRepoRoot := filepath.Join("internal", "cmd", "generator")
relativePathFromRepoRoot := filepath.Join("internal", "go-json", "cmd", "generator")
return strings.TrimSuffix(filepath.Dir(file), relativePathFromRepoRoot)
}

Expand Down

0 comments on commit df85b62

Please sign in to comment.