myena / consul-decoder Goto Github PK
View Code? Open in Web Editor NEWUnmarshal consul KV data into abitrary structures
License: MIT License
Unmarshal consul KV data into abitrary structures
License: MIT License
Line 514 in 763cf13
I don't want to have the decoded JSON in the output since it could contain sensitive information.
Thanks.
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
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
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.