Tested with Golang v1.10
This script uses the net/http library to run a nano web server in localhost:8081. The server will consider the app folder as the root path.
Well, there are many nano servers built with many addons (XAMPP, WAMPP, etc...) and i wanted something lighter to run only static HTML sites for developing.
cd server/src && go run server.go
- Compile the source code with the build script. This will create executables for Windows, Mac & Linux for 32 & 64 bits (you can modify the build script to accommodate your needs).
cd server && ./build
- Depending on your architecture, launch the executable. Remember to enable the firewall, if applies.
Modify the server.go
script. There is a section in which is declared the port. Simple, huh? Obviously, you need to recompile the script if you are using an executable.
You can use the code as you want. Just keep a mention. The example page uses jQuery + Bootstrap.
This app was created based in this 2 pages:
Creating A Simple Web Server With Golang & How To Build Go Executables for Multiple Platforms