title: How to custom handle a file not being found when using go static file server?
body: <p>So I'm using a go server to serve up a single page web application.  </p>
  
  <p>This works for serving all the assets on the root route. All the CSS and HTML are served up correctly. </p>
  
  <pre><code>fs := http.FileServer(http.Dir("build"))
  http.Handle("/", fs)
  </code></pre>
  
  <p>So when the URL is <code>http://myserverurl/index.html</code> or <code>http://myserverurl/styles.css</code>, it serves the corresponding file.</p>
  
  <p>But for a URL like <code>http://myserverurl/myCustompage</code>, it throws <code>404</code> if <code>myCustompage</code> is not a file in the build folder.  </p>
  
  <p>How do I make all routes for which a file does not exist serve <code>index.html</code>? </p>
  
  <p>It is a single page web application and it will render the appropriate screen once the html and js are served. But it needs <code>index.html</code> to be served on routes for which there is no file.</p>
  
  <p>How can this be done?</p>