title: go - golang compile error: type has no method
body: <p>how to solve it?
  <a href="https://play.golang.org/p/aOrqmDM91J" rel="nofollow noreferrer">https://play.golang.org/p/aOrqmDM91J</a></p>
  <blockquote>
  <p>:28: Cache.Segment undefined (type Cache has no method Segment)</p>
  <p>:29: Cache.Segment undefined (type Cache has no method Segment)</p>
  </blockquote>
  <pre><code>package main
  import &quot;fmt&quot;
  
  type Slot struct {  
      Key []string
      Val []string
  }
  
  type Cache struct{
      Segment [3615]Slot
  }
  
  func NewCache(s int) *Cache{
      num:=3615
      Cacheobj:=new(Cache)
      
      for i := 0; i &lt; num; i++ {
          Cacheobj.Segment[i].Key = make([]string, s)
          Cacheobj.Segment[i].Val = make([]string, s)
      }
              
      return Cacheobj
  }
  
  func (*Cache)Set(k string, v string) {
          for mi, mk := range Cache.Segment[0].Key {
           fmt.Println(Cache.Segment[0].Val[mi])  
      }
  }
  func main() {
      Cache1:=NewCache(100)
      Cache1.Set(&quot;a01&quot;, &quot;111111&quot;)
  }
  </code></pre>