A go skeleton for websites.

Overview

git-go-websiteskeleton

A basic website skeleton in Go that comes with the Gorilla Multiplexer for routing, glog for access and error logging, as well as jquery, bootstrap, and font-awesome for making excellent web apps.

You Will Need

  1. A go environment http://golang.org/doc/install#install
  2. Gorilla mux: go get github.com/gorilla/mux (http://www.gorillatoolkit.org/pkg/mux)
  3. glog: go get github.com/golang/glog
  4. Some basic knowledge of Go's httpd package. See the excellent gowiki tutorial at http://golang.org/doc/articles/wiki/

Installation

  1. cd $GOPATH/src
  2. git clone https://github.com/jadekler/git-go-websiteskeleton.git
  3. cd git-go-websiteskeleton
  4. go run main.go
  5. Navigate to http://localhost:8080

Note: To make it your own project, simply remove the .git file from the project and upload it into your own repository.

Logging

This project contains access and error logging. By default, these logs will be placed in your system's temp folder (on most *nix machines, this is /tmp; on mac, it's /private/var/gobbledegook). To change the log dir, simply run main with -log_dir="/path/to/dir", as in ./main -log_dir="/path/to/dir". If you decide to change the log location (which I recommend), you are in charge of cleaning your log dir periodically. The program's log library (glog) will handle max file sizes, but multiple logs will not be cleaned automatically.

Some more info on what gets captured:

  • Access logging captures each request served, logging the requestor's IP, the request method, uri, and protocol, the time requested, and the page load time.
  • Error logging captures the time, error, and a stack trace.

Note: on *nix systems, you can also set the TMPDIR environment variable to specify default output location.

What if I want to use HTTPS?

Check out this fantastic blog post by kaihag.

