Sunday January 22 2017

gosrv A simple Go file server

There’s not really too much to say here, I saw this was possible when digging through the excellent documentation and decided it would be something worth putting on my git server allowing me to go get to install it.

If you have go installed properly it is indeed as easy as:

$ got get git.riedstra.dev/mitch/gosrv

You can view the source code for the program on my git server.

Usage:

$ gosrv  -h
Usage of Simple File Server:
  -d string
    	Directory to serve. (default ".")
  -l string
    	Listening address (default "0.0.0.0:8001")

Should I actually use this instead of Nginx, Apache or $other_server

Maybe? Maybe not. I wrote it to facilitate quick and easy file transfers over HTTP, I can message someone an internal URL e.g. http://10.1.1.7:8001/secret-recipe.txt So using it instead of Nginx in that case saves time.

It’s not meant for long running constant usage, although you could use it that way and you will not likely see an issue. Go’s HTTP stack is solid.

So, if you want to save time, yes. If you want a production server? No.

If you don’t have go setup properly here’s a quick start:

Then it’s usually as simple as adding:

export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin:/usr/local/go/bin"

In your shell’s profile. You can read more on what the GOPATH is and how it’s structured in the excellent documentation.