Question: no?

Asked By
dlsniper
Asked At
2017-10-24 21:30:28

Found 15 possible answers.

User Answered At Possible Answer
alex1100 2017-10-24 21:30:29 they could be a slice of interfaces
dlsniper 2017-10-24 21:30:38 why a slice of interface{}
alex1100 2017-10-24 21:30:47 they contain more key value pairs i didnt design their api man. lol if it’s special strain i guess
dlsniper 2017-10-24 21:31:35 well, I'm trying to understand the data structure, while trying to avoid the fact that this is borderline nono material
alex1100 2017-10-24 21:31:59
Effects struct {
    } `json:"effects"
Medical []interface{} json:"medical" Negative []interface{} json:"negative" Positive []string json:"positive" Effects struct { another variant } json:"effects" Medical []string json:"medical" Negative []interface{} json:"negative" Positive []string json:"positive"`
dlsniper 2017-10-24 21:32:45 don't list all please, I can infer that from the comment
alex1100 2017-10-24 21:32:55 sorry :0
dlsniper 2017-10-24 21:33:22 so the values in that case can be either ["string", "string" ] or [ { "key": "val" }, { "key": "val" } ] ?
alex1100 2017-10-24 21:33:32 yes
dlsniper 2017-10-24 21:34:21 right... https://play.golang.org/p/BvQ-WO0nET -> the only solution that's... unfortunate
alex1100 2017-10-24 21:35:13 hmm and it would be alright with it? because if golang doesn’t know we could just use interface right?
dlsniper 2017-10-24 21:37:45 it's because there's no way to have the type there as either a slice of strings, string or struct/map but, in any case, you definitely don't need to write all of that down as a struct so you are left really with just that option for now and Go doesn't like types like that, at least not right now
golang789 2017-10-24 22:30:59 is there a better way to do this?
func int2ip(ui uint32) net.IP {
} return net.IPv4(b[3], b[2], b[1], b[0]) b := *((*[4]byte)(unsafe.Pointer(&ui)))
alex1100 2017-10-24 22:35:03 @dlsniper So I got stuck again and I think I’m almost there }).Methods("GET")
        return strains
        }
            return Strains{}
        if err := json.NewDecoder(res.Body).Decode(&strains); err != nil {
        var strains Strains
        fmt.Println("RESPNONSE IS: ", res.Body)
        // defer res.Body.Close()
        }
            // return
            // http.Error(w, err.Error(), http.StatusInternalServerError)
            // fmt.Printf("Got the error: %s", err)
            return Strains{}
        if err != nil {
        res, err := http.Get(" ")
mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) Strains {
gopher 2017-10-24 22:35:06 The above code in playground: https://play.golang.org/p/Um-dXVWeVc

Related Questions