title: Golang LinkedList remove first element
body: <p>I'm trying to implement LinkedList operation in Golang from scratch. But I found a problem when dealing with removing first element. My approach is using OOP style, but it seems the first element is not removed. This is the code I write,</p>
  <pre class="lang-golang prettyprint-override"><code>type LinkedList struct {
      Value int
      next  *LinkedList
  }
  
  func (ll *LinkedList) Remove(index int) error {
      pointer := ll
      var pointerPrev *LinkedList = nil
      current := 0
  
      for current &lt; index {
          pointerPrev = pointer
          pointer = pointer.next
          current++
      }
  
      if pointer == ll {
          ll = ll.next // this line is problematic
          pointer = nil
      } else {
          if pointer.next == nil {
              pointerPrev.next = nil
          } else {
              pointerPrev.next = pointer.next
              pointer = nil
          }
      }
  
      return nil
  }
  </code></pre>
  <p>Any suggestion how I implement this way of removing without returning new LinkedList pointer?</p>