pquerna/ffjson

ffjson generated code fails to build in my project

Closed this issue · 1 comments

test/test.go

package test

type Color struct {
    Red   uint8 `json:"red"`
    Green uint8 `json:"green"`
    Blue  uint8 `json:"blue"`
    Alpha uint8 `json:"alpha"`
}

type Colors struct {
    Font       Color `json:"font"`
    Background Color `json:"background"`
}

type KVMap map[string]map[string]Colors

type KVResp struct {
  KVM KVMap `json:"kvs"`
}

main.go

package main

import (
  "fmt"
  "demo/test"
)

func main() {
    t := test.KVResp{}
    fmt.Printf("%#v\n", t)
}

Builds and runs correctly

>$ go build -v
demo/test
demo
>$ ./demo 
test.KVResp{KVM:(*test.KVMap)(nil)}

But fails to build with ffjson:

>$ ffjson test/test.go 
test/test_ffjson.go
$ go build -v
demo/test
# demo/test
test/test_ffjson.go:773: undefined: test in test.Colors
test/test_ffjson.go:781: undefined: test in test.Colors

Seems like one of the issues is map of maps usage, if I replace it with one level map:

type KVMap map[string]Colors

it works. Is this a known limitation? I only see map mentioned under performance pitfalls, so I would expect this to work. Thanks

has same problem when using map