Any Sinatra or Rails like frameworks?

3588 views
Skip to first unread message

R. Rajesh Jeba Anbiah

unread,
Jan 24, 2012, 3:29:37 AM1/24/12
to golang-nuts
I already googled... Is there any Sinatra or Rails like frameworks
in Go to start web development?

--
// PHP Ajax Cookbook -- http://link.packtpub.com/A50biZ //
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Francisco Souza

unread,
Jan 24, 2012, 5:41:23 PM1/24/12
to R. Rajesh Jeba Anbiah, golang-nuts
On Tue, Jan 24, 2012 at 6:29 AM, R. Rajesh Jeba Anbiah <ng4rrj...@rediffmail.com> wrote:

   I already googled... Is there any Sinatra or Rails like frameworks
in Go to start web development?

I think you're just looking for a web framework, since Sinatra is not like Rails.

Check the "web applications" section in the go dashboard [1] and the "web" section on cat-v [2].

[1] http://godashboard.appspot.com/project
[2] http://go-lang.cat-v.org/pure-go-libs

--
Francisco Souza

Marc Byrd

unread,
Jan 24, 2012, 5:52:16 PM1/24/12
to golang-nuts

This maps pretty well to sinatra imho:

Dave Grijalva

unread,
Jan 24, 2012, 6:46:45 PM1/24/12
to golang-nuts
How does one get a project on the go dashboard?

On Jan 24, 2:41 pm, Francisco Souza <f...@souza.cc> wrote:
> On Tue, Jan 24, 2012 at 6:29 AM, R. Rajesh Jeba Anbiah <
>

John Asmuth

unread,
Jan 24, 2012, 7:00:58 PM1/24/12
to golan...@googlegroups.com
On the top of the page there is a submission form. It's curated by hand by a member of the Go team (probably Andrew Gerrand).

Charles Thompson

unread,
Jan 24, 2012, 7:02:01 PM1/24/12
to golang-nuts
Go's standard library gives you much of what Sinatra provides. Check
out the http packages documentation
http://golang.org/pkg/http/

A hello world example looks like this:

package main

import (
"http"
"io"
"log"
)

// hello world, the web server
func HelloServer(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "hello, world!\n")
}

func main() {
http.HandleFunc("/hello", HelloServer)
err := http.ListenAndServe(":12345", nil)
if err != nil {
log.Fatal("ListenAndServe: ", err.String())
}
}

Also check out the "How to write web apps" link from the documentation
page:
http://golang.org/doc/codelab/wiki/

After this Gorilla is the next place to look for more features.

Best,

Charles





Check out http://golang.org/doc/codelab/wiki/.

This maps roughly to Sinatra's hello world example

victorcoder

unread,
Jan 25, 2012, 3:45:57 AM1/25/12
to golan...@googlegroups.com
Rack like framework for Go https://github.com/paulbellamy/mango

Brian Ketelsen

unread,
Jan 25, 2012, 6:14:18 AM1/25/12
to R. Rajesh Jeba Anbiah, golang-nuts
I think Falcore is the closest thing to Sinatra/Rack out there right now:



André Moraes

unread,
Jan 25, 2012, 7:24:57 AM1/25/12
to golang-nuts
If you want something like Rack does, but in Go, just use the standard
HTTP Library (net/http)

Something with easy routing Gorilla (http://code.google.com/p/gorilla/)

SQL Wrapper / ORM -> I saw something on this list but don't remember
the name but it's listed on project dashboard. Just look for
relational mapper.

I generally use the gorilla to extract parameters from the url path
(/fixed/{param1}/etc) and to load my go structures with the
information from HTTP Form fields.

If you are on the weekly tag of Go, I mantain a gorilla clone that
ensure compatibility with weekly, just look on the clone sections of
the offical repository. (andrebq-gorillaw)

--
André Moraes
http://andredevchannel.blogspot.com/

Philip Silva

unread,
Jan 25, 2012, 4:22:35 AM1/25/12
to golang-nuts
On 25 Jan., 01:02, Charles Thompson <charleswthompson...@gmail.com>
wrote:
> Go's standard library gives you much of what Sinatra provides.

On Sinatra you are able to write:

get '/users/:user_id/files/:file_id' do
file_id = params[:file_id]
# ...
end

You can do something similar with web.go. Is there a simple way to
accomplish the same thing just with the standard library?

Rodrigo Moraes

unread,
Jan 25, 2012, 9:43:53 AM1/25/12
to golang-nuts
On Jan 25, 7:22 am, Philip Silva wrote:
> On Sinatra you are able to write:
>
> get '/users/:user_id/files/:file_id' do
>   file_id = params[:file_id]
>   # ...
> end
>
> You can do something similar with web.go. Is there a simple way to
> accomplish the same thing just with the standard library?

No. You need to write a matching library to extract variables and
match HTTP methods. Standard library can only match static path
prefixes.

With Gorilla that function would be something like this:

mux := new(mux.Router)
mux.HandleFunc("/users/{user_id}/files/{file_id}",
SomeHandler).methods("GET")

To have different functions for the same URL but different request
methods you could register it twice or create a subrouter, like this:

mux := new(mux.Router)
sub := mux.Path("/users/{user_id}/files/{file_id}").NewRouter()
sub.methods("GET").HandlerFunc(SomeHandler)
sub.methods("POST").HandlerFunc(OtherHandler)
// ...

The subrouter will test the path first and if it matches, it will test
the methods or other conditions.

I maintain gorilla so I needed to give an example. :)

-- rodrigo

James Cooper

unread,
Jan 25, 2012, 10:08:06 AM1/25/12
to golan...@googlegroups.com
Re: SQL Wrapper / ORM

I've published this to the dashboard:


It's a little in flux at the moment, as exp/sql is in the midst of migrating to database/sql, and the Null* types are still being added to the sql package (there's a CL pending: http://codereview.appspot.com/5557063/ )

But hopefully in a week or two those changes will settle down and gorp will be buildable with the next Go weekly (or Go 1)

-- James

bmizerany

unread,
Jan 25, 2012, 6:40:39 PM1/25/12
to golan...@googlegroups.com
As the creator of Sinatra, I recommend pat.go by Keith Rarick and myself:

Kamil Kisiel

unread,
Mar 21, 2013, 3:59:59 PM3/21/13
to golan...@googlegroups.com, eric...@gmail.com
It's worth pointing out that Gorilla also has a pat implementation: https://github.com/gorilla/pat

It has s a few additional features such as regular expression pattern matches, reverse routing, and other things inherited from gorilla/mux.


On Thursday, March 21, 2013 11:45:58 AM UTC-7, eric...@gmail.com wrote:
Win.
Updated link:
https://github.com/bmizerany/pat
Reply all
Reply to author
Forward
0 new messages