Issues
  • simplify httpInterceptor pattern

    simplify httpInterceptor pattern

    Sorry the changes show every line changed, gofmt did that.

    The actual fix is to simplify the httpInterceptor pattern. Since a mux satisfies the handler interface we can avoid the global router var by passing the router to the httpInterceptor (L#21 and L#35-53) and perform the ServeHTTP on it (L#39).

    You need to do the right dance at the function definition to get all three needed vars inside the function (router, w, req) (#L35-36) but that aside there isn't any thing special about it.

    opened by bryfry 6
  • access logging

    access logging

    Hey man, first of all I love the project. Have been using it to learn Go web development and it's been a big help.

    I noticed a few flaws in your server access logging and wanted to point them out.

    Your access logger takes a response writer, but it's never actually used. So the value for responseBytes is never set or reported, and the status will always be http.StatusOK regardless of what the actual status is.

    I think some confusion might have arisen from trying to incorporate gorilla/mux, but the router return from mux.NewRouter actually implements the interface http.Handler and so the code from https://gist.github.com/cespare/3985516 can actually be used pretty much as -is.

    I've written up my own gist demonstrating that. It's filled with comments to myself as I was going through both of your implementations line by line and I think it may prove helpful. https://gist.github.com/pathouse/e74f9dc7919dd9f0ca88

    question 
    opened by pathouse 4
  • Enabled TLS connection into skeleton

    Enabled TLS connection into skeleton

    I think that enabled TLS connection is good point for this skeleton. It's just few lines of code, but it's so easy in future to change *.pem files to your own and use full secured connection. But there are some disadvantages in this change: new imports, auto-generated certificate by default.

    opened by plutov 2
  • Installation instructions

    Installation instructions

    opened by bryfry 2
  • Import paths incompatible in godoc

    Import paths incompatible in godoc

    Because this is intended to be installed in $GOPATH/src, godoc can't install it. This may represent a deeper problem - if the go community is making apps that assume installations under $GOPATH/src/, then perhaps we should just adhere to that.

    enhancement 
    opened by jadekler 1
  • Template rendering improvements

    Template rendering improvements

    Suggestion from community - needs to be looked into:

    • You shouldn't reload/reparse templates at each request.
    • You should render/execute your template on a byte buffer, then copy that buffer to the http.ResponseWriter. Otherwise you will lose either IO errors or template errors. Either way, a bad idea.
    enhancement question 
    opened by jadekler 0
  • Switch from template.Must to using the template pointer directly

    Switch from template.Must to using the template pointer directly

    As suggested:

    template.Must() returns a pointer to a Template type which is cached (stored in RAM). You can execute content on this type with calling the pointer and calling the method ExecuteTemplate().
    It is shown here: http://golang.org/doc/articles/wiki/#tmp_10
    What you are doing is creating the same Template type over and over again with each request.
    
    bug enhancement 
    opened by jadekler 0
Releases(v1)
  • v1(May 1, 2014)

    This initial release is a basic but highly extensible skeleton that aims at using as many standard go packages as possible in order to give a baseline experience for building web applications. Some exceptions are taken where Go's packages are missing functionality - routing is one such area.

    The highlights of this release: Routing handled by Gorilla Mux. Logging handled by glog and will catch errors (stack trace) and access. Templating and http serving handled by go's built in net/http package.

    Development towards the next release will aim to continue iterating on community feedback as well as providing examples of this skeleton with various database connectors. The decision not to put any one database connector into this skeleton was made because much of what's out right now is very immature. Until some concrete products hit the shelves, I'll create examples for users in branches or a separate /examples area with some of the things out there (such as gorp, beedx, hood, database/sql, etc) and let the users decide which they prefer.

    As a closing note, I highly encourage you to provide feedback on any aspect of this project.

    Source code(tar.gz)
    Source code(zip)
  • v.1(Mar 14, 2014)

Owner
Jean de Klerk
Passionate engineer, avid climber, passable cook, eager traveler. Senior Software Engineer at Google working on NetInfra.
Jean de Klerk
The world’s fastest framework for building websites.

A Fast and Flexible Static Site Generator built with love by bep, spf13 and friends in Go. Website | Forum | Documentation | Installation Guide | Cont

GoHugo.io 59.7k Jun 21, 2022
Crane - 🐦 A full-text WebAssembley search engine for static websites

Crane ?? My blog post: WebAssembly Search Tools for Static Sites Crane is a technical demo is inspired by Stork and uses a near-identical configuratio

Andrew Healey 35 May 25, 2022
A golang script designed to output the cert information for various websites

gofer gofer is a golang script designed to output the cert information for various websites Example run You can supply multiple sites with port (ie. :

Nick Anderson 2 Jun 15, 2022
A go skeleton for websites.

git-go-websiteskeleton A basic website skeleton in Go that comes with the Gorilla Multiplexer for routing, glog for access and error logging, as well

Jean de Klerk 309 Jun 9, 2022
A Game Server Skeleton in golang.

A game server skeleton implemented with golang. 注意(NOTICE) 欢迎加入QQ群: 459420581 (Gopher成都,讨论一切与go有关的话题) gonet/2 gonet1已停止维护(I no longer maintain this, p

xtaci 1.2k Jun 26, 2022
An app skeleton for very simple golang web applications

Golang App Skeleton This is a skeleton for a golang web application optimized for simplicity and rapid development. Prerequisites Go 1.15 or greater O

Ad Hoc 74 Jun 19, 2022
Golang Skeleton With Fully Managed Versions For Kick Start GoLang Project Development

Golang Skeleton With Fully Managed Versions For Kick Start GoLang Project Development There is no doubt that Golang’s good documentation and intellige

MindInventory 323 Jun 26, 2022
utreexo blockchain skeleton

sunyata sunyata is a blockchain skeleton. It implements a minimally-functional proof-of-work blockchain, including consensus algorithms, p2p networkin

The Sia Foundation 18 May 24, 2022
Template project to get started with a simple API skeleton in Go and Docker

A template project to create a Docker image for a Go application. The example application exposes an HTTP endpoint through a REST API packaged as a static binary.

Harsh Mishra 11 Apr 4, 2022
Small skeleton app running on k8s

k8s-go-app Small skeleton app running on k8s Usage NOTE Please replace ${repositry} in below and k8s/*.yml to point your private/public repositry. doc

mattn 8 May 4, 2022
Generates a simple skeleton directory structure for go/gin/bootstrap web apps

Gin Bootstrap Initializer Generates a simple skeleton directory structure for go/gin/bootstrap web apps Description This package handles building a co

Anthony hopkins 0 Jan 21, 2022
⚙️ Convert HTML to Markdown. Even works with entire websites and can be extended through rules.

html-to-markdown Convert HTML into Markdown with Go. It is using an HTML Parser to avoid the use of regexp as much as possible. That should prevent so

Johannes Kaufmann 366 Jun 24, 2022
Flexible HTTP command line stress tester for websites and web services

Pewpew Pewpew is a flexible command line HTTP stress tester. Unlike other stress testers, it can hit multiple targets with multiple configurations, si

Ben Gadbois 339 Jun 17, 2022
The world’s fastest framework for building websites.

A Fast and Flexible Static Site Generator built with love by bep, spf13 and friends in Go. Website | Forum | Documentation | Installation Guide | Cont

GoHugo.io 59.7k Jun 21, 2022
Crane - 🐦 A full-text WebAssembley search engine for static websites

Crane ?? My blog post: WebAssembly Search Tools for Static Sites Crane is a technical demo is inspired by Stork and uses a near-identical configuratio

Andrew Healey 35 May 25, 2022
Take screenshots of websites and create PDF from HTML pages using chromium and docker

gochro is a small docker image with chromium installed and a golang based webserver to interact wit it. It can be used to take screenshots of w

Christian Mehlmauer 48 Jun 12, 2022
Subfinder is a subdomain discovery tool that discovers valid subdomains for websites. Designed as a passive framework to be useful for bug bounties and safe for penetration testing.

Fast passive subdomain enumeration tool. Features • Install • Usage • API Setup • License • Join Discord Subfinder is a subdomain discovery tool that

ProjectDiscovery 5.7k Jun 23, 2022
LinkPage is a FOSS self-hosted alternative to link listing websites such as LinkTree and Campsite.bio

LinkPage LinkPage is a FOSS self-hosted alternative to link listing websites such as LinkTree and Campsite.bio Features Self hostable and open source

Rohan Verma 47 Jun 22, 2022
A simple go program which checks if your websites are running and runs forever (stop it with ctrl+c). It takes two optional arguments, comma separated string with urls and an interval.

uptime A simple go program which checks if your websites are running and runs forever (stop it with ctrl+c). It takes two optional arguments: -interva

Markus Tenghamn 6 Jan 6, 2022
Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Aquatone is a tool for visual inspection of websites across a large amount of hosts and is convenient for quickly gaining an overview of HTTP-based attack surface.

Michael Henriksen 4.7k Jun 26, 2022
Instant online preview of HTML files or websites.

Instant online preview of HTML files or websites.

Krzysztof Kowalczyk 11 Apr 19, 2022
Formrecevr is a simple and lightweight from receiver backend primarily designed for (but not limited to) static websites.

Formrecevr Formrecevr (pronunced "Form receiver") is a simple and lightweight from receiver backend primarily designed for (but not limited to) static

Dorian Zedler 2 Apr 17, 2022
Scrape the web in the eink era. Convert websites into books.

Scrape the web in the eink era. Convert websites into books.

null 32 Jun 21, 2022
A boiler-plate like base for people to get started in creating automation software specifically for purchasing items on websites.

Bot-Base Bot-Base is a small project with concepts for most elements of a bot. Feel free to contact me on Twitter with any questions. Contributing Pul

Edwin J 70 Jun 29, 2022
Subfinder is a subdomain discovery tool that discovers valid subdomains for websites by using passive online sources.

Subfinder is a subdomain discovery tool that discovers valid subdomains for websites by using passive online sources. It has a simple modular architecture and is optimized for speed. subfinder is built for doing one thing only - passive subdomain enumeration, and it does that very well.

Trewis [work] Scotch 2 Feb 13, 2022
Checking if some websites of interest are online

Web site status checker Checking if some websites of interest are online. A little weekend project. Technologies used Go Gin Current sites supported G

null 0 Nov 28, 2021
A golang script designed to output the cert information for various websites

gofer gofer is a golang script designed to output the cert information for various websites Example run You can supply multiple sites with port (ie. :

Nick Anderson 2 Jun 15, 2022
It allows the world to access websites on home computers.

Intranet-Penetration-Go Software function: It allows the world to access websites on home computers. Principle The client runs on a home computer with

Youwei Li 0 Dec 27, 2021
Contact-api - API for websites I have designed that have to send unauthenticated email

contact https://aws.amazon.com/premiumsupport/knowledge-center/custom-headers-ap

Noah Varghese 0 Apr 11, 2022