title: Go cannot call NewRouter() function
body: <p>I'm new to Go, but I'm trying to create a RESTful API using Gorilla Mux to create my router based on this article <a href="http://thenewstack.io/make-a-restful-json-api-go/" rel="nofollow">http://thenewstack.io/make-a-restful-json-api-go/</a></p>
  
  <p>I have a Router file with the below code in it.</p>
  
  <pre><code>package main
  
  import (
      "net/http"
      "github.com/gorilla/mux"
  )
  
  type Route struct {
      Name        string
      Method      string
      Pattern     string
      HandlerFunc http.HandlerFunc
  }
  
  type Routes []Route
  
  func NewRouter() *mux.Router {
  
      router := mux.NewRouter().StrictSlash(true)
      for _, route := range routes {
          router.
              Methods(route.Method).
              Path(route.Pattern).
              Name(route.Name).
              Handler(route.HandlerFunc)
      }
      return router
  }
  
  var routes = Routes{
      Route{
          "Index",
          "GET",
          "/",
          Index,
      },
  }
  </code></pre>
  
  <p>And in my Main.go I have this:</p>
  
  <pre><code>package main
  
  import (
      "log"
      "net/http"
  )
  
  func main() {
      router := NewRouter()
      log.Fatal(http.ListenAndServe(":8080", router))
  }
  </code></pre>
  
  <p>From what I know about Go and how to call a method in one file from another this should work. But when I run: go build Main.go I get this error in my console:</p>
  
  <pre><code>go run Main.go
  # command-line-arguments
  ./Main.go:10: undefined: NewRouter
  </code></pre>
  
  <p>I've run <em>go get</em> in my src folder which has all my files in it to get gorilla, but that didn't fix it. What am I doing wrong here?</p>