title: interface conversion: interface {} is float64 not []interface {} PubNub
body: <p>I am trying to get at the JSON values that are passed as a PubNub message on the subscribe end. the code for this is</p>
  
  <pre><code>package main
  
  import (
      "encoding/json"
      "flag"
      "fmt"
      "github.com/pubnub/go/messaging"
  )
  
  type DeployMessages struct {
      Server string
      Repo   string
  }
  
  type PNMessage struct {
      Messages []DeployMessages
      Id       string
      Channel  string
  }
  
  func main() {
      publishKey := flag.String("pub", "demo", "publish key")
      subscribeKey := flag.String("sub", "demo", "subscribe key")
  
      channels := flag.String("channels", "channel1, channel2", "channels to subscribe to")
  
      pubnub := messaging.NewPubnub(*publishKey, *subscribeKey, "", "", false, "", nil)
  
      successChannel := make(chan []byte)
      errorChannel := make(chan []byte)
  
      go pubnub.Subscribe(*channels, "", successChannel, false, errorChannel)
  
      subscribeHandler(successChannel, errorChannel, "Subscribe")
  }
  
  func (pnm *PNMessage) UnmarshalJSON(bs []byte) error {
      var arr []interface{}
      err := json.Unmarshal(bs, &amp;arr)
      if err != nil {
          return err
      }
      messages := arr[0].([]interface{}) 
      pnm.Messages = make([]DeployMessages, len(messages))
      for i, m := range messages {
          pnm.Messages[i].Server = m.(map[string]interface{})["server"].(string) 
          pnm.Messages[i].Repo = m.(map[string]interface{})["repo"].(string)
      }
      pnm.Id = arr[1].(string)      
      pnm.Channel = arr[2].(string)
      return nil
  }
  
  func subscribeHandler(successChannel, errorChannel chan []byte, action string) {
  
      for {
          select {
          case response, ok := &lt;-successChannel:
              if !ok {
                  break
              }
              if string(response) != "[]" {
                  message := PNMessage{}
                  err := json.Unmarshal([]byte(response), &amp;message)
                  if err != nil {
                      break
                  }
                  fmt.Println(fmt.Sprintf("%s Response: %s ", action, response))
                  fmt.Println("")
              }
  
          case failure, ok := &lt;-errorChannel:
              if !ok {
                  break
              }
              if string(failure) != "[]" {
                  if true {
                      fmt.Printf("%s Error Response: %s ", action, failure)
                      fmt.Println("")
                  }
              }
  
          case &lt;-messaging.SubscribeTimeout():
              fmt.Printf("Subscirbe request timeout")
          }
      }
  }
  </code></pre>
  
  <p>The format of the message is this</p>
  
  <blockquote>
    <p>[[{"Repo":"images","Server":"production"}], "149514560987662985",
    "channel1"]</p>
  </blockquote>
  
  <p>This throws the following panic </p>
  
  <blockquote>
    <p>panic: interface conversion: interface {} is float64, not []interface
    {} [recovered]
            panic: interface conversion: interface {} is float64, not []interface {}</p>
    
    <p>goroutine 1 [running]:
    encoding/json.(*decodeState).unmarshal.func1(0xc042065c20)
            C:/Go/src/encoding/json/decode.go:170 +0xf1 panic(0x6548e0, 0xc042009440)
            C:/Go/src/runtime/panic.go:489 +0x2dd main.(*PNMessage).UnmarshalJSON(0xc0420093c0, 0xc042009300, 0x3d,
    0x40, 0x0, 0xb35198)
            C:/Users/olmadmin/Documents/work/Go/src/DeploymentServer/main.go:43
    +0x499 encoding/json.(*decodeState).array(0xc04205b320, 0x64e6a0, 0xc0420093c0, 0x16)
            C:/Go/src/encoding/json/decode.go:489 +0xbe4 encoding/json.(*decodeState).value(0xc04205b320, 0x64e6a0,
    0xc0420093c0, 0x16)
            C:/Go/src/encoding/json/decode.go:399 +0x28e encoding/json.(*decodeState).unmarshal(0xc04205b320, 0x64e6a0,
    0xc0420093c0, 0x0, 0x0)
            C:/Go/src/encoding/json/decode.go:184 +0x221 encoding/json.Unmarshal(0xc042009300, 0x3d, 0x40, 0x64e6a0,
    0xc0420093c0, 0xc042065c98, 0x5f82de)
            C:/Go/src/encoding/json/decode.go:104 +0x14f main.subscribeHandler(0xc042030c00, 0xc042030c60, 0x69c4a4, 0x9)
            C:/Users/olmadmin/Documents/work/Go/src/DeploymentServer/main.go:64
    +0x222 main.main()
            C:/Users/olmadmin/Documents/work/Go/src/DeploymentServer/main.go:34
    +0x27e</p>
  </blockquote>
  
  <p>I was referencing the answer to this question 
  <a href="https://stackoverflow.com/questions/29348262/decoding-pubnub-messages-with-golang-json" title="Decoding PubNub messages with golang JSON">https://stackoverflow.com/questions/29348262/decoding-pubnub-messages-with-golang-json</a>
  Please point me in the right direction...?</p>