Using mgo and writing handlers in Go with net/http

This is a short example of how to write handlers in Go and use the MongoDB mgo driver.

Assume you want to write handlers that are in a package and mount this handler under a certain prefix,
for instance a HelloHandler mounted on /hello/.

So you have a main package and a handler package, called hello.

Directory structure is

~/go/src/example/hello/
~/go/src/example/hello/main.go
~/go/src/example/hello/hello/
~/go/src/example/hello/hello/hello.go

Run it

and navigate to http://localhost:8080/hello/

Neuer Blog

Habe eine neue Blogsoftware geschrieben, also proof of concept.

Mein Privater Blog lebt wieder, allerdings leicht versteckt. Wer ihn findet bekommt … nix.
Das ist der erste Schritt zur kompletten persönlichen Seite.
Dateien, Bilder, Blog, Wiki und was mir noch so einfällt.

Best Slug Matching Regex

From Stackoverflow

or short

Go version

vars in Go packages

Variables in Go packages.

If you’re coming from C++ or PHP you might know the static keyword.
static int myintvar

And since Go’s package structure is pretty weird, I wanted to see how vars behave in packages.
Are they static or are they different depending on who its parent is?

https://github.com/dalu/inheritance

The result is, since a package import is programwide, if another package imports the same package, it imports the same static memory.
In other words, if you set a var to be 10 in package one, import this from main, and import package one from package two, the value of that variable in package one will be 10 for package main and package two.

main <- one main <- two <- one main says one.One = 1 two asks about one.One, gets 1 two sets one.One = 2 main asks about one.One gets 2