I have some predefined struct (with json tags), that i need to expose
in http via http.FileSystem.
I'm already implement needed functions, but stuck when i need somethins like:

in this case i need to get element with name fist, return it value and
recursive go to the last object.
Does it possible?

I have ugly code that not works as needed:

        for _, name := range strings.Split(f.name, "/") {
                 val := reflect.ValueOf(data)
                 for i := 0; i < val.NumField(); i++ {
                         valueField := val.Field(i)
                         typeField := val.Type().Field(i)
                         tag := typeField.Tag
                         if tag.Get("json") == name &&
!strings.HasSuffix(f.name, name) {
                                 data = valueField.Interface()
                                 continue nameLoop
                         if strings.HasSuffix(f.name, "/") {
                                 buffer = append(buffer,
[]byte(fmt.Sprintf("%s\n", tag.Get("json")))...)
                         } else {
                                 buffer = append(buffer,
[]byte(fmt.Sprintf("%v\n", valueField.Interface()))...)

does somebody knows how to do that i need ?+0 or already have needed code?

Vasiliy Tolstov,
e-mail: [email protected]

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupgolang-nuts @
postedNov 12, '15 at 10:57a
activeNov 12, '15 at 10:57a

1 user in discussion

Vasiliy Tolstov: 1 post



site design / logo © 2023 Grokbase