diff --git a/README.md b/README.md index c7cef4f..8d9126b 100644 --- a/README.md +++ b/README.md @@ -10,16 +10,16 @@ FS Go is a tiny CLI tool in order to spawn a local file server. In order to build the executable run the following command: -``` -$ go build +```bash +go build ``` ### START THE SERVER Starting the server is easy: -``` -$ ./fs-go -port 8080 -dir . +```bash +./fs-go -port 8080 -dir . ``` Only two parameters are needed: @@ -32,14 +32,14 @@ Only two parameters are needed: If you only want to use this CLI tool as a binary then you can do that easily: -``` -$ go install +```bash +go install ``` Now you can use: -``` -$ fs-go +```bash +fs-go ``` From anywhere in your system. \ No newline at end of file diff --git a/main.go b/main.go index f294adb..655514f 100644 --- a/main.go +++ b/main.go @@ -7,11 +7,13 @@ import ( "net/http" ) +// The port that the fileserver will listen to. var port int + +// The root directory that will be served. var dir string func main() { - // Handle the flags that are provided. flag.IntVar(&port, "port", 8080, "The port that the server will listen to.") flag.StringVar(&dir, "dir", ".", "The root directory that will be served.") @@ -22,11 +24,10 @@ func main() { fs := http.FileServer(http.Dir(dir)) // Print details to the console. - log.Printf("FS - Port: %v | Dir: %v", port, dir) + log.Printf("FS - Port: %d | Dir: %s", port, dir) // Start the file server. if err := http.ListenAndServe(fmt.Sprintf(":%d", port), fs); err != nil { log.Fatalf("server listen on port %v: %v", port, err) } - }