title: How to create methods for string type in Golang
body: <p>I'm planning to create some method extension for the string type.</p>
  
  <p>I need to write all my extension methods into a separate package.</p>
  
  <p>here is my hierarchy.</p>
  
  <pre><code>root
  |    main.go
  |    validation
       |   validate.go
  </code></pre>
  
  <p>on the <code>main.go</code> I would like to have, <code>"abcd".Required()</code></p>
  
  <p><strong>main.go</strong></p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "./validation"
  )
  
  func main() {
      fmt.Println( "abcd".Required() )
  }
  </code></pre>
  
  <p><strong>validate.go</strong></p>
  
  <pre><code>package validation
  
  func (s string) Required() bool {
  
      if s != "" {
          return true
      }
  
      return false
  }
  </code></pre>
  
  <p>When I run it, will get an error.</p>
  
  <p><strong>error</strong></p>
  
  <pre><code>cannot define new methods on non-local type string
  </code></pre>
  
  <p>I found some answers in other questions on StackOverflow but they don't exactly talk about the string type &amp; having the method in a different package file.</p>