Duke X

Brazilian, programmer and pseudo-poet

Read this first

rake routes command on grape gem

At April 2013 I write a small article in Portuguese about rails rake routes command on grape gem. I will translate here:

First create a Rakefile:

desc "API Routes"
task :routes do
  MyProject::API.routes.each do |api|
    method = api.route_method.ljust(10)
    path = api.route_path
    puts "     {method} {path}"

Don’t forget change MyProject::API to your class, não run:

$ rake routes
     GET        /resourceX(.:format)
     GET        /resourceX/:id(.:format)
     POST       /resourceX

View →

Manage golang dependencies

Using golang in these 2 months I think the most hard thing is manage dependencies, when I use golang only to test or have fun, normally, I don’t worries with dependencies problems. On Ruby, Java, Python and Nodejs ecosystem have (good) ways to manage dependencies like bundler, maven, virtualenv and npm. Let’s see a little bit about golang dependencies.

There is a initial doc about dependencies in golang.org called How to Write Go Code, the doc say how works the golang workspace, the basic is when we runs go get the go will download and install the packages into $GOPATH, for more details see cmd/go/get.go. The problems with this approach is about the versions of third-party library, for many times I asked: “My code is OK, now how do I guarantee that the third-party libraries I used will stay with the same API?”, I saw some ways to fix it, but none worked fine, like fork the library...

Continue reading →

Tip Golang with EmberJS - JSON Response

If you are search a article step-by-step there are 3 good post by @nerdyworm

Building an App With Ember.js and Go - Part 1

Building an App With Ember.js and Go - Part 2

Building an App With Ember.js and Go - Part 3

This post is about my short experience to build uhura, a podcasts manager. Let’s go!

On API side, I’ll use martini with render package and I have a model called Channel, the initial api code show like it:

package main

import (

type Channel struct {
    Id          int
    Title       string
    Description string

func main() {
    chs := make([]Channel, 2)
    chs[0] = Channel{Id: 1, Title: "First", Description: "Me"}
    chs[1] = Channel{Id: 2, Title: "Second", Description: "You"}

    m := martini.Classic()
    m.Get("/api/channels", func(r

Continue reading →