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 […]

Best Slug Matching Regex

From Stackoverflow /^ [a-z0-9]+ # One or more repetition of given characters (?: # A non-capture group. – # A hyphen [a-z0-9]+ # One or more repetition of given characters )* # Zero or more repetition of previous group $/ or short /^[a-z0-9]+(?:-[a-z0-9]+)*$/ Go version var slugRegex = regexp.MustCompile(`^[a-z0-9]+(?:-[a-z0-9]+)*$`)