Giter VIP home page Giter VIP logo

consul-decoder's People

Contributors

dcarbone avatar nathanejohnson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

ppai-plivo

consul-decoder's Issues

Re-using struct causes out of range panic

Given:

type (
    ChildPrototype struct {
        Name string
    }
    Parent struct {
        Child1 ChildPrototype
        Child2 ChildPrototype
    }
)

Results in (pulled from test I've created):

panic: reflect: Field index out of range [recovered]
        panic: reflect: Field index out of range

goroutine 4 [running]:
testing.tRunner.func1(0xc000116200)
        testing/testing.go:792 +0x6a7
panic(0x157c060, 0x168eb40)
       runtime/panic.go:513 +0x1b9
reflect.Value.Field(0x15bbe80, 0xc0004901a0, 0x199, 0x18, 0x15bbe80, 0xc0004901a0, 0x199)
       reflect/value.go:786 +0x2bc
github.com/myENA/consul-decoder.(*Decoder).allocAssign(0xc0003b58e0, 0xc0004713c0, 0xc000255980, 0xc0003b52f0, 0x1601e80, 0xc000490000, 0x199, 0xc000465520, 0x8, 0x0, ...)
        src/github.com/myENA/consul-decoder/decoder.go:474 +0x3f3
github.com/myENA/consul-decoder.(*Decoder).Unmarshal(0xc0003b58e0, 0xc000465520, 0x8, 0xc0002383b0, 0xa, 0xc, 0x15675c0, 0xc000490000, 0x0, 0x0)
        src/github.com/myENA/consul-decoder/decoder.go:444 +0x4f8
github.com/myENA/consul-decoder.(*encoderTestSuite).TestUnmarshal(0xc000087020)
        src/github.com/myENA/consul-decoder/decoder_test.go:239 +0x6d5
reflect.Value.call(0xc0003acd20, 0xc000474068, 0x13, 0x160b987, 0x4, 0xc0003b5f00, 0x1, 0x1, 0xc0003b5de8, 0x1063592, ...)
        src/reflect/value.go:447 +0x62c
reflect.Value.Call(0xc0003acd20, 0xc000474068, 0x13, 0xc0003b5f00, 0x1, 0x1, 0x15473e3, 0xd, 0x0)
        reflect/value.go:308 +0xc1
github.com/myENA/consul-decoder/vendor/github.com/stretchr/testify/suite.Run.func2(0xc000116200)
        src/github.com/myENA/consul-decoder/vendor/github.com/stretchr/testify/suite/suite.go:102 +0x2d0
testing.tRunner(0xc000116200, 0xc00040e080)
        testing/testing.go:827 +0x163
created by testing.(*T).Run
       testing/testing.go:878 +0x651
exit status 2
FAIL    github.com/myENA/consul-decoder 2.004s

Bug: Keys that contain JSON cannot be unmarshaled into structs

With the following key setup:

test/
 |- string = "string"
 |- Value = `{"field1":"value","field2": {"map1":"value1","map2":["value2"]}}`

and the following structs:

type (
    TestNestedJSONStructValue struct {
	Field1 string
	Field2 map[string]interface{}
    }
    TestNestedJSONStruct struct {
	String string
	Value  TestNestedJSONStructValue `decoder:"Value,json"`
    }
    TestStruct struct {
        JSONStruct TestNestedJSONStruct `decoder:"test"`
    }
)

the current unmarshal implementation fails silently to populate TestStruct.Value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.