Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
klipitkas committed Nov 4, 2019
1 parent d236222 commit 5c1a829
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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)
}

}

0 comments on commit 5c1a829

Please sign in to comment.