jLuger.de - Serve a video with golang

In my last two posts I've shown how to generate a mp4 video file. In this post I show some go code to serve the generated file via http. It basically boils down to a call of ServeContent in the http package.
package main

import (
"flag"
"log"
"net/http"
"os"
"path"
"time"
)

func main() {
fileName := flag.String("f","","filename to stream")
flag.Parse()
if fileName==nil || *fileName=="" {
log.Println("File needed")
return
}
baseName := path.Base(*fileName)
file,err := os.Open(*fileName)
if err!=nil {
log.Println("Couldn't open file",fileName)
return
}
http.HandleFunc("/stream",func(w http.ResponseWriter, r *http.Request) {
http.ServeContent(w,r,baseName,time.Unix(0,0),file)
})
log.Fatal(http.ListenAndServe(":8010",nil))
}
To start the program type ./prog -f cool_movie.mp4 and then enter http://192.168.0.1:8010/stream in a browser on your smartphone (assuming you PC has the IP 192.168.0.1). I've tested it with Firefox and Chrome. Both could play the file but Firefox has no full screen mode and thus leaves the navigation bars active. A resized and shrinked video isn't what you want when playing around with cardboard VR.