title: Type has no field or method
body: <p>I have a problem with a struct's method.
  In one file (same package) I a struct:</p>
  
  <pre><code>type Task struct {
      ID       int    `json:"id"`
      Priority string `json:"priority"`
      Content  string `json:"content"`
  }
  </code></pre>
  
  <p>The Task comes as a body in POST. Parsing the JSON to this struct works well.
  In other file I have a method:</p>
  
  <pre><code>func (task *Task) createTask() (err error) {
      data, err := bson.Marshal(&amp;task)
      if err != nil {
          return errors.New("error in parsing incoming task")
      }
      rslt, err := collection.InsertOne(context.Background(), data)
      if err != nil {
          return errors.New("error in saving task to database")
      }
      fmt.Println(rslt.InsertedID)
      return nil
  }
  </code></pre>
  
  <p>The Task structure is in the same file with my server. createTask() method is in the file which handles communication to mongoDB.
  When I run my server I have this error:</p>
  
  <pre><code>./server.go:53:12: task.createTask undefined (type Task has no field or method createTask)
  </code></pre>
  
  <p>Here is how I am calling the method:</p>
  
  <pre><code>var task Task
  json.Unmarshal(body, &amp;task)
  err = task.createTask()
  </code></pre>
  
  <p>Do you have any ideas what am I doing wrong?</p>