Simple implementation of a Go webserver using only native Go components, no external frameworks or libraries, no frills or whatsoever.
The server serves a minimalist wiki editable by anyone.
Run the webserver as such:
go run main.go
You'll see the output in your terminal:
$ go run main.go
Server started... listening on post 5000
URL: http://localhost:5000/
Heroku: https://go-vanillawiki.herokuapp.com/
Private web server: http://vanillawiki.fieel.space/
Of course you'll need the Go cli to run the project.
This wiki.go file uses the following imports, which are necessary to run this web server:
import (
"fmt"
"html/template"
"io/ioutil"
"log"
"net/http"
"os"
"regexp"
"strings"
)
These packages should be found in your local ~/go/bin folder (or wherever your GOPATH points to).
This simple implementation uses some html templates and .txt data sources to create and show individual pages.
Pages are stored in the /pages subdirectory.
This project links to the bulma.io css library for quick styling.
Templates are stored in the /templates subdirectory.
Two layouts are used, view.html and edit.html and are respectively used by Go whenever accessing the /view/ or /edit/ subfolder from the browser.
A third custom is used by the homepage.
The pages temselves are stored as .txt files.
The page name will become the HTML page title and the body of the file will populate the HTML body.