Hacker News new | past | comments | ask | show | jobs | submit login

Go comes with a built in web server that can serve static web pages easily. What's the point of this?



It's handy to have a program, easily compiled for multiple platforms, that can be told to simply serve a given directory, with optional HTTPS support, and no config files or dependencies—just cross-compile to the target arch/OS, scp it over, and run.

Without, you know, having to write it, even if Go's libraries make it fairly easy to do so.

My go-to (haha) for this is Goserve[1]. I'm not sure why I'd switch to this, except that it may now have more eyes on it after today's publicity (it's already got more stars than Goserve—a little advertising goes a long way)

[1] https://github.com/johnsto/goserve


Static file serving is a great tutorial project in Go. I wrote mine (https://github.com/biorisk/httpfolder) to include a file upload option too, but did not add some of the nicer features, e.g., https, in your project.


So 20 or so lines of code is too tough? How much work is involved integrating this server into an app?


Not sure why you think this server was written to integrate into apps. If you can't think of a use for it, that's fine. But lots of other people do have uses for simple static web servers. Including people who don't have the knowledge, time, or patience to hand code a 20 line Go program every time they want to use one.


By integrate I meant interacting with your program, whatever that may be. With the go server, you get everything this program has without the concern of the code going stale or dying should the author abandon it.



I was wandering the same thing. It takes only few lines to set this one up: https://golang.org/pkg/net/http/#FileServer


As I understand, the point is: a simple and practical bash command to http-serve the current directory (implemented in Go).


So everything Go already does but in bash.


Maybe because you don't have to write it yourself?

    $ go get github.com/m3ng9i/ran && ran


How much work is involved integrating this server into your application versus writing 20 lines of Go code? Or less. Maybe more.


Not necessarily. In addition, this kind of program can be really useful for development.

I use "python3 -m http.server" a lot when I'm just testing a bit of HTML/JS and don't want to setup a whole virtual host within Nginx/Apache. It just starts a static file server, on any platform.


So just like go except with benefits.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: