title: How can I call a function from a controller in a subdirectory - Golang
body: <p>I am trying to make a web app, without using a Framework like Revel and just using the Gorilla toolkit,</p>
  
  <p>So far I have structured my app like this:</p>
  
  <pre><code>/App
  - Controllers
     - Index.go
  - Views
     - Index.html
  - Public
     - css
     - js
     - img
  - main.go
  </code></pre>
  
  <p>My <code>main.go</code> looks like:</p>
  
  <pre><code>package main
  
  import (
      "github.com/gorilla/mux"
      "net/http"
  )
  
  func main() {
  
      r := mux.NewRouter()
  
      r.HandleFunc("/", Index)
  
      http.Handle("/", r)
  
      http.ListenAndServe(":8080", nil)
  }
  </code></pre>
  
  <p>And <code>Index.go</code> looks like </p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "net/http"
  )
  
  func Index(res http.ResponseWriter, req *http.Request) {
      fmt.Println("Here")
  }
  </code></pre>
  
  <p>But when I <code>go run main.go</code> it says Index is undefined, I'm not sure how to call functions from another file in a subdirectory. Any information would be great thanks.</p>