Golang: Martini - An interesting framework for go

Not sure how many of you have been looking into Go, but this is the first extension of the already stupid simple http interface in Go that I’ve liked so far.


If you have not seen Go yet, I recommend the following:

http://www.youtube.com/watch?v=f6kdp27TYZs (51 minute introduction from one the the creators of Google’s Go - Rob Pike)

Off Topic:

Hm, most things I’ve read about Go online jump straight into the nitty gritty of it without giving a conceptual overview of where it fits into the coding landscape (such as how it compares with other languages, what the use case is for it, how it relates to the web etc.—at least in reasonably basic terms) and I’ve come away shrugging and not thinking it had any use for the web. Always interesting to me how people struggle with presentation issues like this.

How did you feel about Rob’s presentation? Easy concurrent application development is the goal of Go right now. At 28:30 he goes into a simple example, but I think a better example for the web and this forum is probable a video the Andrew Gerrand did:

http://www.youtube.com/watch?v=UgzIApJdLwY - Andrew focuses on the net/http package and builds a couple sample web projects, and walks you through everything

Over my head by a long way, but Andrew’s certainly does give a clearer idea of it. Thanks for that. :slight_smile:

A couple of months ago I was impressed with the “Hello World” and the Moustache demonstration. I set up the Google account which worked fine. I created a link back to a couple of my sites which not only required email verification but also Google crawl treated the link as suspicious.

I tried installing the source code on a couple of sites but Golang refused to work in each case.

I think Golang is a good idea but far too techie for me at the moment, hopefully this will change :frowning:

Can you elaborate on the google account? Google doesn’t force you to join anything for this, it’s open source, it just so happens that there’s employees dedicated to working on it since it is benefiting Google.

As for the code, Golang is a compiled language, like c or c++. Which means that there is not dropping it on your shared hosting provider. You have to have the ability to compile your applications, and run it from command line. This also means that you do not run it with something like apache, Golang would replace apache with its own built in, high performance http package, which is fully demonstrated in the second video.

For quite a while I’ve been staring at Golang trying to fully comprehend it, knowing how much this language could empower my applications due to it’s concurrent nature (think of c++ but MUCH easier). But I would just stare, dabble in a hello world app and never really understand it. Something just clicked for me a few months ago and I’ve been loving it since. One of the things I was afraid of was the “lack of documentation” because it is such a new language, theres not many examples on the web like there is PHP. While true, I finally learned how to navigate GoDoc (their documentation) which is incredibly detailed and useful.

Here is the screen-dump image of Googles “Warning: Suspected phishing site”:

>>> Can you elaborate on the Google account?
I created the account about six months ago using this link:

https://appengine.google.com/” # Google GoLang App Engine

>>> Which means that there is not dropping it on your shared hosting provider.
My knowledge is limited as far as installing Golang on the VPS and will have to watch the videos again and also to ask the Host provider to make the installation.

I studied C++ quite a few years ago, liked the cryptic and succinct language features which was the main attraction to Golang. I would like to start coding again using C and Golang seemed an ideal opportunity.

I have sent a private message giving details of my attempt to get Golang working on my server which requires a Gmail login. If you do not a Gmail account I have a spare that may be used.

John, it seems you are having rouble with Google app engine, not Go itself base on the PM you sent me. Golang does not require app engine to run, it can be compiled locally and run locally (even to develop windowed applications).

Here is the Go website: http://golang.org/ where do you do need an account to download the software. You can skip the app engine part :slight_smile:

H Kyle,

I installed Golang on my local Windows computer and ran through all the tutorials with no problem. Next task was to try and install Golang on one of my Apache sites and this is where I had the problems. The source code is still sat waiting to be installed.

I used Google’s App Engine, which also caters for Python, Java, Go and PHP. I managed to get the application running on Google’s App Engine. I tried to link from my site to the Google’s App Engine and the App Engine required an email verification. Also Google’s crawl warned of a possible phishing site.

That is the link that I sent in the message, did you try the link?

As mentioned before I would like to use Golang and think that a concerted effort is required, I must allocate at least 5 hours and especially eliminate all telephone, email, forums, etc

Hi John,

The problem here is that Go shouldnt be coupled with Apache, it should replace it. I plan on putting up a few introductory tutorials to the language, but in the mean time I recomend this video posted earlier: http://www.youtube.com/watch?v=UgzIApJdLwY

I’m not sure I can help you out with your Google App Engine issues, but as I said, App Engine is NOT a requirement to deploy a Go web app. Nor is apache.

Here is your generic hello world for a web application.

package main
import (
func rootHandler(w http.ResponseWriter, r *http.Request) {
     fmt.Fprint(w, "Hello, world!")
func main() {
     http.HandleFunc("/", rootHandler)
     log.Fatal(http.ListenAndServe(":8080", nil))

line #1 of main we register a route for the root directory of our site
#2 of main is launching a web server on port 8080 and wrapping it with basic logging for errors

Yup, several lines of code and your generating your mcuh more powerful web app. Python can also deploy a web server in about this many lines of code, however python does not have the same performance nor does it have the bread and butter of Go (channels and go routines for easy high concurrency applications).

There is no placing this in apache or anythign like that. You compile this and run it from command line.

I’m a big fan of Go and have part of a production system running on the Revel framework. I’m just about to tear that apart and replace it with Martini. It’s a simple service and Martini feels like the perfect fit.

One of the things I love about Go is that you can get incredible performance for cheap. We can spin up a heroku dyno and handle tens of thousands of requests / minute for simple redis interactions.